chore(just): add library and Rust version checks

This commit is contained in:
Michael Aaron Murphy 2024-03-06 20:03:34 +01:00 committed by Michael Murphy
parent b65cb1a038
commit f0603d648f
4 changed files with 63 additions and 18 deletions

View file

@ -1,3 +1,13 @@
import "common.just"
# Return an error if the system does not contain the minimum required Rust version.
min-rust-version := '>=' + `grep rust-version Cargo.toml | cut -d' ' -f3 | cut -c 2-7`
rust-version-check := if semver_matches(`rustc --version | cut -c 7-12`, min-rust-version) == "false" {
error('Requires rustc version ' + min-rust-version)
} else {
"passed"
}
cargo-target-dir := env('CARGO_TARGET_DIR', 'target')
# Use mold linker if clang and mold exists.
@ -17,6 +27,7 @@ linker-arg := if clang-path != '' {
export RUSTFLAGS := linker-arg + env_var_or_default('RUSTFLAGS', '')
# Compile with debug profile
[no-cd]
build-debug *args:
cargo build {{args}}
@ -34,10 +45,12 @@ check *args:
check-json: (check '--message-format=json')
# Remove Cargo build artifacts
[no-cd]
clean:
cargo clean
# Also remove .cargo and vendored dependencies
[no-cd]
clean-dist: clean
rm -rf .cargo vendor vendor.tar target
@ -49,8 +62,17 @@ run *args:
test *args:
cargo test {{args}}
# Vendor Cargo dependencies locally
[no-cd]
vendor:
mkdir -p .cargo
cargo vendor | head -n -1 > .cargo/config
echo 'directory = "vendor"' >> .cargo/config
tar pcf vendor.tar vendor
rm -rf vendor
# Extracts vendored dependencies
[private]
[no-cd, private]
vendor-extract:
rm -rf vendor
tar pxf vendor.tar