chore(just): justfile refactoring
This commit is contained in:
parent
7d6c5562aa
commit
b65cb1a038
3 changed files with 87 additions and 85 deletions
88
justfile
88
justfile
|
|
@ -1,26 +1,9 @@
|
|||
import 'scripts/cargo.just'
|
||||
import 'scripts/cosmic.just'
|
||||
|
||||
name := 'cosmic-settings'
|
||||
appid := 'com.system76.CosmicSettings'
|
||||
|
||||
# Use mold linker if clang and mold exists.
|
||||
clang-path := `which clang || true`
|
||||
mold-path := `which mold || true`
|
||||
|
||||
linker-arg := if clang-path != '' {
|
||||
if mold-path != '' {
|
||||
'-C linker=' + clang-path + ' -C link-arg=--ld-path=' + mold-path + ' '
|
||||
} else {
|
||||
''
|
||||
}
|
||||
} else {
|
||||
''
|
||||
}
|
||||
|
||||
export RUSTFLAGS := linker-arg + env_var_or_default('RUSTFLAGS', '')
|
||||
|
||||
rootdir := ''
|
||||
prefix := '/usr'
|
||||
|
||||
cargo-target-dir := env('CARGO_TARGET_DIR', 'target')
|
||||
default-schema-target := clean(rootdir / prefix) / 'share' / 'cosmic'
|
||||
|
||||
# File paths
|
||||
|
|
@ -40,55 +23,11 @@ metainfo-dst := clean(rootdir / prefix) / 'share' / 'metainfo' / metainfo
|
|||
[private]
|
||||
default: build-release
|
||||
|
||||
# Remove Cargo build artifacts
|
||||
clean:
|
||||
cargo clean
|
||||
|
||||
# Also remove .cargo and vendored dependencies
|
||||
clean-dist: clean
|
||||
rm -rf .cargo vendor vendor.tar target
|
||||
|
||||
# Compile with debug profile
|
||||
build-debug *args:
|
||||
cargo build {{args}}
|
||||
|
||||
# Compile with release profile
|
||||
build-release *args: (build-debug '--release' args)
|
||||
|
||||
# Compile with a vendored tarball
|
||||
build-vendored *args: vendor-extract (build-release '--frozen --offline' args)
|
||||
|
||||
# Check for errors and linter warnings
|
||||
check *args:
|
||||
cargo clippy --all-features {{args}} -- -W clippy::pedantic
|
||||
|
||||
# Runs a check with JSON message format for IDE integration
|
||||
check-json: (check '--message-format=json')
|
||||
|
||||
# Installation command
|
||||
[private]
|
||||
install-cmd options src dest:
|
||||
install {{options}} {{src}} {{dest}}
|
||||
|
||||
[private]
|
||||
install-bin src dest: (install-cmd '-Dm0755' src dest)
|
||||
|
||||
[private]
|
||||
install-file src dest: (install-cmd '-Dm0644' src dest)
|
||||
|
||||
# Install everything
|
||||
install: (install-bin bin-src bin-dest) (install-file desktop-src desktop-dest) (install-file metainfo-src metainfo-dst)
|
||||
find 'resources'/'default_schema' -type f -exec echo {} \; | rev | cut -d'/' -f-3 | rev | xargs -d '\n' -I {} install -Dm0644 'resources'/'default_schema'/{} {{default-schema-target}}/{}
|
||||
find 'resources'/'icons' -type f -exec echo {} \; | rev | cut -d'/' -f-3 | rev | xargs -d '\n' -I {} install -Dm0644 'resources'/'icons'/{} {{iconsdir}}/{}
|
||||
|
||||
# Run the application for testing purposes
|
||||
run *args:
|
||||
env RUST_LOG=debug RUST_BACKTRACE=full cargo run --release {{args}}
|
||||
|
||||
# Run `cargo test`
|
||||
test:
|
||||
cargo test
|
||||
|
||||
# Uninstalls everything (requires same arguments as given to install)
|
||||
uninstall:
|
||||
rm -rf {{bin-dest}} {{desktop-dest}}
|
||||
|
|
@ -103,24 +42,3 @@ vendor:
|
|||
echo 'directory = "vendor"' >> .cargo/config
|
||||
tar pcf vendor.tar vendor
|
||||
rm -rf vendor
|
||||
|
||||
# Extracts vendored dependencies
|
||||
[private]
|
||||
vendor-extract:
|
||||
rm -rf vendor
|
||||
tar pxf vendor.tar
|
||||
|
||||
# Show the name of the project
|
||||
name:
|
||||
@cargo pkgid | sed -e 's:.*/::' -e 's:[#^].*::'
|
||||
|
||||
# Show the current version
|
||||
version:
|
||||
@cargo pkgid | sed -e 's:.*/::' -e 's:.*#::'
|
||||
|
||||
# Show the current git commit
|
||||
git-rev:
|
||||
@git rev-parse --short HEAD
|
||||
|
||||
info:
|
||||
echo ${RUSTFLAGS}
|
||||
56
scripts/cargo.just
Normal file
56
scripts/cargo.just
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
cargo-target-dir := env('CARGO_TARGET_DIR', 'target')
|
||||
|
||||
# Use mold linker if clang and mold exists.
|
||||
clang-path := `which clang || true`
|
||||
mold-path := `which mold || true`
|
||||
|
||||
linker-arg := if clang-path != '' {
|
||||
if mold-path != '' {
|
||||
'-C linker=' + clang-path + ' -C link-arg=--ld-path=' + mold-path + ' '
|
||||
} else {
|
||||
''
|
||||
}
|
||||
} else {
|
||||
''
|
||||
}
|
||||
|
||||
export RUSTFLAGS := linker-arg + env_var_or_default('RUSTFLAGS', '')
|
||||
|
||||
# Compile with debug profile
|
||||
build-debug *args:
|
||||
cargo build {{args}}
|
||||
|
||||
# Compile with release profile
|
||||
build-release *args: (build-debug '--release' args)
|
||||
|
||||
# Compile with a vendored tarball
|
||||
build-vendored *args: vendor-extract (build-release '--frozen --offline' args)
|
||||
|
||||
# Check for errors and linter warnings
|
||||
check *args:
|
||||
cargo clippy --all-features {{args}} -- -W clippy::pedantic
|
||||
|
||||
# Runs a check with JSON message format for IDE integration
|
||||
check-json: (check '--message-format=json')
|
||||
|
||||
# Remove Cargo build artifacts
|
||||
clean:
|
||||
cargo clean
|
||||
|
||||
# Also remove .cargo and vendored dependencies
|
||||
clean-dist: clean
|
||||
rm -rf .cargo vendor vendor.tar target
|
||||
|
||||
# Run the application for testing purposes
|
||||
run *args:
|
||||
env RUST_LOG=debug RUST_BACKTRACE=full cargo run --release {{args}}
|
||||
|
||||
# Run `cargo test`
|
||||
test *args:
|
||||
cargo test {{args}}
|
||||
|
||||
# Extracts vendored dependencies
|
||||
[private]
|
||||
vendor-extract:
|
||||
rm -rf vendor
|
||||
tar pxf vendor.tar
|
||||
28
scripts/cosmic.just
Normal file
28
scripts/cosmic.just
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
rootdir := ''
|
||||
prefix := '/usr'
|
||||
|
||||
# Installation command
|
||||
[private]
|
||||
install-cmd options src dest:
|
||||
install {{options}} {{src}} {{dest}}
|
||||
|
||||
[private]
|
||||
install-bin src dest: (install-cmd '-Dm0755' src dest)
|
||||
|
||||
[private]
|
||||
install-file src dest: (install-cmd '-Dm0644' src dest)
|
||||
|
||||
# Errors if a command does not exist
|
||||
[private]
|
||||
dep-cmd cmd:
|
||||
@which {{cmd}} >/dev/null || (just print-error 'missing dependency' 'command' {{cmd}}; exit 1)
|
||||
|
||||
# Errors if a library does not exist
|
||||
[private]
|
||||
dep-lib lib:
|
||||
@pkg-config --libs {{lib}} >/dev/null 2>&1 || (just print-error 'missing dependency' 'library' {{lib}}; exit 1)
|
||||
|
||||
# Display a formatted error for the user.
|
||||
[private]
|
||||
print-error msg key value:
|
||||
@echo '\e[0;31mERROR {{msg}}, \e[1;31m{{key}}: \e[0;31m{{value}}\e[0m'
|
||||
Loading…
Add table
Add a link
Reference in a new issue