-
Notifications
You must be signed in to change notification settings - Fork 9
/
build-win64.sh
333 lines (280 loc) · 8.36 KB
/
build-win64.sh
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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
#!/bin/bash
set -eu
PROJ_DIR=$PWD
DIST_DIR=${PROJ_DIR}/windows-installer/win64-dist
BUILD_DIR=$PROJ_DIR/build
JOBS=$NUMBER_OF_PROCESSORS
build_sys='cmake'
msg()
{
echo -e "\e[32m$1\e[0m"
}
fatal()
{
echo -e "\e[31m$1\e[0m"
exit 1
}
download_yolort()
{
file_name=yolort.zip
yolort_dir="$PROJ_DIR/plugins/windows-notification/yolort"
rm -rf "$yolort_dir"
mkdir "$yolort_dir"
curl -L -o "$file_name" "https://github.com/mxlgv/YoloRT/releases/download/dev1/$file_name"
echo "c2727e390da7e842f66e0a4cf0a9f5d9dfb665115bb554152d98f108d322bbc1 $file_name" | sha256sum --check --status
unzip -o "$file_name" -d "$yolort_dir"
rm -f "$file_name"
}
download_gtk4_git()
{
# FIXME: The bug fix https://gitlab.gnome.org/GNOME/gtk/-/issues/3749 is currently only available in the main branch,
# so GTK4 was builded from it. Needs to be replaced with a package from the MSYS2 repository when the changes get there.
url="https://github.com/mxlgv/mingw-w64-gtk4-git/releases/download/rel1"
gtk_pkg="mingw-w64-x86_64-gtk4-git-4.14.1.r62.gb1eed1c153-1-any.pkg.tar.zst"
gtk_gstreamer_pkg="mingw-w64-x86_64-gtk4-media-gstreamer-git-4.14.1.r62.gb1eed1c153-1-any.pkg.tar.zst"
curl -L -o "$gtk_pkg" "$url/$gtk_pkg"
curl -L -o "$gtk_gstreamer_pkg" "$url/$gtk_gstreamer_pkg"
pacman -U --needed --noconfirm "$gtk_pkg" "$gtk_gstreamer_pkg"
}
prepare()
{
msg "Installing MINGW64 build dependencies"
pacman -S --needed --noconfirm \
mingw64/mingw-w64-x86_64-gcc \
mingw64/mingw-w64-x86_64-cmake \
mingw64/mingw-w64-x86_64-ninja \
mingw64/mingw-w64-x86_64-libadwaita \
mingw64/mingw-w64-x86_64-sqlite3 \
mingw64/mingw-w64-x86_64-openssl \
mingw64/mingw-w64-x86_64-libgcrypt \
mingw64/mingw-w64-x86_64-libgee \
mingw64/mingw-w64-x86_64-vala \
mingw64/mingw-w64-x86_64-gsettings-desktop-schemas \
mingw64/mingw-w64-x86_64-qrencode \
mingw64/mingw-w64-x86_64-ntldd-git \
mingw64/mingw-w64-x86_64-gpgme \
mingw64/mingw-w64-x86_64-fontconfig \
mingw64/mingw-w64-x86_64-iso-codes \
mingw64/mingw-w64-x86_64-gstreamer \
mingw64/mingw-w64-x86_64-gst-plugins-bad \
mingw64/mingw-w64-x86_64-gst-plugins-good \
mingw64/mingw-w64-x86_64-gst-plugins-base \
mingw64/mingw-w64-x86_64-gst-plugins-ugly \
mingw64/mingw-w64-x86_64-nsis \
mingw64/mingw-w64-x86_64-libsignal-protocol-c \
mingw64/mingw-w64-x86_64-icu \
mingw64/mingw-w64-x86_64-meson \
git \
make \
unzip \
curl
msg "Downloading and install git versions of gtk4 and gtk4-media-gstreamer packages"
download_gtk4_git
msg "Successfully installed!"
msg "Download YoloRT headers"
download_yolort
msg "Successfully downloaded!"
}
configure_cmake()
{
msg "Running configuration for Windows"
./configure --program-prefix="$DIST_DIR" --no-debug --release --disable-fast-vapi --with-libsoup3 --with-tests
msg "Configured!"
}
build_cmake()
{
msg "Started building on $JOBS threads"
make -j"$JOBS"
msg "Successfully builded!"
msg "Installing Dino .."
make install
}
test_cmake()
{
msg "Run tests"
make test
}
configure_meson()
{
arg=${1:-"none"}
encr=${2:-"auto"}
local cmd=""
if [ x"${arg}" == x"reconfig" ]; then
cmd=--reconfigure
fi
mkdir -p $BUILD_DIR
meson setup ${cmd} --prefix "$DIST_DIR" \
-D crypto-backend=${encr} \
-D plugin-ice=enabled \
$PROJ_DIR $BUILD_DIR
}
build_meson()
{
meson compile -C $BUILD_DIR
meson install -C $BUILD_DIR
}
test_meson()
{
msg "Run tests"
meson test -C $BUILD_DIR
}
dist_install()
{
_dist_arg=${1:-$DIST_DIR}
msg "Generate dino-with-console.exe"
cp -f "$_dist_arg/bin/dino.exe" "$_dist_arg/bin/dino-with-console.exe"
# IMAGE_SUBSYSTEM_WINDOWS_CUI = 0x0003
# SUBSYSTEM_OFFSET = 0xDC (220)
printf '\x03\x00' | dd of="$_dist_arg/bin/dino-with-console.exe" bs=1 seek=220 count=2 conv=notrunc
msg "Copying MINGW64 dependencies"
cp /mingw64/bin/gdbus.exe "$_dist_arg/bin"
cp /mingw64/bin/gspawn-win64-helper.exe "$_dist_arg/bin"
cp /mingw64/bin/libcrypto-*-x64.dll "$_dist_arg/bin/"
cp -r /mingw64/lib/gstreamer-1.0 "$_dist_arg/lib"
mkdir -p "$_dist_arg/lib/gdk-pixbuf-2.0/" && cp -r /mingw64/lib/gdk-pixbuf-2.0 "$_dist_arg/lib/"
mkdir -p "$_dist_arg/lib/gio/" && cp -r /mingw64/lib/gio "$_dist_arg/lib/"
list=`find "$_dist_arg" -type f \( -name "*.exe" -o -name "*.dll" \) -exec \
ntldd -R {} + | \
grep "mingw64" | \
cut -f1 -d "=" | sort | uniq`
for a in $list; do
cp -fv "/mingw64/bin/$a" "$_dist_arg/bin/"
done
msg "Removing debug information from all EXE and DLL files"
find "$_dist_arg" -iname "*.exe" -exec strip -s {} +
find "$_dist_arg" -iname "*.dll" -exec strip -s {} +
find "$_dist_arg" -iname "*.a" -exec rm {} +
msg "Removing redudant header files"
rm -rf "$_dist_arg/include"
msg "Copy LICENSE"
cp -f "$PWD/LICENSE" "$_dist_arg/LICENSE"
msg "Copy icons, themes, locales and fonts"
cp -f "$PWD/main/dino.ico" "$_dist_arg/dino.ico"
cp -rf "/mingw64/share/xml" "$_dist_arg/share"
mkdir -p "$_dist_arg/etc/fonts" && cp -r /mingw64/etc/fonts "$_dist_arg/etc/"
mkdir -p "$_dist_arg/share/icons" && cp -r /mingw64/share/icons "$_dist_arg/share/"
mkdir -p "$_dist_arg/share/glib-2.0/schemas" && cp -rf /mingw64/share/glib-2.0/schemas "$_dist_arg/share/glib-2.0/"
msg "Successfully installed!"
}
build_installer()
{
msg "Building an installer for Windows using NSIS"
cd windows-installer
makensis dino.nsi
msg "Installer successfully builded!"
cd ..
}
clean()
{
rm -rf $BUILD_DIR $DIST_DIR
msg "Build artifacts removed successfull!"
}
help()
{
cat << EOF
Script to build Dino for windows using cmake or meson build-system.
By default it will be build using build directory
$BUILD_DIR
and installed to
$DIST_DIR
Usage: $0 [option]
Note: you may set the multiple options, but be sure that they will be
processed sequentially (one-by-one), e.g. command
$0 -s meson -c -b
will run buld config and _after_ that run build using meson, while
$0 -c -b -s meson
will run cmake-based configure & build commands and the -s option
wont have any effect. And the one
$0 -b -s meson -c
is incorrect, as it willtry to run build(for cmake), then configure
with for meson build.
--help, -h
print this help message.
--set-buildsys, -s
set (specify) build system name to be used
possible options are: cmake or meson
--prepare, -p
install build dependencies. may be done once.
--configure, -c
configure build using selected build-system.
--build, -b
invoke build.
--test, -t
run tests.
--reconfig, -r
reconfigure project, if minor changes were
done to build config files but build has been
configured already (only for meson!).
--whipe, -w
remove build artifacts from $BUILD_DIR
--verbose, -v
verbose output enable.
--dist-install, -i
install the builded project along with its'
dependencies.
--build-installer
build installer (using NSIS)
Running without parameters will run configure, build & install
using cmake-based build-system as default one.
EOF
}
if [[ "$(uname)" != "MINGW64_NT"* ]]; then
fatal "This is not a MINGW64 environment!"
fi
# no options provided,simply build with defaults
if [[ $# == 0 ]]; then
prepare
configure_${build_sys}
build_${build_sys}
dist_install
exit 0
fi
while [[ $# > 0 ]];
do
case $1 in
--prepare|-p)
prepare
;;
--configure|-c)
configure_${build_sys}
;;
--build|-b)
build_${build_sys}
;;
--test|-t)
test_${build_sys}
;;
--reconfig|-r)
configure_${build_sys} reconfig
;;
--whipe|-w)
clean
;;
--dist-install|-i)
dist_install
;;
--verbose|-v)
set -xv
;;
--help|-h)
help
exit 0;
;;
--build-installer)
build_installer
;;
--set-buildsys|-s)
if [ x"$2" != x"cmake" -a x"$2" != x"meson" ]; then
fatal "Improper build system selected: ${2}!"
exit 1;
fi
build_sys=$2
shift
;;
-*)
echo "Unknown option $1"
exit 1
;;
esac
shift
done