mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-04-21 17:21:14 -03:00
This allows having the proc macro crate as an optional dependency and speeds up compilation in situations where `FISH_GETTEXT_EXTRACTION_FILE` changes, such as the `build_tools/check.sh` script. Because we don't need to recompile on changes to the environment variable when the feature is disabled, cargo can reuse earlier compilation results instead of recompiling everything. This speeds up the compilation work in `build_tools/check.sh` when no changes were made which necessitate recompilation. For such runs of `build_tools/check.sh`, these changes reduce the runtime on my system by about 10 seconds, from 70 to 60, approximately. The difference comes from the following two commands recompiling code without the changes in this commit, but not with them: - `cargo test --doc --workspace` - `cargo doc --workspace`
55 lines
1.2 KiB
Bash
Executable File
55 lines
1.2 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
{
|
|
set -ex
|
|
|
|
lint=true
|
|
if [ "$FISH_CHECK_LINT" = false ]; then
|
|
lint=false
|
|
fi
|
|
|
|
cargo_args=$FISH_CHECK_CARGO_ARGS
|
|
target_triple=$FISH_CHECK_TARGET_TRIPLE
|
|
if [ -n "$target_triple" ]; then
|
|
cargo_args="$cargo_args --target=$FISH_CHECK_TARGET_TRIPLE"
|
|
fi
|
|
|
|
cargo() {
|
|
subcmd=$1
|
|
shift
|
|
# shellcheck disable=2086
|
|
command cargo "$subcmd" $cargo_args "$@"
|
|
}
|
|
|
|
cleanup () {
|
|
if [ -n "$template_file" ] && [ -e "$template_file" ]; then
|
|
rm "$template_file"
|
|
fi
|
|
}
|
|
|
|
trap cleanup EXIT INT TERM HUP
|
|
|
|
if $lint; then
|
|
export RUSTFLAGS="--deny=warnings ${RUSTFLAGS}"
|
|
export RUSTDOCFLAGS="--deny=warnings ${RUSTDOCFLAGS}"
|
|
fi
|
|
|
|
repo_root="$(dirname "$0")/.."
|
|
build_dir="${CARGO_TARGET_DIR:-$repo_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
|
|
cargo clippy --workspace --all-targets
|
|
fi
|
|
cargo test --no-default-features --workspace --all-targets
|
|
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"
|
|
|
|
exit
|
|
}
|