2024-03-06 19:35:21 +01:00
|
|
|
cargo-target-dir := env('CARGO_TARGET_DIR', 'target')
|
|
|
|
|
|
|
|
|
|
# Compile with debug profile
|
2026-08-21 20:45:16 +02:00
|
|
|
[no-cd]
|
2024-03-06 19:35:21 +01:00
|
|
|
build-debug *args:
|
2026-08-21 20:45:16 +02:00
|
|
|
cargo build {{args}}
|
2024-03-06 19:35:21 +01:00
|
|
|
|
|
|
|
|
# Compile with release profile
|
2026-08-21 20:45:16 +02:00
|
|
|
[no-cd]
|
2024-03-06 19:35:21 +01:00
|
|
|
build-release *args: (build-debug '--release' args)
|
|
|
|
|
|
|
|
|
|
# Compile with a vendored tarball
|
2026-08-21 20:45:16 +02:00
|
|
|
[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
|
2026-08-21 20:45:16 +02:00
|
|
|
[no-cd]
|
2024-03-06 19:35:21 +01:00
|
|
|
check *args:
|
2026-08-21 20:45:16 +02:00
|
|
|
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
|
2026-08-21 20:45:16 +02:00
|
|
|
[no-cd]
|
2024-03-06 19:35:21 +01:00
|
|
|
check-json: (check '--message-format=json')
|
|
|
|
|
|
|
|
|
|
# Remove Cargo build artifacts
|
2024-03-06 20:03:34 +01:00
|
|
|
[no-cd]
|
2024-03-06 19:35:21 +01:00
|
|
|
clean:
|
|
|
|
|
cargo clean
|
|
|
|
|
|
|
|
|
|
# Also remove .cargo and vendored dependencies
|
2024-03-06 20:03:34 +01:00
|
|
|
[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
|
2026-08-21 20:45:16 +02:00
|
|
|
[no-cd]
|
2024-03-06 19:35:21 +01:00
|
|
|
run *args:
|
2026-08-21 20:45:16 +02:00
|
|
|
cargo run {{args}}
|
2024-03-06 19:35:21 +01:00
|
|
|
|
|
|
|
|
# Run `cargo test`
|
2026-08-21 20:45:16 +02:00
|
|
|
[no-cd]
|
2024-03-06 19:35:21 +01:00
|
|
|
test *args:
|
2026-08-21 20:45:16 +02:00
|
|
|
cargo test {{args}}
|
2024-03-06 19:35:21 +01:00
|
|
|
|
2024-03-06 20:03:34 +01:00
|
|
|
# Vendor Cargo dependencies locally
|
|
|
|
|
[no-cd]
|
|
|
|
|
vendor:
|
2026-08-21 20:45:16 +02:00
|
|
|
#!/usr/bin/env bash
|
2024-03-06 20:03:34 +01:00
|
|
|
mkdir -p .cargo
|
2026-01-10 04:48:17 +01:00
|
|
|
cargo vendor --locked | head -n -1 > .cargo/config.toml
|
2024-07-31 16:39:44 +02:00
|
|
|
echo 'directory = "vendor"' >> .cargo/config.toml
|
2026-08-21 20:45:16 +02:00
|
|
|
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 20:03:34 +01:00
|
|
|
|
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
|