refactor!: match target triple for TAURI_ENV_ARCH (#8486)

* refactor!: match target triple for `TAURI_ENV_ARCH`

* fix build

* Update .changes/cli-hooks-env-vars-breaking.md

Co-authored-by: Lucas Fernandes Nogueira <lucas@tauri.app>

* Update tooling/cli/ENVIRONMENT_VARIABLES.md

Co-authored-by: Lucas Fernandes Nogueira <lucas@tauri.app>

---------

Co-authored-by: Lucas Fernandes Nogueira <lucas@tauri.app>
This commit is contained in:
Amr Bashir 2023-12-28 17:10:12 +02:00 committed by GitHub
parent cb640c8e94
commit 4f73057e6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 31 deletions

View File

@ -1,6 +0,0 @@
---
'tauri-cli': 'patch:bug'
'@tauri-apps/cli': 'patch:bug'
---
Prevent `Invalid target triple` warnings and correctly set `TAURI_ENV_` vars when target triple contains 4 components. `darwin` and `androideabi` are no longer replaced with `macos` and `android` in `TAURI_ENV_PLATFORM`.

View File

@ -0,0 +1,6 @@
---
'tauri-cli': 'patch:bug'
'@tauri-apps/cli': 'patch:bug'
---
Prevent `Invalid target triple` warnings and correctly set `TAURI_ENV_` vars when target triple contains 4 components.

View File

@ -0,0 +1,9 @@
---
'tauri-cli': 'patch:breaking'
'@tauri-apps/cli': 'patch:breaking'
---
Removed `TAURI_ENV_PLATFORM_TYPE` which will not be set for CLI hook commands anymore, use `TAURI_ENV_PLATFORM` instead. Also Changed value of `TAURI_ENV_PLATFORM` and `TAURI_ENV_ARCH` values to match the target triple more accurately:
- `darwin` and `androideabi` are no longer replaced with `macos` and `android` in `TAURI_ENV_PLATFORM`.
- `i686` and `i586` are no longer replaced with `x86` in `TAURI_ENV_ARCH`.

View File

@ -1,5 +1,3 @@
<!-- TODO: v2 rename all vars with consistency and grouping -->
### Tauri's Environment Variables
This is a documentation of all environment variables used by tauri core crates and tauri CLI.
@ -42,10 +40,9 @@ These environment variables are inputs to the CLI which may have an equivalent C
These environment variables are set for each hook command (`beforeDevCommand`, `beforeBuildCommand`, ...etc) which could be useful to conditionally build your frontend or execute a specific action.
- `TAURI_ENV_ARCH` — Target arch, `x86_64`, `aarch64`...etc.
- `TAURI_ENV_PLATFORM` — Target platform, `windows`, `macos`, `linux`...etc.
- `TAURI_ENV_FAMILY` — Target platform family `unix` or `windows`.
- `TAURI_ENV_PLATFORM_TYPE` — Target platform type `Linux`, `Windows_NT` or `Darwin`
- `TAURI_ENV_PLATFORM_VERSION` — Build platform version
- `TAURI_ENV_DEBUG``true` for `dev` command, `false` for `build` command.
- `TAURI_ENV_DEBUG``true` for `dev` command or `build --debug`, `false` otherwise.
- `TAURI_ENV_TARGET_TRIPLE` — Target triple the CLI is building.
- `TAURI_ENV_ARCH` — Target arch, `x86_64`, `aarch64`...etc.
- `TAURI_ENV_PLATFORM` — Target platform, `windows`, `darwin`, `linux`...etc.
- `TAURI_ENV_PLATFORM_VERSION` — Build platform version
- `TAURI_ENV_FAMILY` — Target platform family `unix` or `windows`.

View File

@ -241,17 +241,8 @@ impl Interface for Rust {
}
};
env.insert(
"TAURI_ENV_ARCH",
match arch {
// keeps compatibility with old `std::env::consts::ARCH` implementation
"i686" | "i586" => "x86".into(),
a => a.into(),
},
);
env.insert("TAURI_ENV_ARCH", arch.into());
env.insert("TAURI_ENV_PLATFORM", host.into());
env.insert(
"TAURI_ENV_FAMILY",
match host {
@ -260,13 +251,6 @@ impl Interface for Rust {
},
);
match host {
"linux" => env.insert("TAURI_ENV_PLATFORM_TYPE", "Linux".into()),
"windows" => env.insert("TAURI_ENV_PLATFORM_TYPE", "Windows_NT".into()),
"darwin" => env.insert("TAURI_ENV_PLATFORM_TYPE", "Darwin".into()),
_ => None,
};
env
}
}