mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-04-22 18:21:13 -03:00
Also use a different name than for the CMake variable, to reduce
confusion.
(cherry picked from commit a0b22077a5)
32 lines
975 B
Rust
32 lines
975 B
Rust
use std::{borrow::Cow, env, path::Path};
|
|
|
|
pub fn workspace_root() -> &'static Path {
|
|
let manifest_dir = Path::new(env!("CARGO_MANIFEST_DIR"));
|
|
manifest_dir.ancestors().nth(2).unwrap()
|
|
}
|
|
|
|
fn cargo_target_dir() -> Cow<'static, Path> {
|
|
option_env!("CARGO_TARGET_DIR")
|
|
.map(|d| Cow::Borrowed(Path::new(d)))
|
|
.unwrap_or(Cow::Owned(workspace_root().join("target")))
|
|
}
|
|
|
|
pub fn fish_build_dir() -> Cow<'static, Path> {
|
|
// This is set if using CMake.
|
|
option_env!("FISH_BUILD_DIR")
|
|
.map(|d| Cow::Borrowed(Path::new(d)))
|
|
.unwrap_or(cargo_target_dir())
|
|
}
|
|
|
|
// TODO Move this to rsconf
|
|
pub fn rebuild_if_path_changed<P: AsRef<Path>>(path: P) {
|
|
rsconf::rebuild_if_path_changed(path.as_ref().to_str().unwrap());
|
|
}
|
|
|
|
// TODO Move this to rsconf
|
|
pub fn rebuild_if_paths_changed<P: AsRef<Path>, I: IntoIterator<Item = P>>(paths: I) {
|
|
for path in paths {
|
|
rsconf::rebuild_if_path_changed(path.as_ref().to_str().unwrap());
|
|
}
|
|
}
|