cosmic-settings/cargo.just

71 lines
1.7 KiB
Text
Raw Normal View History

2024-03-06 19:35:21 +01:00
cargo-target-dir := env('CARGO_TARGET_DIR', 'target')
# Compile with debug profile
[no-cd]
2024-03-06 19:35:21 +01:00
build-debug *args:
cargo build {{args}}
2024-03-06 19:35:21 +01:00
# Compile with release profile
[no-cd]
2024-03-06 19:35:21 +01:00
build-release *args: (build-debug '--release' args)
# Compile with a vendored tarball
[no-cd]
2024-03-06 19:35:21 +01:00
build-vendored *args: vendor-extract (build-release '--frozen --offline' args)
# Check for errors and linter warnings
[no-cd]
2024-03-06 19:35:21 +01:00
check *args:
cargo clippy --all-features {{args}} -- -W clippy::pedantic
2024-03-06 19:35:21 +01:00
# Runs a check with JSON message format for IDE integration
[no-cd]
2024-03-06 19:35:21 +01:00
check-json: (check '--message-format=json')
# Remove Cargo build artifacts
[no-cd]
2024-03-06 19:35:21 +01:00
clean:
cargo clean
# Also remove .cargo and vendored dependencies
[no-cd]
2024-03-06 19:35:21 +01:00
clean-dist: clean
rm -rf .cargo vendor vendor.tar target
# Run the application for testing purposes
[no-cd]
2024-03-06 19:35:21 +01:00
run *args:
cargo run {{args}}
2024-03-06 19:35:21 +01:00
# Run `cargo test`
[no-cd]
2024-03-06 19:35:21 +01:00
test *args:
cargo test {{args}}
2024-03-06 19:35:21 +01:00
# Vendor Cargo dependencies locally
[no-cd]
vendor:
#!/usr/bin/env bash
mkdir -p .cargo
2026-01-10 04:48:17 +01:00
cargo vendor --locked | head -n -1 > .cargo/config.toml
echo 'directory = "vendor"' >> .cargo/config.toml
echo >> .cargo/config.toml
echo '[env]' >> .cargo/config.toml
if [ -n "${SOURCE_DATE_EPOCH}" ]
then
source_date="$(date -d "@${SOURCE_DATE_EPOCH}" "+%Y-%m-%d")"
echo "VERGEN_GIT_COMMIT_DATE = \"${source_date}\"" >> .cargo/config.toml
fi
if [ -n "${SOURCE_GIT_HASH}" ]
then
echo "VERGEN_GIT_SHA = \"${SOURCE_GIT_HASH}\"" >> .cargo/config.toml
fi
tar pcf vendor.tar .cargo vendor
rm -rf .cargo vendor
2024-03-06 19:35:21 +01:00
# Extracts vendored dependencies
2026-01-10 04:48:17 +01:00
[no-cd]
2024-03-06 19:35:21 +01:00
vendor-extract:
rm -rf vendor
tar pxf vendor.tar