From 89282fd9bcce6139a26e71f18004952adb1f80db Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Sat, 20 Jan 2024 19:02:39 +0100 Subject: [PATCH] Use CARGO_MANIFEST_DIR to see if we're running from build dir This allows running a fish built from `cargo build` *and* built via cmake. In future, we should make this an optional thing that's removed from installed builds. --- src/bin/fish.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/bin/fish.rs b/src/bin/fish.rs index a66ca9950..f5a7e4600 100644 --- a/src/bin/fish.rs +++ b/src/bin/fish.rs @@ -77,8 +77,6 @@ const DATA_DIR: &str = env!("DATADIR"); const SYSCONF_DIR: &str = env!("SYSCONFDIR"); const BIN_DIR: &str = env!("BINDIR"); -const OUT_DIR: &str = env!("FISH_BUILD_DIR"); - /// container to hold the options specified within the command line #[derive(Default, Debug)] struct FishCmdOpts { @@ -160,7 +158,7 @@ fn determine_config_directory_paths(argv0: impl AsRef) -> ConfigPaths { // TODO: we should determine program_name from argv0 somewhere in this file // Detect if we're running right out of the CMAKE build directory - if exec_path.starts_with(OUT_DIR) { + if exec_path.starts_with(env!("CARGO_MANIFEST_DIR")) { let manifest_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")); FLOG!( config, @@ -172,7 +170,7 @@ fn determine_config_directory_paths(argv0: impl AsRef) -> ConfigPaths { data: manifest_dir.join("share"), sysconf: manifest_dir.join("etc"), doc: manifest_dir.join("user_doc/html"), - bin: OUT_DIR.into(), + bin: exec_path.clone(), } }