From 17958dbbec8d507bf1667e841b3f2da1c0ccaee6 Mon Sep 17 00:00:00 2001 From: Andy Georges Date: Mon, 17 Jun 2024 17:25:57 +0200 Subject: [PATCH] Check for the presence of CARGO_BUILD_TARGET_DIR env variable (#5430) * feat: use CARGO_BUILD_TARGET_DIR env When building in the presence of a CARGO_BUILD_TARGET_DIR, there is no target dir created inside the repo, so copying to a location within the local repo dir fails, hence we need to copy to the actual target dir that is being used. * fix: environment variable with correct name --- wezterm-gui/build.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/wezterm-gui/build.rs b/wezterm-gui/build.rs index 7ef7b9877..6ffb3c085 100644 --- a/wezterm-gui/build.rs +++ b/wezterm-gui/build.rs @@ -168,7 +168,10 @@ END .join("WezTerm.app") .join("Contents") .join("Info.plist"); - let dest_plist = repo_dir.join("target").join(profile).join("Info.plist"); + let build_target_dir = std::env::var("CARGO_TARGET_DIR") + .and_then(|s| Ok(std::path::PathBuf::from(s))) + .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"); std::fs::copy(&src_plist, &dest_plist)