mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-08 02:31:18 -03:00
Support installing to nested subdirectory of CMAKE_BINARY_DIR
The only install directory that's not supported is -DCMAKE_INSTALL_PREFIX=$CARGO_MANIFEST_DIR, but that's a bad idea anyway since share/ is Git-tracked.
This commit is contained in:
35
src/env/config_paths.rs
vendored
35
src/env/config_paths.rs
vendored
@@ -105,28 +105,16 @@ fn from_exec_path(unresolved_exec_path: PathBuf) -> Self {
|
||||
return invalid_exec_path(exec_path);
|
||||
};
|
||||
|
||||
// If we're in Cargo's target directory or CMake's build directory, use the source files.
|
||||
if exec_path.starts_with(env!("FISH_BUILD_DIR")) {
|
||||
let workspace_root = workspace_root();
|
||||
return Self {
|
||||
kind: WorkspaceRoot,
|
||||
paths: ConfigPaths {
|
||||
sysconf: workspace_root.join("etc"),
|
||||
bin: Some(exec_path_parent.to_owned()),
|
||||
data: workspace_root.join("share"),
|
||||
doc: workspace_root.join("user_doc/html"),
|
||||
locale: workspace_root.join("share/locale"),
|
||||
},
|
||||
exec_path,
|
||||
};
|
||||
}
|
||||
let workspace_root = workspace_root();
|
||||
|
||||
// The next check is that we are in a relocatable directory tree
|
||||
if exec_path_parent.ends_with("bin") {
|
||||
let base_path = exec_path_parent.parent().unwrap();
|
||||
let data = base_path.join("share/fish");
|
||||
let sysconf = base_path.join("etc/fish");
|
||||
if data.exists() && sysconf.exists() {
|
||||
if base_path != workspace_root // Install to repo root is not supported.
|
||||
&& data.exists() && sysconf.exists()
|
||||
{
|
||||
let doc = base_path.join("share/doc/fish");
|
||||
return Self {
|
||||
kind: RelocatableTree,
|
||||
@@ -147,6 +135,21 @@ fn from_exec_path(unresolved_exec_path: PathBuf) -> Self {
|
||||
}
|
||||
}
|
||||
|
||||
// If we're in Cargo's target directory or in CMake's build directory, use the source files.
|
||||
if exec_path.starts_with(env!("FISH_BUILD_DIR")) {
|
||||
return Self {
|
||||
kind: WorkspaceRoot,
|
||||
paths: ConfigPaths {
|
||||
sysconf: workspace_root.join("etc"),
|
||||
bin: Some(exec_path_parent.to_owned()),
|
||||
data: workspace_root.join("share"),
|
||||
doc: workspace_root.join("user_doc/html"),
|
||||
locale: workspace_root.join("share/locale"),
|
||||
},
|
||||
exec_path,
|
||||
};
|
||||
}
|
||||
|
||||
Self {
|
||||
kind: StaticPathsDueToWeirdLayout,
|
||||
paths: ConfigPaths::static_paths(),
|
||||
|
||||
Reference in New Issue
Block a user