From 2feeeb986c88ff92ba181ff1011546bd114d5a33 Mon Sep 17 00:00:00 2001 From: Allen Hsu Date: Sun, 4 Aug 2024 04:01:52 +1000 Subject: [PATCH] Use OUT_DIR over CARGO_TARGET_DIR. - https://github.com/rust-lang/cargo/issues/9661#issuecomment-1769481293 CARGO_TARGET_DIR from cargo.toml is not available during build scripts at the moment --- wezterm-gui/build.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/wezterm-gui/build.rs b/wezterm-gui/build.rs index 6ffb3c0853f..9d2282834b9 100644 --- a/wezterm-gui/build.rs +++ b/wezterm-gui/build.rs @@ -168,8 +168,14 @@ END .join("WezTerm.app") .join("Contents") .join("Info.plist"); - let build_target_dir = std::env::var("CARGO_TARGET_DIR") - .and_then(|s| Ok(std::path::PathBuf::from(s))) + let build_target_dir = std::env::var("OUT_DIR") + .map(|s| { + let mut path = std::path::PathBuf::from(s); + // OUT_DIR form is: + // $CARGO_TARGET_DIR/target/{profile}/build/wezterm-gui-/out + for _ in 0..3 { path.pop(); } // drop /build/wezterm-gui-/out + path + }) .unwrap_or(repo_dir.join("target").join(profile)); let dest_plist = build_target_dir.join("Info.plist"); println!("cargo:rerun-if-changed=assets/macos/WezTerm.app/Contents/Info.plist");