build: streamline justfile & add tag recipe
This commit is contained in:
parent
449411c7e9
commit
79ae68662b
3 changed files with 32 additions and 214 deletions
|
|
@ -1,23 +1,5 @@
|
|||
import "common.just"
|
||||
|
||||
cargo-target-dir := env('CARGO_TARGET_DIR', 'target')
|
||||
|
||||
# Use mold linker if clang and mold exists.
|
||||
clang-path := `which clang || true`
|
||||
mold-path := `which mold || true`
|
||||
|
||||
linker-arg := if clang-path != '' {
|
||||
if mold-path != '' {
|
||||
'-C linker=' + clang-path + ' -C link-arg=--ld-path=' + mold-path + ' '
|
||||
} else {
|
||||
''
|
||||
}
|
||||
} else {
|
||||
''
|
||||
}
|
||||
|
||||
export RUSTFLAGS := linker-arg + env_var_or_default('RUSTFLAGS', '')
|
||||
|
||||
# Compile with debug profile
|
||||
build-debug *args:
|
||||
cargo build {{args}}
|
||||
191
justfile
191
justfile
|
|
@ -1,164 +1,42 @@
|
|||
import 'scripts/cargo.just'
|
||||
|
||||
# Project metadata
|
||||
name := 'cosmic-settings'
|
||||
appid := 'com.system76.CosmicSettings'
|
||||
|
||||
# File paths
|
||||
rootdir := ''
|
||||
prefix := '/usr'
|
||||
|
||||
appdir := clean(rootdir / prefix) / 'share' / 'applications'
|
||||
default-schema-target := clean(rootdir / prefix) / 'share' / 'cosmic'
|
||||
usrdir := clean(rootdir / prefix)
|
||||
appdir := usrdir / 'share' / 'applications'
|
||||
default-schema-target := usrdir / 'share' / 'cosmic'
|
||||
iconsdir := usrdir / 'share' / 'icons' / 'hicolor'
|
||||
|
||||
bin-src := cargo-target-dir / 'release' / name
|
||||
bin-dest := clean(rootdir / prefix) / 'bin' / name
|
||||
|
||||
iconsdir := clean(rootdir / prefix) / 'share' / 'icons' / 'hicolor'
|
||||
|
||||
metainfo := appid + '.metainfo.xml'
|
||||
metainfo-src := 'resources' / metainfo
|
||||
metainfo-dst := clean(rootdir / prefix) / 'share' / 'metainfo' / metainfo
|
||||
|
||||
polkit-actions-src := 'resources' / 'polkit-1' / 'actions'
|
||||
polkit-actions-dst := clean(rootdir / prefix) / 'share' / 'polkit-1' / 'actions'
|
||||
|
||||
policy-users-src := polkit-actions-src / appid + '.Users.policy'
|
||||
# Installation target paths
|
||||
bin-dst := usrdir / 'bin' / name
|
||||
metainfo-dst := usrdir / 'share' / 'metainfo' / appid + '.metainfo.xml'
|
||||
polkit-actions-dst := usrdir / 'share' / 'polkit-1' / 'actions'
|
||||
policy-users-dst := polkit-actions-dst / appid + '.Users.policy'
|
||||
polkit-rules-dst := usrdir / 'share' / 'polkit-1' / 'rules.d' / 'cosmic-settings.rules'
|
||||
|
||||
polkit-rules-src := 'resources' / 'polkit-1' / 'rules.d' / 'cosmic-settings.rules'
|
||||
polkit-rules-dst := clean(rootdir / prefix) / 'share' / 'polkit-1' / 'rules.d' / 'cosmic-settings.rules'
|
||||
|
||||
# Desktop entries
|
||||
entry-settings := appid + '.desktop'
|
||||
entry-about := appid + '.About.desktop'
|
||||
entry-accessibility := appid + '.Accessibility.desktop'
|
||||
entry-appear := appid + '.Appearance.desktop'
|
||||
entry-apps := appid + '.Applications.desktop'
|
||||
entry-bluetooth := appid + '.Bluetooth.desktop'
|
||||
entry-date-time := appid + '.DateTime.desktop'
|
||||
entry-default-apps := appid + '.DefaultApps.desktop'
|
||||
entry-desktop := appid + '.Desktop.desktop'
|
||||
entry-displays := appid + '.Displays.desktop'
|
||||
entry-dock := appid + '.Dock.desktop'
|
||||
entry-firmware := appid + '.Firmware.desktop'
|
||||
entry-input := appid + '.Input.desktop'
|
||||
entry-keyboard := appid + '.Keyboard.desktop'
|
||||
entry-legacy-apps := appid + '.LegacyApplications.desktop'
|
||||
entry-mouse := appid + '.Mouse.desktop'
|
||||
entry-network := appid + '.Network.desktop'
|
||||
entry-notifications := appid + '.Notifications.desktop'
|
||||
entry-panel := appid + '.Panel.desktop'
|
||||
entry-power := appid + '.Power.desktop'
|
||||
entry-region-language := appid + '.RegionLanguage.desktop'
|
||||
entry-sound := appid + '.Sound.desktop'
|
||||
entry-startup-apps := appid + '.StartupApps.desktop'
|
||||
entry-system := appid + '.System.desktop'
|
||||
entry-time := appid + '.Time.desktop'
|
||||
entry-touchpad := appid + '.Touchpad.desktop'
|
||||
entry-users := appid + '.Users.desktop'
|
||||
entry-vpn := appid + '.Vpn.desktop'
|
||||
entry-wallpaper := appid + '.Wallpaper.desktop'
|
||||
entry-window-management := appid + '.WindowManagement.desktop'
|
||||
entry-wired := appid + '.Wired.desktop'
|
||||
entry-wireless := appid + '.Wireless.desktop'
|
||||
entry-workspaces := appid + '.Workspaces.desktop'
|
||||
import 'cargo.just'
|
||||
|
||||
# Build recipes
|
||||
[private]
|
||||
default: build-release
|
||||
|
||||
[private]
|
||||
install-desktop-entries:
|
||||
install -Dm0644 'resources/{{entry-settings}}' '{{appdir}}/{{entry-settings}}'
|
||||
install -Dm0644 'resources/{{entry-about}}' '{{appdir}}/{{entry-about}}'
|
||||
install -Dm0644 'resources/{{entry-accessibility}}' '{{appdir}}/{{entry-accessibility}}'
|
||||
install -Dm0644 'resources/{{entry-appear}}' '{{appdir}}/{{entry-appear}}'
|
||||
install -Dm0644 'resources/{{entry-apps}}' '{{appdir}}/{{entry-apps}}'
|
||||
install -Dm0644 'resources/{{entry-bluetooth}}' '{{appdir}}/{{entry-bluetooth}}'
|
||||
install -Dm0644 'resources/{{entry-date-time}}' '{{appdir}}/{{entry-date-time}}'
|
||||
install -Dm0644 'resources/{{entry-default-apps}}' '{{appdir}}/{{entry-default-apps}}'
|
||||
install -Dm0644 'resources/{{entry-desktop}}' '{{appdir}}/{{entry-desktop}}'
|
||||
install -Dm0644 'resources/{{entry-displays}}' '{{appdir}}/{{entry-displays}}'
|
||||
install -Dm0644 'resources/{{entry-dock}}' '{{appdir}}/{{entry-dock}}'
|
||||
install -Dm0644 'resources/{{entry-firmware}}' '{{appdir}}/{{entry-firmware}}'
|
||||
install -Dm0644 'resources/{{entry-input}}' '{{appdir}}/{{entry-input}}'
|
||||
install -Dm0644 'resources/{{entry-keyboard}}' '{{appdir}}/{{entry-keyboard}}'
|
||||
install -Dm0644 'resources/{{entry-legacy-apps}}' '{{appdir}}/{{entry-legacy-apps}}'
|
||||
install -Dm0644 'resources/{{entry-mouse}}' '{{appdir}}/{{entry-mouse}}'
|
||||
install -Dm0644 'resources/{{entry-network}}' '{{appdir}}/{{entry-network}}'
|
||||
install -Dm0644 'resources/{{entry-notifications}}' '{{appdir}}/{{entry-notifications}}'
|
||||
install -Dm0644 'resources/{{entry-panel}}' '{{appdir}}/{{entry-panel}}'
|
||||
install -Dm0644 'resources/{{entry-power}}' '{{appdir}}/{{entry-power}}'
|
||||
install -Dm0644 'resources/{{entry-region-language}}' '{{appdir}}/{{entry-region-language}}'
|
||||
install -Dm0644 'resources/{{entry-sound}}' '{{appdir}}/{{entry-sound}}'
|
||||
install -Dm0644 'resources/{{entry-startup-apps}}' '{{appdir}}/{{entry-startup-apps}}'
|
||||
install -Dm0644 'resources/{{entry-system}}' '{{appdir}}/{{entry-system}}'
|
||||
install -Dm0644 'resources/{{entry-time}}' '{{appdir}}/{{entry-time}}'
|
||||
install -Dm0644 'resources/{{entry-touchpad}}' '{{appdir}}/{{entry-touchpad}}'
|
||||
install -Dm0644 'resources/{{entry-users}}' '{{appdir}}/{{entry-users}}'
|
||||
install -Dm0644 'resources/{{entry-vpn}}' '{{appdir}}/{{entry-vpn}}'
|
||||
install -Dm0644 'resources/{{entry-wallpaper}}' '{{appdir}}/{{entry-wallpaper}}'
|
||||
install -Dm0644 'resources/{{entry-window-management}}' '{{appdir}}/{{entry-window-management}}'
|
||||
install -Dm0644 'resources/{{entry-wired}}' '{{appdir}}/{{entry-wired}}'
|
||||
install -Dm0644 'resources/{{entry-wireless}}' '{{appdir}}/{{entry-wireless}}'
|
||||
install -Dm0644 'resources/{{entry-workspaces}}' '{{appdir}}/{{entry-workspaces}}'
|
||||
|
||||
# Install everything
|
||||
install: install-desktop-entries (install-bin bin-src bin-dest) (install-file metainfo-src metainfo-dst) install-polkit-files
|
||||
find 'resources'/'default_schema' -type f -exec echo {} \; | rev | cut -d'/' -f-3 | rev | xargs -I {} install -Dm0644 'resources'/'default_schema'/{} {{default-schema-target}}/{}
|
||||
find 'resources'/'icons' -type f -exec echo {} \; | rev | cut -d'/' -f-3 | rev | xargs -I {} install -Dm0644 'resources'/'icons'/{} {{iconsdir}}/{}
|
||||
|
||||
install-polkit-files: (install-file polkit-rules-src polkit-rules-dst) (install-file policy-users-src policy-users-dst)
|
||||
|
||||
[private]
|
||||
install-cmd options src dest:
|
||||
install {{options}} {{src}} {{dest}}
|
||||
|
||||
[private]
|
||||
install-bin src dest: (install-cmd '-Dm0755' src dest)
|
||||
|
||||
[private]
|
||||
install-file src dest: (install-cmd '-Dm0644' src dest)
|
||||
install:
|
||||
install -Dm0644 {{'resources' / appid + '.metainfo.xml'}} {{metainfo-dst}}
|
||||
install -Dm0644 {{'resources' / 'polkit-1' / 'rules.d' / 'cosmic-settings.rules'}} {{polkit-rules-dst}}
|
||||
install -Dm0644 {{'resources' / 'polkit-1' / 'actions' / appid + '.Users.policy'}} {{policy-users-dst}}
|
||||
install -Dm0755 {{cargo-target-dir / 'release' / name}} {{bin-dst}}
|
||||
cd resources && find * -type f -name '*.desktop' -exec install -Dm0644 '{}' '{{appdir}}/{}' \;
|
||||
cd resources/default_schema && find * -type f -exec install -Dm0644 '{}' '{{default-schema-target}}/{}' \;
|
||||
cd resources/icons && find * -type f -exec install -Dm0644 '{}' '{{iconsdir}}/{}' \;
|
||||
|
||||
# Uninstalls everything (requires same arguments as given to install)
|
||||
uninstall:
|
||||
rm -rf {{bin-dest}} \
|
||||
'{{appdir}}/{{entry-settings}}' \
|
||||
'{{appdir}}/{{entry-about}}' \
|
||||
'{{appdir}}/{{entry-accessibility}}' \
|
||||
'{{appdir}}/{{entry-appear}}' \
|
||||
'{{appdir}}/{{entry-apps}}' \
|
||||
'{{appdir}}/{{entry-bluetooth}}' \
|
||||
'{{appdir}}/{{entry-date-time}}' \
|
||||
'{{appdir}}/{{entry-default-apps}}' \
|
||||
'{{appdir}}/{{entry-desktop}}' \
|
||||
'{{appdir}}/{{entry-displays}}' \
|
||||
'{{appdir}}/{{entry-dock}}' \
|
||||
'{{appdir}}/{{entry-firmware}}' \
|
||||
'{{appdir}}/{{entry-input}}' \
|
||||
'{{appdir}}/{{entry-keyboard}}' \
|
||||
'{{appdir}}/{{entry-legacy-apps}}' \
|
||||
'{{appdir}}/{{entry-mouse}}' \
|
||||
'{{appdir}}/{{entry-network}}' \
|
||||
'{{appdir}}/{{entry-notifications}}' \
|
||||
'{{appdir}}/{{entry-panel}}' \
|
||||
'{{appdir}}/{{entry-power}}' \
|
||||
'{{appdir}}/{{entry-region-language}}' \
|
||||
'{{appdir}}/{{entry-sound}}' \
|
||||
'{{appdir}}/{{entry-startup-apps}}' \
|
||||
'{{appdir}}/{{entry-system}}' \
|
||||
'{{appdir}}/{{entry-time}}' \
|
||||
'{{appdir}}/{{entry-touchpad}}' \
|
||||
'{{appdir}}/{{entry-users}}' \
|
||||
'{{appdir}}/{{entry-vpn}}' \
|
||||
'{{appdir}}/{{entry-wallpaper}}' \
|
||||
'{{appdir}}/{{entry-window-management}}' \
|
||||
'{{appdir}}/{{entry-wired}}' \
|
||||
'{{appdir}}/{{entry-wireless}}' \
|
||||
'{{appdir}}/{{entry-workspaces}}'
|
||||
find 'resources'/'default_schema' -type f -exec echo {} \; | rev | cut -d'/' -f-3 | rev | xargs -I {} rm -rf {{default-schema-target}}/{}
|
||||
find 'resources'/'icons' -type f -exec echo {} \; | rev | cut -d'/' -f-3 | rev | xargs -I {} rm {{iconsdir}}/{}
|
||||
rm {{bin-dst}} {{metainfo-dst}} {{polkit-rules-dst}} {{policy-users-dst}}
|
||||
cd resources && find * -type f -name '*.desktop' -exec rm '{{appdir}}/{}' \;
|
||||
cd resources/default_schema && find * -type f -exec rm '{{default-schema-target}}/{}' \;
|
||||
cd resources/icons && find * -type f -exec rm '{{iconsdir}}/{}' \;
|
||||
|
||||
heaptrack *args:
|
||||
#!/usr/bin/env bash
|
||||
|
|
@ -193,18 +71,13 @@ check-features:
|
|||
cargo check --no-default-features --features "${feature}"
|
||||
done
|
||||
|
||||
# Dependencies
|
||||
cmd-depends := "
|
||||
cargo
|
||||
cmake
|
||||
"
|
||||
|
||||
lib-depends := "
|
||||
expat
|
||||
fontconfig
|
||||
freetype2
|
||||
libinput
|
||||
libudev
|
||||
wayland-client=1.20
|
||||
xkbcommon
|
||||
"
|
||||
# Bump cargo version, create git commit, and create tag
|
||||
tag version:
|
||||
find -type f -name Cargo.toml -exec sed -i '0,/^version/s/^version.*/version = "{{version}}"/' '{}' \; -exec git add '{}' \;
|
||||
cargo check
|
||||
cargo clean
|
||||
dch -D noble -v {{version}}
|
||||
git add Cargo.lock debian/changelog
|
||||
git commit -m 'release: {{version}}'
|
||||
git commit --amend
|
||||
git tag -a {{version}} -m ''
|
||||
|
|
|
|||
|
|
@ -1,37 +0,0 @@
|
|||
# Check if required dependencies are installed on the system
|
||||
dep-check:
|
||||
#!/bin/sh
|
||||
echo "{{lib-depends}}" | while read -r lib; do
|
||||
if [ -n "${lib}" ]; then
|
||||
just dep-lib "${lib}" || exit 1
|
||||
fi
|
||||
done
|
||||
echo "{{cmd-depends}}" | while read -r cmd; do
|
||||
if [ -n "${cmd}" ]; then
|
||||
just dep-cmd "${cmd}" || exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
# Errors if a command does not exist
|
||||
[private]
|
||||
dep-cmd cmd:
|
||||
@which {{cmd}} >/dev/null || (just print-error 'missing dependency' 'command' {{cmd}}; exit 1)
|
||||
|
||||
# Errors if a library does not exist
|
||||
[private]
|
||||
dep-lib lib:
|
||||
#!/bin/sh
|
||||
if echo {{lib}} | grep = >/dev/null; then
|
||||
name=$(echo {{lib}} | cut -d= -f1)
|
||||
version=$(echo {{lib}} | cut -d= -f2)
|
||||
pkg-config --exists ${name} --atleast-version ${version} || (
|
||||
has=$(pkg-config --modversion ${name})
|
||||
just print-error "expected version ${version}, found ${has}" 'library' ${name}; exit 1)
|
||||
else
|
||||
pkg-config --exists {{lib}} || (just print-error 'missing dependency' 'library' {{lib}}; exit 1)
|
||||
fi
|
||||
|
||||
# Display a formatted error for the user.
|
||||
[private]
|
||||
print-error msg key value:
|
||||
@echo '\e[0;31mERROR {{msg}}, \e[1;31m{{key}}: \e[0;31m{{value}}\e[0m'
|
||||
Loading…
Add table
Add a link
Reference in a new issue