Skip to content

Commit bfc423b

Browse files
committed
chore: Migrate from Makefile to justfile
1 parent f48c1dd commit bfc423b

File tree

4 files changed

+118
-83
lines changed

4 files changed

+118
-83
lines changed

Makefile

Lines changed: 0 additions & 73 deletions
This file was deleted.

debian/control

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Build-Depends:
66
debhelper (>= 11),
77
debhelper-compat (= 11),
88
cargo,
9+
just,
910
libclang-dev,
1011
libglib2.0-dev,
1112
libegl-dev,

debian/rules

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
11
#!/usr/bin/make -f
22

3+
DESTDIR = debian/xdg-desktop-portal-cosmic
34
CLEAN ?= 1
45
VENDOR ?= 1
56

67
%:
78
dh $@
89

910
override_dh_auto_clean:
10-
ifeq ($(CLEAN),1)
11-
make clean
12-
endif
13-
ifeq ($(VENDOR),1)
14-
if ! ischroot; then \
15-
make vendor; \
11+
if test "${CLEAN}" = "1"; then \
12+
cargo clean; \
13+
fi
14+
15+
if ! ischroot && test "${VENDOR}" = "1"; then \
16+
just vendor; \
1617
fi
17-
endif
1818

1919
override_dh_auto_build:
20-
env CARGO_HOME="$$(pwd)/target/cargo" \
21-
make all VENDOR=$(VENDOR) prefix=/usr
20+
just build-vendored
2221

2322
override_dh_auto_install:
24-
dh_auto_install -- prefix=/usr
23+
just rootdir=$(DESTDIR) install

justfile

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
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

Comments
 (0)