-
Notifications
You must be signed in to change notification settings - Fork 2
/
build-release.sh
executable file
·148 lines (123 loc) · 3.45 KB
/
build-release.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
#!/bin/bash
RELDIR="release"
EXE_MAIN="minewars_foss"
EXE_EXTRA="mw_certgen mw_datatool"
MYOS="$(uname)"
export CARGO_TARGET_DIR="./target-release"
macos() {
APPNAME="MineWars"
if [ "$MYOS" != "Darwin" ]; then
echo "MacOS builds can only be made on MacOS! Run this script on MacOS!"
exit 1
fi
RELDIR_MAC="${RELDIR}/macos"
mkdir -p "${RELDIR_MAC}/${APPNAME}.app/Contents/MacOS" || exit 2
mkdir -p "${RELDIR_MAC}/${APPNAME}.app/Contents/Resources" || exit 2
cargo build --workspace --target aarch64-apple-darwin --release || exit 2
cargo build --workspace --target x86_64-apple-darwin --release || exit 2
lipo \
"${CARGO_TARGET_DIR}/aarch64-apple-darwin/release/${EXE_MAIN}" \
"${CARGO_TARGET_DIR}/x86_64-apple-darwin/release/${EXE_MAIN}" \
-create -output "${RELDIR_MAC}/${APPNAME}.app/Contents/MacOS/${APPNAME}" || exit 2
for exe in $EXE_EXTRA; do
lipo \
"${CARGO_TARGET_DIR}/aarch64-apple-darwin/release/${exe}" \
"${CARGO_TARGET_DIR}/x86_64-apple-darwin/release/${exe}" \
-create -output "${RELDIR_MAC}/${APPNAME}.app/Contents/MacOS/${exe}" || exit 2
done
cp -R "assets" "${RELDIR_MAC}/${APPNAME}.app/Contents/MacOS/" || exit 2
cp "dist/AppIcon.icns" "${RELDIR_MAC}/${APPNAME}.app/Resources/AppIcon.icns" || exit 2
cp "dist/Info.plist" "${RELDIR_MAC}/${APPNAME}.app/Info.plist" || exit 2
create-dmg \
--volname "${APPNAME}" \
--volicon "dist/AppIcon.icns" \
--background "dist/DMG-background.png" \
--window-size 800 400 \
--icon-size 128 \
--icon "${APPNAME}.app" 200 200 \
--hide-extension "${APPNAME}.app" \
--app-drop-link 600 200 \
"${RELDIR}/${APPNAME}.dmg" \
"${RELDIR_MAC}" || exit 2
}
windows() {
cargo build --workspace --target "${TARGET}" --release || exit 2
for exe in ${EXE_MAIN} ${EXE_EXTRA}; do
cp "${CARGO_TARGET_DIR}/${TARGET}/release/${exe}.exe" "${RELDIR_WIN}/" || exit 2
done
cp -R "assets" "${RELDIR_WIN}/" || exit 2
}
linux() {
if [ "$MYOS" != "Linux" ]; then
echo "Linux builds can only be made on Linux! Run this script on Linux!"
exit 1
fi
cargo build --workspace --target "${TARGET}" --release || exit 2
for exe in ${EXE_MAIN} ${EXE_EXTRA}; do
cp "${CARGO_TARGET_DIR}/${TARGET}/release/${exe}" "${RELDIR_LIN}/" || exit 2
done
cp -R "assets" "${RELDIR_LIN}/" || exit 2
}
win64() {
RELDIR_WIN="${RELDIR}/win64"
TARGET="x86_64-pc-windows-msvc"
windows
}
win32() {
RELDIR_WIN="${RELDIR}/win32"
TARGET="i686-pc-windows-msvc"
windows
}
linux-x86() {
RELDIR_LIN="${RELDIR}/linux-x86"
TARGET="i686-unknown-linux-gnu"
linux
}
linux-x64() {
RELDIR_LIN="${RELDIR}/linux-x64"
TARGET="x86_64-unknown-linux-gnu"
linux
}
linux-arm() {
RELDIR_LIN="${RELDIR}/linux-arm"
TARGET="armv7-unknown-linux-gnueabihf"
linux
}
linux-arm64() {
RELDIR_LIN="${RELDIR}/linux-arm64"
TARGET="aarch64-unknown-linux-gnu"
linux
}
case "${1}" in
mac)
macos
;;
win)
win64
win32
;;
lin)
linux-x64
linux-x86
linux-arm64
linux-arm
;;
win32)
win32
;;
win64)
win64
;;
linux-x86)
linux-x86
;;
linux-x64)
linux-x64
;;
linux-arm)
linux-arm
;;
linux-arm64)
linux-arm64
;;
esac