-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathjustfile
More file actions
237 lines (211 loc) · 8.96 KB
/
Copy pathjustfile
File metadata and controls
237 lines (211 loc) · 8.96 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
name := 'cosmicding'
appid := 'com.vkhitrin.cosmicding'
rootdir := ''
prefix := '/usr'
base-dir := absolute_path(clean(rootdir / prefix))
bin-src := 'target' / 'release' / name
bin-dst := base-dir / 'bin' / name
desktop := appid + '.desktop'
desktop-dst := clean(rootdir / prefix) / 'share' / 'applications' / desktop
metainfo-dst := clean(rootdir / prefix) / 'share' / 'metainfo' / 'com.vkhitrin.cosmicding.metainfo.xml'
icons-src := 'res' / 'icons' / 'hicolor'
icons-dst := clean(rootdir / prefix) / 'share' / 'icons' / 'hicolor'
macos-assets-dir := 'res' / 'macOS'
macos-release-dir := 'target' / 'release'
macos-app-name := 'Cosmicding' + '.app'
macos-app-template := macos-assets-dir / macos-app-name
macos-app-template-plist := macos-app-template / 'Contents' / 'Info.plist'
macos-app-dir := macos-release-dir / 'macos'
macos-app-binary := macos-release-dir / name
macos-app-binary-dir := macos-app-dir / macos-app-name / 'Contents' / 'MacOS'
macos-app-extras-dir := macos-app-dir / macos-app-name / 'Contents' / 'Resources'
macos-dmg-name := name + '.dmg'
default: build-release
clean:
cargo clean
clean-vendor:
rm -rf .cargo vendor vendor.tar
clean-dist: clean clean-vendor
build-debug *args:
cargo build {{ args }}
build-release *args:
#!/usr/bin/env sh
if [ "$(uname)" = "Linux" ]; then
just build-release-linux {{ args }}
elif [ "$(uname)" = "Darwin" ]; then
export HOMEBREW_PREFIX="$(brew --prefix)"
export PKG_CONFIG_PATH="${HOMEBREW_PREFIX}/lib/pkgconfig"
export LIBRARY_PATH="${HOMEBREW_PREFIX}/lib"
export C_INCLUDE_PATH="${HOMEBREW_PREFIX}/include"
if [ "$(uname -m)" = "arm64" ]; then
just build-release-macos-aarch64
elif [ "$(uname -m)" = "x86_64" ]; then
just build-release-macos-x86_64
fi
fi
build-release-linux *args: (build-debug '--release' args)
build-release-macos-aarch64 *args:
#!/usr/bin/env sh
if [ ! -z ${COSMICDING_UNIVERSAL_BUILD} ]; then
SDKROOT="$(xcrun --sdk macosx --show-sdk-path)"
CFLAGS="-isysroot ${SDKROOT}"
rustup run stable cargo build --release --target aarch64-apple-darwin {{ args }}
else
cargo build --release --target=aarch64-apple-darwin {{ args }}
lipo "target/aarch64-apple-darwin/release/{{ name }}" -create -output "{{ macos-app-binary }}"
just bundle-macos
fi
build-release-macos-x86_64 *args:
#!/usr/bin/env sh
if [ ! -z ${COSMICDING_UNIVERSAL_BUILD} ]; then
SDKROOT="$(xcrun --sdk macosx --show-sdk-path)"
CFLAGS="-isysroot ${SDKROOT}"
rustup run stable cargo build --release --target x86_64-apple-darwin {{ args }}
else
cargo build --release --target x86_64-apple-darwin {{ args }}
lipo "target/x86_64-apple-darwin/release/{{ name }}" -create -output "{{ macos-app-binary }}"
just bundle-macos
fi
build-release-macos-universal:
which rustup || exit 1
rustup toolchain install stable
rustup target add aarch64-apple-darwin
rustup target add x86_64-apple-darwin
env COSMICDING_UNIVERSAL_BUILD=true just build-release-macos-aarch64
env COSMICDING_UNIVERSAL_BUILD=true just build-release-macos-x86_64
lipo "target/aarch64-apple-darwin/release/{{ name }}" "target/x86_64-apple-darwin/release/{{ name }}" -create -output "{{ macos-app-binary }}"
just bundle-macos
build-release-linux-multi-arch *args:
#!/usr/bin/env sh
which cross || exit 1
just build-release-linux {{ args }}
if [ "$(uname -m)" = "arm64" ]; then
cross build --target x86_64-unknown-linux-gnu --release
elif [ "$(uname -m)" = "x86_64" ]; then
cross build --target aarch64-unknown-linux-gnu --release
fi
just bundle-linux
bundle-macos:
# Using native macOS' sed
/usr/bin/sed -i '' -e "s/__VERSION__/$(cargo pkgid | cut -d "#" -f2)/g" {{ macos-app-template-plist }}
/usr/bin/sed -i '' -e "s/__BUILD__/$(git describe --always --exclude='*')/g" {{ macos-app-template-plist }}
mkdir -p "{{ macos-app-binary-dir }}"
mkdir -p "{{ macos-app-extras-dir }}/icons/hicolor"
cp -fRp "{{ macos-app-template }}" "{{ macos-app-dir }}"
cp -fp "{{ macos-app-binary }}" "{{ macos-app-binary-dir }}"
cp -r ./res/icons/hicolor/* "{{ macos-app-extras-dir }}/icons/hicolor"
touch -r "{{ macos-app-binary }}" "{{ macos-app-dir }}/{{ macos-app-name }}"
echo "Created '{{ macos-app-name }}' in '{{ macos-app-dir }}'"
git stash -- {{ macos-app-template-plist }}
bundle-linux:
rm -rf cosmicding; mkdir -p cosmicding cosmicding/desktop
cp -r res/icons cosmicding/
cp res/icons/favicon_placeholder.png cosmicding/icons/favicon_placeholder.png
cp res/icons/linkding-logo.svg cosmicding/icons/linkding-logo.svg
cp res/linux/app.desktop cosmicding/desktop/{{desktop}}
distribute-macos-dmg:
which create-dmg || exit 1
create-dmg \
--volname "Cosmicding Installer" \
--window-pos 200 120 \
--window-size 800 400 \
--icon-size 100 \
--hide-extension "Cosmicding.app" \
--icon {{ macos-app-name }} 200 160 \
--app-drop-link 600 155 \
{{ macos-app-dir }}/{{ macos-dmg-name }} \
{{ macos-app-dir }}/{{ macos-app-name }}
distribute-linux-archives:
#!/usr/bin/env sh
COSMICDING_VERSION="v$(cargo metadata --no-deps --format-version=1 | jq -r '.packages[0].version')"
COSMICDING_X86_64_ARCHIVE="cosmicding-${COSMICDING_VERSION}-x86_64-unknown-linux-gnu.tar.gz"
COSMICDING_ARM64_ARCHIVE="cosmicding-${COSMICDING_VERSION}-aarch64-unknown-linux-gnu.tar.gz"
tar --gzip -c cosmicding --file "${COSMICDING_X86_64_ARCHIVE}"
tar --gzip -c cosmicding --file "${COSMICDING_ARM64_ARCHIVE}"
if [ "$(uname -m)" = "arm64" ]; then
tar --gzip -c target/release/cosmicding --file "${COSMICDING_ARM64_ARCHIVE}" cosmicding/
tar --gzip -c target/x86-64-unknown-linux-gnu/release/cosmicding --file "${COSMICDING_X86_64_ARCHIVE}" cosmicding/
elif [ "$(uname -m)" = "x86_64" ]; then
tar --gzip -c target/release/cosmicding -f "${COSMICDING_X86_64_ARCHIVE}" cosmicding/
tar --gzip -c target/aarch64-unknown-linux-gnu/release/cosmicding --file "${COSMICDING_ARM64_ARCHIVE}" cosmicding/
fi
build-release-linux-flatpak:
which flatpak-builder || exit 1
flatpak-builder --force-clean \
--sandbox \
--user \
--install \
--install-deps-from=flathub \
--ccache \
--mirror-screenshots-url=https://dl.flathub.org/media/ \
--repo=flatpak-repo builddir \
res/flatpak/com.vkhitrin.cosmicding.yaml
build-vendored *args: vendor-extract (build-release '--frozen --offline' args)
check *args:
cargo clippy --all-features {{ args }} -- -W clippy::pedantic
check-json: (check '--message-format=json')
run-linux *args:
env RUST_BACKTRACE=full cargo run --release {{ args }}
run-macos:
just build-release
env RUST_BACKTRACE=full {{ macos-app-binary-dir }}/{{ name }}
run *args:
#!/usr/bin/env sh
if [ "$(uname)" = "Linux" ]; then
just run-linux {{ args }}
elif [ "$(uname)" = "Darwin" ]; then
just run-macos {{ args }}
fi
install:
#!/usr/bin/env sh
if [ "$(uname)" = "Linux" ]; then
install -Dm0755 {{ bin-src }} {{ bin-dst }}
find {{ icons-src }} -type f -path "*/apps/*.svg" -exec bash -c '
for src; do
rel_path="${src#{{ icons-src }}/}"
dst="{{ icons-dst }}/$rel_path"
install -Dm0644 "$src" "$dst"
done
' bash {} +
install -Dm0644 res/linux/app.desktop {{ desktop-dst }}
install -Dm0644 res/flatpak/com.vkhitrin.cosmicding.metainfo.xml {{ metainfo-dst }}
elif [ "$(uname)" = "Darwin" ]; then
cp -r {{ macos-app-dir }}/{{ name }}.app /Applications/
fi
uninstall:
#!/usr/bin/env sh
if [ "$(uname)" = "Linux" ]; then
rm {{ bin-dst }} {{ desktop-dst }}
find {{ icons-src }} -type f -path "*/apps/*.svg" -exec bash -c '
for src; do
rel_path="${src#{{ icons-src }}/}"
dst="{{ icons-dst }}/$rel_path"
if [ -f "$dst" ]; then
rm "$dst"
fi
done
' bash {} +
elif [ "$(uname)" = "Darwin" ]; then
rm -rf /Applications/{{ name }}.app
fi
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
vendor-extract:
rm -rf vendor
tar pxf vendor.tar