From 1deb065f59a2aec1056396829d8b169036ad1d18 Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Sat, 27 Jan 2024 20:00:10 +0100 Subject: [PATCH] build.rs: canonicalize CARGO_MANIFEST_DIR We use this so you can run fish from the build directory and it picks up its data files. If this wasn't canonicalized, that would break if you're building with a $PWD through a symlink. --- build.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/build.rs b/build.rs index 2e5bd948b..dfa34f672 100644 --- a/build.rs +++ b/build.rs @@ -13,6 +13,16 @@ fn main() { let build_dir = format!("{}/build", env!("CARGO_MANIFEST_DIR")); let build_dir = option_env!("FISH_BUILD_DIR").unwrap_or(&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. + rsconf::set_env_value( + "CARGO_MANIFEST_DIR", + std::fs::canonicalize(env!("CARGO_MANIFEST_DIR")) + .unwrap() + .as_path() + .to_str() + .unwrap(), + ); cc::Build::new() .file("src/libc.c")