chore(just): improve the justfile recipes

This commit is contained in:
Michael Aaron Murphy 2023-02-06 19:26:39 +01:00 • committed by Michael Murphy
parent 9d01d7873e
commit fdb35774c9
4 changed files with 61 additions and 49 deletions

View file

@ -20,16 +20,19 @@ And then must be used with a compatible pop-launcher frontend
- [onagre](https://github.com/oknozor/onagre) - [onagre](https://github.com/oknozor/onagre)
```sh ```sh
just # Build just build-release # Build
just install # Install locally just install # Install locally
``` ```
Packaging for a Linux distribution? 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.
```sh ```sh
just vendor # Vendor # Outside build chroot
just vendor=1 # Build with vendored dependencies just vendor
just rootdir=$(DESTDIR) install # Install to custom root directory
# Inside build chroot
just build-vendored
sudo just rootdir=debian/tmp prefix=/usr install
``` ```
Want to install specific plugins? Remove the plugins you don't want: Want to install specific plugins? Remove the plugins you don't want:

2
debian/control vendored
View file

@ -6,7 +6,7 @@ Build-Depends:
cargo, cargo,
debhelper-compat (=10), debhelper-compat (=10),
just, just,
pkgconf, pkg-config,
rustc (>=1.65), rustc (>=1.65),
libxkbcommon-dev, libxkbcommon-dev,
libegl-dev, libegl-dev,

2
debian/rules vendored
View file

@ -25,7 +25,7 @@ override_dh_auto_clean:
fi fi
override_dh_auto_build: override_dh_auto_build:
env CARGO_HOME="$$(pwd)/target/cargo" just rootdir=$(DESTDIR) debug=$(DEBUG) vendor=$(VENDOR) just rootdir=$(DESTDIR) build-vendored
override_dh_auto_install: override_dh_auto_install:
just rootdir=$(DESTDIR) install just rootdir=$(DESTDIR) install

View file

@ -1,84 +1,96 @@
debug := '0' ID := 'pop-launcher'
vendor := '0'
target := if debug == '1' { 'debug' } else { 'release' }
vendor_args := if vendor == '1' { '--frozen --offline' } else { '' }
debug_args := if debug == '1' { '' } else { '--release' }
cargo_args := vendor_args + ' ' + debug_args
plugins := 'calc desktop_entries files find pop_shell pulse recent scripts terminal web cosmic_toplevel' plugins := 'calc desktop_entries files find pop_shell pulse recent scripts terminal web cosmic_toplevel'
ID := 'pop-launcher' x86-64-target := 'x86-64-v2'
export RUSTFLAGS := if arch() == 'x86_64' {
' -C target-cpu=' + x86-64-target
} else {
''
}
rootdir := '' rootdir := ''
base_dir := if rootdir == '' { base-dir := if rootdir == '' {
env_var('HOME') + '/.local/' env_var('HOME') / '.local'
} else { } else {
rootdir + '/usr/' rootdir / 'usr'
} }
lib_dir := if rootdir == '' { lib-dir := if rootdir == '' {
base_dir + 'share/' base-dir / 'share'
} else { } else {
base_dir + 'lib/' base-dir / 'lib'
} }
bin_dir := base_dir + 'bin/' bin-dir := base-dir / 'bin'
bin_path := bin_dir + ID bin-path := bin-dir / ID
launcher_dir := lib_dir + ID + '/' launcher-dir := lib-dir / ID
scripts_dir := launcher_dir + 'scripts/' scripts-dir := launcher-dir / 'scripts/'
plugin_dir := launcher_dir + 'plugins/' plugin-dir := launcher-dir / 'plugins/'
version := '0.0.0' version := '0.0.0'
# Compile pop-launcher # Compile pop-launcher
all: _extract_vendor all *args: (build-release args)
cargo build -p pop-launcher-bin {{cargo_args}}
check: # Compile with debug profile
cargo check -p pop-launcher-bin {{cargo_args}} build-debug *args:
cargo build -p pop-launcher-bin {{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 # Remove Cargo build artifacts
clean: clean:
cargo clean cargo clean
# Also remove .cargo and vendored dependencies # Also remove .cargo and vendored dependencies
distclean: clean-dist:
rm -rf .cargo vendor vendor.tar target rm -rf .cargo vendor vendor.tar target
# Install everything # Install everything
install: install_bin install_plugins install_scripts install: install-bin install-plugins install-scripts
# Install pop-launcher binary # Install pop-launcher binary
install_bin: install-bin:
install -Dm0755 target/{{target}}/pop-launcher-bin {{bin_path}} install -Dm0755 target/release/pop-launcher-bin {{bin-path}}
# Install pop-launcher plugins # Install pop-launcher plugins
install_plugins: install-plugins:
#!/usr/bin/env sh #!/usr/bin/env sh
set -ex set -ex
for plugin in {{plugins}}; do for plugin in {{plugins}}; do
dest={{plugin_dir}}${plugin} dest={{plugin-dir}}${plugin}
mkdir -p ${dest} mkdir -p ${dest}
install -Dm0644 plugins/src/${plugin}/*.ron ${dest} install -Dm0644 plugins/src/${plugin}/*.ron ${dest}
ln -sf {{bin_path}} {{plugin_dir}}${plugin}/$(echo ${plugin} | sed 's/_/-/') ln -sf {{bin-path}} {{plugin-dir}}${plugin}/$(echo ${plugin} | sed 's/_/-/')
done done
# Install pop-launcher scripts # Install pop-launcher scripts
install_scripts: install-scripts:
#!/usr/bin/env sh #!/usr/bin/env sh
set -ex set -ex
mkdir -p {{scripts_dir}} mkdir -p {{scripts-dir}}
for script in {{justfile_directory()}}/scripts/*; do for script in {{justfile_directory()}}/scripts/*; do
cp -r ${script} {{scripts_dir}} cp -r ${script} {{scripts-dir}}
done done
# Uninstalls everything (requires same arguments as given to install) # Uninstalls everything (requires same arguments as given to install)
uninstall: uninstall:
rm {{bin_path}} rm {{bin-path}}
rm -rf {{launcher_dir}} rm -rf {{launcher-dir}}
# Vendor Cargo dependencies locally # Vendor Cargo dependencies locally
vendor: vendor:
@ -92,9 +104,6 @@ vendor:
rm -rf vendor rm -rf vendor
# Extracts vendored dependencies if vendor=1 # Extracts vendored dependencies if vendor=1
_extract_vendor: _vendor-extract:
#!/usr/bin/env sh rm -rf vendor
if test {{vendor}} = 1; then tar pxf vendor.tar
rm -rf vendor
tar pxf vendor.tar
fi