Skip to content

Commit 4f73057

Browse files
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>
1 parent cb640c8 commit 4f73057

File tree

5 files changed

+20
-30
lines changed

5 files changed

+20
-30
lines changed

.changes/cli-hook-env-vars.md

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'tauri-cli': 'patch:bug'
3+
'@tauri-apps/cli': 'patch:bug'
4+
---
5+
6+
Prevent `Invalid target triple` warnings and correctly set `TAURI_ENV_` vars when target triple contains 4 components.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
'tauri-cli': 'patch:breaking'
3+
'@tauri-apps/cli': 'patch:breaking'
4+
---
5+
6+
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:
7+
8+
- `darwin` and `androideabi` are no longer replaced with `macos` and `android` in `TAURI_ENV_PLATFORM`.
9+
- `i686` and `i586` are no longer replaced with `x86` in `TAURI_ENV_ARCH`.

tooling/cli/ENVIRONMENT_VARIABLES.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
<!-- TODO: v2 rename all vars with consistency and grouping -->
2-
31
### Tauri's Environment Variables
42

53
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
4240

4341
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.
4442

43+
- `TAURI_ENV_DEBUG``true` for `dev` command or `build --debug`, `false` otherwise.
44+
- `TAURI_ENV_TARGET_TRIPLE` — Target triple the CLI is building.
4545
- `TAURI_ENV_ARCH` — Target arch, `x86_64`, `aarch64`...etc.
46-
- `TAURI_ENV_PLATFORM` — Target platform, `windows`, `macos`, `linux`...etc.
47-
- `TAURI_ENV_FAMILY` — Target platform family `unix` or `windows`.
48-
- `TAURI_ENV_PLATFORM_TYPE` — Target platform type `Linux`, `Windows_NT` or `Darwin`
46+
- `TAURI_ENV_PLATFORM` — Target platform, `windows`, `darwin`, `linux`...etc.
4947
- `TAURI_ENV_PLATFORM_VERSION` — Build platform version
50-
- `TAURI_ENV_DEBUG``true` for `dev` command, `false` for `build` command.
51-
- `TAURI_ENV_TARGET_TRIPLE` — Target triple the CLI is building.
48+
- `TAURI_ENV_FAMILY` — Target platform family `unix` or `windows`.

tooling/cli/src/interface/rust.rs

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -241,17 +241,8 @@ impl Interface for Rust {
241241
}
242242
};
243243

244-
env.insert(
245-
"TAURI_ENV_ARCH",
246-
match arch {
247-
// keeps compatibility with old `std::env::consts::ARCH` implementation
248-
"i686" | "i586" => "x86".into(),
249-
a => a.into(),
250-
},
251-
);
252-
244+
env.insert("TAURI_ENV_ARCH", arch.into());
253245
env.insert("TAURI_ENV_PLATFORM", host.into());
254-
255246
env.insert(
256247
"TAURI_ENV_FAMILY",
257248
match host {
@@ -260,13 +251,6 @@ impl Interface for Rust {
260251
},
261252
);
262253

263-
match host {
264-
"linux" => env.insert("TAURI_ENV_PLATFORM_TYPE", "Linux".into()),
265-
"windows" => env.insert("TAURI_ENV_PLATFORM_TYPE", "Windows_NT".into()),
266-
"darwin" => env.insert("TAURI_ENV_PLATFORM_TYPE", "Darwin".into()),
267-
_ => None,
268-
};
269-
270254
env
271255
}
272256
}

0 commit comments

Comments
 (0)