Skip to content

Commit

Permalink
Use OUT_DIR over CARGO_TARGET_DIR.
Browse files Browse the repository at this point in the history
- rust-lang/cargo#9661 (comment)
  CARGO_TARGET_DIR from cargo.toml is not available during build scripts at the moment
  • Loading branch information
Allen Hsu committed Aug 6, 2024
1 parent 56a27e9 commit 2feeeb9
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions wezterm-gui/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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-<unique_build_path>/out
for _ in 0..3 { path.pop(); } // drop /build/wezterm-gui-<unique_build_path>/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");
Expand Down

0 comments on commit 2feeeb9

Please sign in to comment.