-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
justfile
111 lines (86 loc) · 3.63 KB
/
justfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
release := 'false'
appid := if release == 'true' { 'de.leopoldluley.Clapgrep' } else { 'de.leopoldluley.Clapgrep.Devel' }
bin-target := if release == 'true' { 'release' } else { 'debug' }
release-flag := if release == 'true' { '--release' } else { '' }
export APP_ID := appid
rootdir := ''
prefix := '/usr'
base-dir := absolute_path(clean(rootdir / prefix))
bin-src := 'target' / bin-target / 'clapgrep-gnome'
bin-dst := base-dir / 'bin' / 'clapgrep'
desktop := appid + '.desktop'
desktop-src := 'assets' / desktop
desktop-dst := base-dir / 'share' / 'applications' / desktop
metainfo := 'de.leopoldluley.Clapgrep.metainfo.xml'
metainfo-src := 'assets' / metainfo
metainfo-dst := base-dir / 'share' / 'metainfo' / metainfo
icons-src := 'assets' / 'icons' / 'hicolor'
icons-dst := base-dir / 'share' / 'icons' / 'hicolor'
icon-svg-src := icons-src / 'scalable' / 'apps' / appid + '.svg'
icon-svg-dst := icons-dst / 'scalable' / 'apps' / appid + '.svg'
po-src := 'assets' / 'locale'
po-dst := base-dir / 'share' / 'locale'
default:
just --list
clean:
cargo clean
build *args: build-translations
cargo build --package clapgrep-gnome {{args}} {{release-flag}}
check *args: build
cargo clippy --all-features {{args}}
run *args: build
env RUST_BACKTRACE=full cargo run --package clapgrep-gnome {{args}}
ci: setup-flatpak-repos
echo "skip:" > build-aux/Makefile
flatpak-builder --keep-build-dirs --disable-updates --build-only --ccache --force-clean flatpak build-aux/{{appid}}.json
echo Check formatting:
./build-aux/fun.sh cargo fmt --all -- --check --verbose
echo Check code:
./build-aux/fun.sh cargo check
echo Check code with Clippy:
./build-aux/fun.sh cargo clippy --workspace --all-targets --all-features -- -D warnings
install: build
mkdir -p {{po-dst}}
install -Dm0755 {{bin-src}} {{bin-dst}}
install -Dm0755 {{desktop-src}} {{desktop-dst}}
install -Dm0755 {{metainfo-src}} {{metainfo-dst}}
install -Dm0755 {{icon-svg-src}} {{icon-svg-dst}}
cp -r {{po-src}} {{po-dst}}
make-makefile target='build-aux/Makefile':
echo "# This file was generated by 'just make-makefile'" > {{target}}
echo ".PHONY: install" >> {{target}}
echo "install:" >> {{target}}
just -n release={{release}} prefix=/app install 2>&1 | sed 's/^/\t/' | sed 's/\$/$$/g' >> {{target}}
make-cargo-sources:
python3 build-aux/flatpak-cargo-generator.py ./Cargo.lock -o build-aux/cargo-sources.json
install-flatpak: setup-flatpak-repos make-makefile
flatpak-builder flatpak-build build-aux/{{appid}}.json --force-clean --install --user
setup-flatpak-repos:
flatpak remote-add --user --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
flatpak install --or-update --user --noninteractive flathub org.gnome.Platform//47 org.gnome.Sdk//47 org.freedesktop.Sdk.Extension.rust-stable//24.08
gettext *args:
xgettext \
--from-code=UTF-8 \
--add-comments \
--keyword=_ \
--keyword=C_:1c,2 \
--language=C \
--output=po/messages.pot \
--files-from=po/POTFILES \
{{args}}
cat po/LINGUAS | while read lang; do \
msgmerge -N -U po/$lang.po po/messages.pot; \
rm -f po/$lang.po~; \
done
add-translation language:
msginit -l {{language}}.UTF8 -o po/{{language}}.po -i po/messages.pot
build-translations:
cat po/LINGUAS | while read lang; do \
mkdir -p assets/locale/$lang/LC_MESSAGES; \
msgfmt -o assets/locale/$lang/LC_MESSAGES/{{appid}}.mo po/$lang.po; \
done
prepare-release:
just make-cargo-sources
just release=true make-makefile makefile
flatpak-builder --force-clean --repo=repo flatpak build-aux/de.leopoldluley.Clapgrep.json
flatpak run --command=flatpak-builder-lint org.flatpak.Builder repo repo