Skip to content

Commit fdb3577

Browse files
committed
chore(just): improve the justfile recipes
1 parent 9d01d78 commit fdb3577

File tree

4 files changed

+61
-49
lines changed

4 files changed

+61
-49
lines changed

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,19 @@ And then must be used with a compatible pop-launcher frontend
2020
- [onagre](https://github.com/oknozor/onagre)
2121

2222
```sh
23-
just # Build
23+
just build-release # Build
2424
just install # Install locally
2525
```
2626

27-
Packaging for a Linux distribution?
27+
If you are packaging, run `just vendor` outside of your build chroot, then use `just build-vendored` inside the build-chroot. Then you can specify a custom root directory and prefix.
2828

2929
```sh
30-
just vendor # Vendor
31-
just vendor=1 # Build with vendored dependencies
32-
just rootdir=$(DESTDIR) install # Install to custom root directory
30+
# Outside build chroot
31+
just vendor
32+
33+
# Inside build chroot
34+
just build-vendored
35+
sudo just rootdir=debian/tmp prefix=/usr install
3336
```
3437

3538
Want to install specific plugins? Remove the plugins you don't want:

debian/control

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Build-Depends:
66
cargo,
77
debhelper-compat (=10),
88
just,
9-
pkgconf,
9+
pkg-config,
1010
rustc (>=1.65),
1111
libxkbcommon-dev,
1212
libegl-dev,

debian/rules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ override_dh_auto_clean:
2525
fi
2626

2727
override_dh_auto_build:
28-
env CARGO_HOME="$$(pwd)/target/cargo" just rootdir=$(DESTDIR) debug=$(DEBUG) vendor=$(VENDOR)
28+
just rootdir=$(DESTDIR) build-vendored
2929

3030
override_dh_auto_install:
3131
just rootdir=$(DESTDIR) install

justfile

Lines changed: 51 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,96 @@
1-
debug := '0'
2-
vendor := '0'
3-
4-
target := if debug == '1' { 'debug' } else { 'release' }
5-
vendor_args := if vendor == '1' { '--frozen --offline' } else { '' }
6-
debug_args := if debug == '1' { '' } else { '--release' }
7-
cargo_args := vendor_args + ' ' + debug_args
8-
1+
ID := 'pop-launcher'
92
plugins := 'calc desktop_entries files find pop_shell pulse recent scripts terminal web cosmic_toplevel'
103

11-
ID := 'pop-launcher'
4+
x86-64-target := 'x86-64-v2'
5+
6+
export RUSTFLAGS := if arch() == 'x86_64' {
7+
' -C target-cpu=' + x86-64-target
8+
} else {
9+
''
10+
}
1211

1312
rootdir := ''
1413

15-
base_dir := if rootdir == '' {
16-
env_var('HOME') + '/.local/'
14+
base-dir := if rootdir == '' {
15+
env_var('HOME') / '.local'
1716
} else {
18-
rootdir + '/usr/'
17+
rootdir / 'usr'
1918
}
2019

21-
lib_dir := if rootdir == '' {
22-
base_dir + 'share/'
20+
lib-dir := if rootdir == '' {
21+
base-dir / 'share'
2322
} else {
24-
base_dir + 'lib/'
23+
base-dir / 'lib'
2524
}
2625

27-
bin_dir := base_dir + 'bin/'
28-
bin_path := bin_dir + ID
26+
bin-dir := base-dir / 'bin'
27+
bin-path := bin-dir / ID
2928

30-
launcher_dir := lib_dir + ID + '/'
31-
scripts_dir := launcher_dir + 'scripts/'
32-
plugin_dir := launcher_dir + 'plugins/'
29+
launcher-dir := lib-dir / ID
30+
scripts-dir := launcher-dir / 'scripts/'
31+
plugin-dir := launcher-dir / 'plugins/'
3332

3433
version := '0.0.0'
3534

3635
# Compile pop-launcher
37-
all: _extract_vendor
38-
cargo build -p pop-launcher-bin {{cargo_args}}
36+
all *args: (build-release args)
3937

40-
check:
41-
cargo check -p pop-launcher-bin {{cargo_args}}
38+
# Compile with debug profile
39+
build-debug *args:
40+
cargo build -p pop-launcher-bin {{args}}
41+
42+
# Compile with release profile
43+
build-release *args: (build-debug '--release' args)
44+
45+
# Compile with a vendored tarball
46+
build-vendored *args: _vendor-extract (build-release '--frozen --offline' args)
47+
48+
# Check for errors and linter warnings
49+
check *args:
50+
cargo clippy --all-features {{args}} -- -W clippy::pedantic
51+
52+
# Runs a check with JSON message format for IDE integration
53+
check-json: (check '--message-format=json')
4254

4355
# Remove Cargo build artifacts
4456
clean:
4557
cargo clean
4658

4759
# Also remove .cargo and vendored dependencies
48-
distclean:
60+
clean-dist:
4961
rm -rf .cargo vendor vendor.tar target
5062

5163
# Install everything
52-
install: install_bin install_plugins install_scripts
64+
install: install-bin install-plugins install-scripts
5365

5466
# Install pop-launcher binary
55-
install_bin:
56-
install -Dm0755 target/{{target}}/pop-launcher-bin {{bin_path}}
67+
install-bin:
68+
install -Dm0755 target/release/pop-launcher-bin {{bin-path}}
5769

5870
# Install pop-launcher plugins
59-
install_plugins:
71+
install-plugins:
6072
#!/usr/bin/env sh
6173
set -ex
6274
for plugin in {{plugins}}; do
63-
dest={{plugin_dir}}${plugin}
75+
dest={{plugin-dir}}${plugin}
6476
mkdir -p ${dest}
6577
install -Dm0644 plugins/src/${plugin}/*.ron ${dest}
66-
ln -sf {{bin_path}} {{plugin_dir}}${plugin}/$(echo ${plugin} | sed 's/_/-/')
78+
ln -sf {{bin-path}} {{plugin-dir}}${plugin}/$(echo ${plugin} | sed 's/_/-/')
6779
done
6880

6981
# Install pop-launcher scripts
70-
install_scripts:
82+
install-scripts:
7183
#!/usr/bin/env sh
7284
set -ex
73-
mkdir -p {{scripts_dir}}
85+
mkdir -p {{scripts-dir}}
7486
for script in {{justfile_directory()}}/scripts/*; do
75-
cp -r ${script} {{scripts_dir}}
87+
cp -r ${script} {{scripts-dir}}
7688
done
7789

7890
# Uninstalls everything (requires same arguments as given to install)
7991
uninstall:
80-
rm {{bin_path}}
81-
rm -rf {{launcher_dir}}
92+
rm {{bin-path}}
93+
rm -rf {{launcher-dir}}
8294

8395
# Vendor Cargo dependencies locally
8496
vendor:
@@ -92,9 +104,6 @@ vendor:
92104
rm -rf vendor
93105

94106
# Extracts vendored dependencies if vendor=1
95-
_extract_vendor:
96-
#!/usr/bin/env sh
97-
if test {{vendor}} = 1; then
98-
rm -rf vendor
99-
tar pxf vendor.tar
100-
fi
107+
_vendor-extract:
108+
rm -rf vendor
109+
tar pxf vendor.tar

0 commit comments

Comments
 (0)