Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli.rs): prefix the "before script" env vars with TAURI_ #3274

Merged
merged 3 commits into from
Jan 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .changes/before-script-envs.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"cli.rs": patch
---

Define `PLATFORM`, `ARCH`, `FAMILY`, `PLATFORM_TYPE` and `TAURI_DEBUG` environment variables for the `beforeDevCommand` and `beforeBuildCommand` scripts.
Define `TAURI_PLATFORM`, `TAURI_ARCH`, `TAURI_FAMILY`, `TAURI_PLATFORM_TYPE`, `TAURI_PLATFORM_VERSION` and `TAURI_DEBUG` environment variables for the `beforeDevCommand` and `beforeBuildCommand` scripts.
4 changes: 2 additions & 2 deletions tooling/cli.rs/config_definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -850,11 +850,11 @@ pub struct BuildConfig {
pub dist_dir: AppUrl,
/// A shell command to run before `tauri dev` kicks in.
///
/// The PLATFORM, ARCH, FAMILY, PLATFORM_TYPE and TAURI_DEBUG environment variables are set if you perform conditional compilation.
/// The TAURI_PLATFORM, TAURI_ARCH, TAURI_FAMILY, TAURI_PLATFORM_VERSION, TAURI_PLATFORM_TYPE and TAURI_DEBUG environment variables are set if you perform conditional compilation.
pub before_dev_command: Option<String>,
/// A shell command to run before `tauri build` kicks in.
///
/// The PLATFORM, ARCH, FAMILY, PLATFORM_TYPE and TAURI_DEBUG environment variables are set if you perform conditional compilation.
/// The TAURI_PLATFORM, TAURI_ARCH, TAURI_FAMILY, TAURI_PLATFORM_VERSION, TAURI_PLATFORM_TYPE and TAURI_DEBUG environment variables are set if you perform conditional compilation.
pub before_build_command: Option<String>,
/// Features passed to `cargo` commands.
pub features: Option<Vec<String>>,
Expand Down
14 changes: 7 additions & 7 deletions tooling/cli.rs/src/helpers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,17 @@ pub fn execute_with_output(cmd: &mut Command) -> crate::Result<()> {
pub fn command_env(debug: bool) -> HashMap<String, String> {
let mut map = HashMap::new();

map.insert("PLATFORM".into(), std::env::consts::OS.into());
map.insert("ARCH".into(), std::env::consts::ARCH.into());
map.insert("FAMILY".into(), std::env::consts::FAMILY.into());
map.insert("VERSION".into(), os_info::get().version().to_string());
map.insert("TAURI_PLATFORM".into(), std::env::consts::OS.into());
map.insert("TAURI_ARCH".into(), std::env::consts::ARCH.into());
map.insert("TAURI_FAMILY".into(), std::env::consts::FAMILY.into());
map.insert("TAURI_PLATFORM_VERSION".into(), os_info::get().version().to_string());

#[cfg(target_os = "linux")]
map.insert("PLATFORM_TYPE".into(), "Linux".into());
map.insert("TAURI_PLATFORM_TYPE".into(), "Linux".into());
#[cfg(target_os = "windows")]
map.insert("PLATFORM_TYPE".into(), "Windows_NT".into());
map.insert("TAURI_PLATFORM_TYPE".into(), "Windows_NT".into());
#[cfg(target_os = "macos")]
map.insert("PLATFORM_TYPE".into(), "Darwin".into());
map.insert("TAURI_PLATFORM_TYPE".into(), "Darwin".into());

if debug {
map.insert("TAURI_DEBUG".into(), "true".to_string());
Expand Down