From a20525c44fba0d3c5e928d77d69be4acff89897a Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Fri, 12 Jan 2024 12:50:58 +0100 Subject: [PATCH] build.rs: deduplicate the build-dir heuristic --- fish-rust/build.rs | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/fish-rust/build.rs b/fish-rust/build.rs index 337823bd5..f0dfc6b76 100644 --- a/fish-rust/build.rs +++ b/fish-rust/build.rs @@ -15,12 +15,12 @@ fn main() { } } - let build_dir = PathBuf::from( - std::env::var("FISH_BUILD_DIR") - // Add our default to enable tools that don't go through CMake, like "cargo test" - // and the language server. - .unwrap_or("./build".into()), - ); + let rust_dir = env!("CARGO_MANIFEST_DIR"); + // Add our default to enable tools that don't go through CMake, like "cargo test" and the + // language server. + let build_dir = + PathBuf::from(std::env::var("FISH_BUILD_DIR").unwrap_or(format!("{rust_dir}/build"))); + println!("cargo:rustc-env=FISH_BUILD_DIR={}", build_dir.display()); let cached_curses_libnames = Path::join(&build_dir, "cached-curses-libnames"); let curses_libnames: Vec = if let Ok(lib_path_list) = env::var("CURSES_LIBRARY_LIST") { @@ -66,12 +66,6 @@ fn main() { println!("cargo:rustc-cfg=FISH_USE_POSIX_SPAWN"); } - let rust_dir = env!("CARGO_MANIFEST_DIR"); - // If FISH_BUILD_DIR is given by CMake, then use it; otherwise assume it's at build. - let fish_build_dir = - std::env::var("FISH_BUILD_DIR").unwrap_or(format!("{}/{}", rust_dir, "build/")); - println!("cargo:rustc-env=FISH_BUILD_DIR={fish_build_dir}"); - let mut build = cc::Build::new(); // Add to the default library search path build.flag_if_supported("-L/usr/local/lib/");