diff --git a/build.rs b/build.rs index bdd4062c4..f54838d9d 100644 --- a/build.rs +++ b/build.rs @@ -27,7 +27,7 @@ fn main() { // compare it directly as a string at runtime. rsconf::set_env_value( "CARGO_MANIFEST_DIR", - fish_build_helper::get_repo_root().to_str().unwrap(), + fish_build_helper::workspace_root().to_str().unwrap(), ); // Some build info @@ -335,9 +335,9 @@ fn get_version(src_dir: &Path) -> String { // or because it refused (safe.directory applies to `git describe`!) // So we read the SHA ourselves. fn get_git_hash() -> Result> { - let repo_root_dir = fish_build_helper::get_repo_root(); - let gitdir = repo_root_dir.join(".git"); - let jjdir = repo_root_dir.join(".jj"); + let workspace_root = fish_build_helper::workspace_root(); + let gitdir = workspace_root.join(".git"); + let jjdir = workspace_root.join(".jj"); let commit_id = if gitdir.exists() { // .git/HEAD contains ref: refs/heads/branch let headpath = gitdir.join("HEAD"); diff --git a/build_tools/check.sh b/build_tools/check.sh index 329f49110..48ad70d65 100755 --- a/build_tools/check.sh +++ b/build_tools/check.sh @@ -34,13 +34,13 @@ if $lint; then export RUSTDOCFLAGS="--deny=warnings ${RUSTDOCFLAGS}" fi -repo_root="$(dirname "$0")/.." -build_dir="${CARGO_TARGET_DIR:-$repo_root/target}/${target_triple}/debug" +workspace_root="$(dirname "$0")/.." +build_dir="${CARGO_TARGET_DIR:-$workspace_root/target}/${target_triple}/debug" template_file=$(mktemp) FISH_GETTEXT_EXTRACTION_FILE=$template_file cargo build --workspace --all-targets --features=gettext-extract if $lint; then - PATH="$build_dir:$PATH" "$repo_root/build_tools/style.fish" --all --check + PATH="$build_dir:$PATH" "$workspace_root/build_tools/style.fish" --all --check for features in "" --no-default-features; do cargo clippy --workspace --all-targets $features done @@ -50,7 +50,7 @@ cargo test --doc --workspace if $lint; then cargo doc --workspace fi -FISH_GETTEXT_EXTRACTION_FILE=$template_file "$repo_root/tests/test_driver.py" "$build_dir" +FISH_GETTEXT_EXTRACTION_FILE=$template_file "$workspace_root/tests/test_driver.py" "$build_dir" exit } diff --git a/build_tools/fish_xgettext.fish b/build_tools/fish_xgettext.fish index 009713593..2e50bbc72 100755 --- a/build_tools/fish_xgettext.fish +++ b/build_tools/fish_xgettext.fish @@ -19,7 +19,7 @@ begin echo "" end - set -g repo_root (status dirname)/.. + set -g workspace_root (status dirname)/.. set -l rust_extraction_file if set -l --query _flag_use_existing_template @@ -66,7 +66,7 @@ begin sed -E -e 's_\\\\_\\\\\\\\_g' -e 's_"_\\\\"_g' -e 's_^(.*)$_msgid "\1"\nmsgstr ""\n_' end - set -g share_dir $repo_root/share + set -g share_dir $workspace_root/share # This regex handles explicit requests to translate a message. These are more important to translate # than messages which should be implicitly translated. diff --git a/build_tools/style.fish b/build_tools/style.fish index 28a023919..707246825 100755 --- a/build_tools/style.fish +++ b/build_tools/style.fish @@ -24,7 +24,7 @@ if set -l -q _flag_all end end -set -l repo_root (status dirname)/.. +set -l workspace_root (status dirname)/.. if test $all = yes if not set -l -q _flag_force; and not set -l -q _flag_check @@ -43,7 +43,7 @@ if test $all = yes end end end - set fish_files $repo_root/{benchmarks,build_tools,etc,share}/**.fish + set fish_files $workspace_root/{benchmarks,build_tools,etc,share}/**.fish set python_files {doc_src,share,tests}/**.py else # Format the files specified as arguments. diff --git a/build_tools/update_translations.fish b/build_tools/update_translations.fish index cedd8ec20..cdffdc5ad 100755 --- a/build_tools/update_translations.fish +++ b/build_tools/update_translations.fish @@ -6,7 +6,7 @@ # updates the PO files for each language from that # (changed line numbers, added messages, removed messages), # and finally generates a machine-readable MO file for each language, -# which is stored in share/locale/$LANG/LC_MESSAGES/fish.mo (relative to the repo root). +# which is stored in share/locale/$LANG/LC_MESSAGES/fish.mo (relative to the workspace root). # # Use cases: # For developers: diff --git a/crates/build-helper/src/lib.rs b/crates/build-helper/src/lib.rs index a1bd88440..a12189566 100644 --- a/crates/build-helper/src/lib.rs +++ b/crates/build-helper/src/lib.rs @@ -7,7 +7,7 @@ pub fn canonicalize>(path: P) -> PathBuf { std::fs::canonicalize(path).unwrap() } -pub fn get_repo_root() -> PathBuf { +pub fn workspace_root() -> PathBuf { let manifest_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")); canonicalize(manifest_dir.ancestors().nth(2).unwrap()) } @@ -15,7 +15,7 @@ pub fn get_repo_root() -> PathBuf { pub fn get_target_dir() -> PathBuf { option_env!("CARGO_TARGET_DIR") .map(canonicalize) - .unwrap_or(get_repo_root().join("target")) + .unwrap_or(workspace_root().join("target")) } // TODO Move this to rsconf diff --git a/crates/build-man-pages/build.rs b/crates/build-man-pages/build.rs index 2710d6d62..5230ec211 100644 --- a/crates/build-man-pages/build.rs +++ b/crates/build-man-pages/build.rs @@ -17,19 +17,19 @@ fn main() { fn build_man(man_dir: &Path) { use std::{env, process::Command}; - let repo_root_dir = fish_build_helper::get_repo_root(); + let workspace_root = fish_build_helper::workspace_root(); let man_str = man_dir.to_str().unwrap(); let sec1_dir = man_dir.join("man1"); let sec1_str = sec1_dir.to_str().unwrap(); - let docsrc_dir = repo_root_dir.join("doc_src"); + let docsrc_dir = workspace_root.join("doc_src"); let docsrc_str = docsrc_dir.to_str().unwrap(); let sphinx_doc_sources = [ - repo_root_dir.join("CHANGELOG.rst"), - repo_root_dir.join("CONTRIBUTING.rst"), + workspace_root.join("CHANGELOG.rst"), + workspace_root.join("CONTRIBUTING.rst"), docsrc_dir.clone(), ]; fish_build_helper::rebuild_if_paths_changed(sphinx_doc_sources); diff --git a/tests/test_functions/sphinx-shared.sh b/tests/test_functions/sphinx-shared.sh index bf648da1d..d1c937e51 100755 --- a/tests/test_functions/sphinx-shared.sh +++ b/tests/test_functions/sphinx-shared.sh @@ -10,9 +10,9 @@ cleanup () { trap cleanup EXIT INT TERM HUP -repo_root=$(dirname "$0")/../.. +workspace_root=$(dirname "$0")/../.. builder=$1 -docsrc=$repo_root/doc_src +docsrc=$workspace_root/doc_src tmp_dir=$(mktemp -d) doctree=$tmp_dir/doctree output_dir=$tmp_dir/$builder