cosmic-files/justfile

134 lines
3.8 KiB
Makefile
Raw Normal View History

2024-01-03 15:27:32 -07:00
name := 'cosmic-files'
export APPID := 'com.system76.CosmicFiles'
rootdir := ''
prefix := '/usr'
base-dir := absolute_path(clean(rootdir / prefix))
export INSTALL_DIR := base-dir / 'share'
2024-07-14 19:14:21 +02:00
cargo-target-dir := env('CARGO_TARGET_DIR', 'target')
bin-src := cargo-target-dir / 'release' / name
2024-01-03 15:27:32 -07:00
bin-dst := base-dir / 'bin' / name
2024-08-20 13:26:10 -06:00
applet-name := name + '-applet'
applet-src := cargo-target-dir / 'release' / applet-name
applet-dst := base-dir / 'bin' / applet-name
2024-01-03 15:27:32 -07:00
desktop := APPID + '.desktop'
desktop-src := 'target/xdgen' / desktop
2024-01-03 15:27:32 -07:00
desktop-dst := clean(rootdir / prefix) / 'share' / 'applications' / desktop
2024-03-13 14:05:43 -06:00
metainfo := APPID + '.metainfo.xml'
metainfo-src := 'target/xdgen' / metainfo
2024-03-13 14:05:43 -06:00
metainfo-dst := clean(rootdir / prefix) / 'share' / 'metainfo' / metainfo
icons-src := 'res' / 'icons' / 'hicolor'
icons-dst := clean(rootdir / prefix) / 'share' / 'icons' / 'hicolor'
2024-01-03 15:27:32 -07:00
# Default recipe which runs `just build-release`
default: build-release
# Runs `cargo clean`
clean:
cargo clean
# Removes vendored dependencies
clean-vendor:
rm -rf .cargo vendor vendor.tar
# `cargo clean` and removes vendored dependencies
clean-dist: clean clean-vendor
# Compiles with debug profile
build-debug *args:
cargo build {{args}}
2024-08-20 13:26:10 -06:00
cargo build --package {{applet-name}} {{args}}
2024-01-03 15:27:32 -07:00
# Compiles with release profile
build-release *args: (build-debug '--release' args)
# Compiles applet with release profile
build-release-applet *args:
cargo build --package {{applet-name}} --release {{args}}
2024-01-03 15:27:32 -07:00
# Compiles release profile with vendored dependencies
build-vendored *args: vendor-extract (build-release '--frozen --offline' args)
# Runs a clippy check
check *args:
cargo clippy --all-features {{args}} -- -W clippy::pedantic
# Runs a clippy check with JSON message format
check-json: (check '--message-format=json')
# Developer target
dev *args:
cargo fmt
2024-02-26 14:11:45 -07:00
just run {{args}}
2024-01-03 15:27:32 -07:00
# Run with debug logs
run *args:
cargo build --release
2025-12-21 19:53:09 +01:00
env RUST_LOG=cosmic_files=debug RUST_BACKTRACE=full {{bin-src}} {{args}}
2024-01-03 15:27:32 -07:00
# Run tests
test *args:
cargo test {{args}}
2024-11-14 09:28:28 -07:00
flamegraph *args:
cargo flamegraph --release --bin cosmic-files -- --no-daemon {{args}}
xdg-open flamegraph.svg
2024-11-11 09:24:09 -07:00
heaptrack *args:
#!/usr/bin/env bash
set -ex
rm -fv heaptrack.cosmic-files.*
2024-11-14 09:28:28 -07:00
cargo heaptrack --profile release-with-debug --bin cosmic-files -- --no-daemon {{args}}
2024-11-11 09:24:09 -07:00
zstd -dc < heaptrack.cosmic-files.*.raw.zst | /usr/lib/heaptrack/libexec/heaptrack_interpret | zstd -c > heaptrack.cosmic-files.zst
heaptrack_gui heaptrack.cosmic-files.zst
2024-01-03 15:27:32 -07:00
# Installs files
install:
install -Dm0755 {{bin-src}} {{bin-dst}}
2024-08-20 13:26:10 -06:00
install -Dm0755 {{applet-src}} {{applet-dst}}
install -Dm0644 {{desktop-src}} {{desktop-dst}}
2024-03-13 14:05:43 -06:00
install -Dm0644 {{metainfo-src}} {{metainfo-dst}}
for size in `ls {{icons-src}}`; do \
install -Dm0644 "{{icons-src}}/$size/apps/{{APPID}}.svg" "{{icons-dst}}/$size/apps/{{APPID}}.svg"; \
done
2024-01-03 15:27:32 -07:00
# Installs applet files
install-applet:
install -Dm0755 {{applet-src}} {{applet-dst}}
2024-01-03 15:27:32 -07:00
# Uninstalls installed files
uninstall:
2024-08-20 13:26:10 -06:00
rm -f {{bin-dst}} {{applet-dst}}
2024-01-03 15:27:32 -07:00
# Vendor dependencies locally
vendor:
#!/usr/bin/env bash
2024-01-03 15:27:32 -07:00
mkdir -p .cargo
cargo vendor --sync Cargo.toml | 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-01-03 15:27:32 -07:00
# Extracts vendored dependencies
vendor-extract:
rm -rf vendor
tar pxf vendor.tar