|
| 1 | +name := 'xdg-desktop-portal-cosmic' |
| 2 | +export APPID := 'org.freedesktop.impl.portal.desktop.cosmic' |
| 3 | + |
| 4 | +rootdir := '' |
| 5 | +prefix := '/usr' |
| 6 | + |
| 7 | +# Paths for the final installed system (used in service files) |
| 8 | +libexecdir := clean(prefix / 'libexec') |
| 9 | + |
| 10 | +# Paths for staging installation (includes rootdir) |
| 11 | +base-dir := absolute_path(clean(rootdir / prefix)) |
| 12 | + |
| 13 | +export INSTALL_DIR := base-dir / 'share' |
| 14 | + |
| 15 | +bin-dir := base-dir / 'libexec' |
| 16 | +data-dir := base-dir / 'share' |
| 17 | +lib-dir := base-dir / 'lib' |
| 18 | +icons-dir := data-dir / 'icons' / 'hicolor' |
| 19 | + |
| 20 | +cargo-target-dir := env('CARGO_TARGET_DIR', 'target') |
| 21 | +bin-src := cargo-target-dir / 'release' / name |
| 22 | +bin-dst := bin-dir / name |
| 23 | + |
| 24 | +# Default recipe which runs `just build-release` |
| 25 | +[private] |
| 26 | +default: build-release |
| 27 | + |
| 28 | +# Runs `cargo clean` |
| 29 | +clean: |
| 30 | + cargo clean |
| 31 | + |
| 32 | +# `cargo clean` and removes vendored dependencies |
| 33 | +clean-dist: clean |
| 34 | + rm -rf .cargo vendor vendor.tar |
| 35 | + |
| 36 | +# Compiles with debug profile |
| 37 | +build-debug *args: |
| 38 | + cargo build {{args}} |
| 39 | + |
| 40 | +# Compiles with release profile |
| 41 | +build-release *args: (build-debug '--release' args) |
| 42 | + |
| 43 | +# Compiles release profile with vendored dependencies |
| 44 | +build-vendored *args: vendor-extract (build-release '--frozen --offline' args) |
| 45 | + |
| 46 | +# Runs a clippy check |
| 47 | +check *args: |
| 48 | + cargo clippy --all-features {{args}} -- -W clippy::pedantic |
| 49 | + |
| 50 | +# Runs a clippy check with JSON message format |
| 51 | +check-json: (check '--message-format=json') |
| 52 | + |
| 53 | +# Run with debug logs |
| 54 | +run *args: |
| 55 | + env RUST_LOG=debug RUST_BACKTRACE=full cargo run --release {{args}} |
| 56 | + |
| 57 | +# Installs files |
| 58 | +install: |
| 59 | + install -Dm0755 {{bin-src}} {{bin-dst}} |
| 60 | + sed 's|@libexecdir@|{{libexecdir}}|' data/dbus-1/{{APPID}}.service.in \ |
| 61 | + | install -Dm0644 /dev/stdin {{data-dir}}/dbus-1/services/{{APPID}}.service |
| 62 | + sed 's|@libexecdir@|{{libexecdir}}|' data/{{APPID}}.service.in \ |
| 63 | + | install -Dm0644 /dev/stdin {{lib-dir}}/systemd/user/{{APPID}}.service |
| 64 | + install -Dm0644 data/cosmic.portal {{data-dir}}/xdg-desktop-portal/portals/cosmic.portal |
| 65 | + install -Dm0644 data/cosmic-portals.conf {{data-dir}}/xdg-desktop-portal/cosmic-portals.conf |
| 66 | + find 'data'/'icons' -type f -exec echo {} \; \ |
| 67 | + | rev \ |
| 68 | + | cut -d'/' -f-3 \ |
| 69 | + | rev \ |
| 70 | + | xargs -d '\n' -I {} install -Dm0644 'data'/'icons'/{} {{icons-dir}}/{} |
| 71 | + -pkill -f 'xdg-desktop-portal-cosmic' |
| 72 | + |
| 73 | +# Uninstalls installed files |
| 74 | +uninstall: |
| 75 | + rm -f {{bin-dst}} |
| 76 | + rm -f {{data-dir}}/dbus-1/services/{{APPID}}.service |
| 77 | + rm -f {{lib-dir}}/systemd/user/{{APPID}}.service |
| 78 | + rm -f {{data-dir}}/xdg-desktop-portal/portals/cosmic.portal |
| 79 | + rm -f {{data-dir}}/xdg-desktop-portal/cosmic-portals.conf |
| 80 | + find 'data'/'icons' -type f -exec echo {} \; \ |
| 81 | + | rev \ |
| 82 | + | cut -d'/' -f-3 \ |
| 83 | + | rev \ |
| 84 | + | xargs -d '\n' -I {} rm -f {{icons-dir}}/{} |
| 85 | + |
| 86 | +# Vendor dependencies locally |
| 87 | +vendor: |
| 88 | + rm -rf .cargo |
| 89 | + mkdir -p .cargo |
| 90 | + cargo vendor | head -n -1 > .cargo/config.toml |
| 91 | + echo 'directory = "vendor"' >> .cargo/config.toml |
| 92 | + echo >> .cargo/config.toml |
| 93 | + echo '[env]' >> .cargo/config.toml |
| 94 | + if [ -n "$${SOURCE_DATE_EPOCH}" ]; then \ |
| 95 | + source_date="$$(date -d "@$${SOURCE_DATE_EPOCH}" "+%Y-%m-%d")"; \ |
| 96 | + echo "VERGEN_GIT_COMMIT_DATE = \"$${source_date}\"" >> .cargo/config.toml; \ |
| 97 | + fi |
| 98 | + if [ -n "$${SOURCE_GIT_HASH}" ]; then \ |
| 99 | + echo "VERGEN_GIT_SHA = \"$${SOURCE_GIT_HASH}\"" >> .cargo/config.toml; \ |
| 100 | + fi |
| 101 | + tar pcf vendor.tar .cargo vendor |
| 102 | + rm -rf .cargo vendor |
| 103 | + |
| 104 | +# Extracts vendored dependencies |
| 105 | +[private] |
| 106 | +vendor-extract: |
| 107 | + rm -rf vendor |
| 108 | + tar pxf vendor.tar |
0 commit comments