Repository navigation
Expand file tree
/
Copy pathjustfile
More file actions
102 lines (81 loc) · 2.54 KB
/
Copy pathjustfile
File metadata and controls
102 lines (81 loc) · 2.54 KB
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
APPID := 'dev.heppen.webapps'
PREFIX := env("HOME", "/usr") / ".local"
DATA_DIR := env("XDG_DATA_HOME", PREFIX / "share") / APPID
FLATPAK_MANIFEST := (APPID + '.json')
BASE_DIR := PREFIX
TARGET_DIR := 'target' / 'release'
BIN_SRC := TARGET_DIR / "webapps"
BIN_DST := BASE_DIR / 'bin' / APPID
DESKTOP_SRC := 'resources' / (APPID + '.desktop')
DESKTOP_DST := BASE_DIR / 'share/applications' / (APPID + '.desktop')
METAINFO_SRC := 'resources' / (APPID + '.metainfo.xml')
METAINFO_DST := BASE_DIR / 'share/metainfo' / (APPID + '.metainfo.xml')
ICON_SRC := 'resources/icons/hicolor'
ICON_DST := BASE_DIR / 'share/icons/hicolor'
# Default task
default: build
# Builds the project
build: format check test
cargo build --release
# Build the project with flatpak-builder
build-flatpak:
flatpak-builder --force-clean --user --install-deps-from=flathub --repo=repo --install builddir {{FLATPAK_MANIFEST}}
# Checks the project
check:
cargo check
# Format the project
format:
cargo fmt --all
# Runs tests
test:
cargo test
# Runs the application
run: build
{{BIN_SRC}}
# Build the applications in debug mode
build-debug: format check test
cargo build
# Runs the applications in debug mode
run-dev: build-debug
cargo run
install-data:
mkdir -p {{DATA_DIR}}
cp -rv "data" {{DATA_DIR}}
# Installs files
install: install-data
install -Dm0755 {{BIN_SRC}} {{BIN_DST}}
install -Dm0644 {{DESKTOP_SRC}} {{DESKTOP_DST}}
install -Dm0644 {{METAINFO_SRC}} {{METAINFO_DST}}
for size in `ls {{ICON_SRC}}`; do \
install -Dm0644 "{{ICON_SRC}}/$size/apps/{{APPID}}.png" "{{ICON_DST}}/$size/apps/{{APPID}}.png"; \
done
# Uninstalls files
uninstall:
rm -v {{BIN_DST}}
rm -v {{DESKTOP_DST}}
rm -v {{METAINFO_DST}}
rm -v {{ICON_DST}}/*/apps/{{APPID}}.png
rm -rv {{DATA_DIR}}
# Vendor dependencies locally
vendor:
#!/usr/bin/env bash
mkdir -p .cargo
cargo vendor --sync Cargo.toml | head -n -1 > .cargo/config.toml
echo 'directory = "vendor"' >> .cargo/config.toml
echo >> .cargo/config.toml
echo '[env]' >> .cargo/config.toml
if [ -n "${SOURCE_DATE_EPOCH}" ]
then
source_date="$(date -d "@${SOURCE_DATE_EPOCH}" "+%Y-%m-%d")"
echo "VERGEN_GIT_COMMIT_DATE = \"${source_date}\"" >> .cargo/config.toml
fi
if [ -n "${SOURCE_GIT_HASH}" ]
then
echo "VERGEN_GIT_SHA = \"${SOURCE_GIT_HASH}\"" >> .cargo/config.toml
fi
tar pcf vendor.tar .cargo vendor
rm -rf .cargo vendor
# Extracts vendored dependencies
vendor-extract:
rm -rf vendor
tar pxf vendor.tar