Skip to content

Commit

Permalink
Use CARGO_MANIFEST_DIR to see if we're running from build dir
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
faho committed Jan 21, 2024
1 parent 3ecd835 commit 89282fd
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/bin/fish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -160,7 +158,7 @@ fn determine_config_directory_paths(argv0: impl AsRef<Path>) -> 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,
Expand All @@ -172,7 +170,7 @@ fn determine_config_directory_paths(argv0: impl AsRef<Path>) -> 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(),
}
}

Expand Down

0 comments on commit 89282fd

Please sign in to comment.