From 2d4e42ee93327b9cfd554a0d809f85e3d371e70e Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Mon, 6 May 2024 19:50:49 -0500 Subject: [PATCH] Don't use a hardcoded ./build/ path for FISH_BUILD_DIR We use this fallback value for FISH_BUILD_DIR when `cargo` is not invoked from `cmake`, but we already have a cargo-defined build directory and we shouldn't just decide to use $TARGET_MANIFEST_DIR/build instead. Tests pass locally! --- build.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/build.rs b/build.rs index b664b0835..82240c21d 100644 --- a/build.rs +++ b/build.rs @@ -10,8 +10,11 @@ fn main() { // Add our default to enable tools that don't go through CMake, like "cargo test" and the // language server. - let build_dir = format!("{}/build", env!("CARGO_MANIFEST_DIR")); - let build_dir = option_env!("FISH_BUILD_DIR").unwrap_or(&build_dir); + + // FISH_BUILD_DIR is set by CMake, if we are using it. + // OUT_DIR is set by Cargo when the build script is running (not compiling) + let default_build_dir = env::var("OUT_DIR").unwrap(); + let build_dir = option_env!("FISH_BUILD_DIR").unwrap_or(&default_build_dir); rsconf::set_env_value("FISH_BUILD_DIR", build_dir); // We need to canonicalize (i.e. realpath) // the manifest dir because we want to compare it simply as a string at runtime.