-
Notifications
You must be signed in to change notification settings - Fork 23
/
build.sh
executable file
·91 lines (67 loc) · 1.85 KB
/
build.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
#!/bin/sh
set -ex
# needed for cmake to find some programs
export PATH="/usr/lib/mxe/usr/bin:$PATH"
mkdir build && cd build
mkdir -p /tmp/xmoto
MXE_PATH=/usr/lib/mxe
MXE_TARGET="i686-w64-mingw32.shared"
is_broken_symlink() {
if [ -L "$1" ] && [ ! -e "$1" ]; then
return 0
else
return 1
fi
}
relink() {
for prog in "$@"; do
if is_broken_symlink "$MXE_HOST_PFX-$prog"; then
sudo rm "$MXE_HOST_PFX-$prog"
sudo ln -s "$MXE_CROSS_PFX-$prog" "$MXE_HOST_PFX-$prog"
fi
done
}
MXE_HOST_PFX="$MXE_PATH/usr/x86_64-pc-linux-gnu/bin/$MXE_TARGET"
MXE_CROSS_PFX="$MXE_PATH/usr/bin/$MXE_TARGET"
# add the mxe DLLs to wine's path
export WINEPATH="$MXE_PATH/usr/$MXE_TARGET/bin${WINEPATH:+:${WINEPATH}}"
export WINEARCH=win32
echo "MXE_PATH: $MXE_PATH"
echo "MXE HOST PREFIX: $MXE_HOST_PFX"
echo "MXE CROSS PREFIX: $MXE_CROSS_PFX"
echo "WINEPATH: $WINEPATH"
relink "gcc" "g++"
"$MXE_CROSS_PFX-cmake" \
-DCMAKE_INSTALL_PREFIX=/tmp/xmoto \
-DCMAKE_BUILD_TYPE=Release \
-DXMOTO_PACK=manual ..
make -j"$(nproc)"
Xvfb :0 -screen 0 1024x768x16 &
xvfb_pid=$!
sleep 5
echo "pidof Xvfb:"
pidof Xvfb
make xmoto_pack
# not that any reasonable PID 1 responds to SIGTERM anyway ;)
if [ "$xvfb_pid" -gt 1 ]; then
kill -15 "$xvfb_pid" || true
fi
# aaand if the graceful termination doesn't work..
jobs -p | xargs -r kill -9
#make install
"$MXE_CROSS_PFX"-cpack -G "NSIS"
"$MXE_CROSS_PFX"-cpack -G "ZIP"
fix_pkg_name() {
if [ -z "$1" ] || [ -z "$2" ]; then
>&2 echo "Error: [fix_pkg_name]: 2 parameters required"
fi
file="$1"
ext="${file##*.}"
mv "$file" "${file%.$ext}-$2${ext:+.${ext}}"
}
# add -win32 to .zip files, and -win32-setup to .exe files
for pkg in xmoto-*.zip; do fix_pkg_name "$pkg" "win32"; done
for pkg in xmoto-*.exe; do fix_pkg_name "$pkg" "win32-setup"; done
mkdir artifacts
mv xmoto-*.exe artifacts/
mv xmoto-*.zip artifacts/