forked from rwellinger/BetterPusbackMod
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_release
executable file
·218 lines (196 loc) · 4.86 KB
/
build_release
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
#!/bin/bash
# CDDL HEADER START
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
# CDDL HEADER END
# Copyright 2022 Saso Kiselkov. All rights reserved.
# Some Cleanup's
# Delivery File Name
ZIP_DELIVERY_FILE="BetterPushback_V110.zip"
rm -rf BetterPushback_*.zip
rm -rf win_x64
rm -rf lin_x64
CMAKE_OPTS_COMMON="-DCMAKE_BUILD_TYPE=Release"
DIST_FILES=(
'COPYING' ''
'data/msgs/README.txt' ''
'data/msgs/cc_aliases.cfg' ''
'objects/tugs/LIVERIES_HOWTO.txt' ''
'objects/night_lamp.obj' ''
)
function install_xtra_file() {
FILE="$1"
DSTDIR="$2"
if [[ "$DSTDIR" = "//PNG2DDS//" ]]; then
DSTDIR=""
XFERCMD="convert"
TGTFILE="$(basename "$FILE")"
TGTFILE="${TGTFILE/%.png/.dds}"
else
TGTFILE="$(basename "$FILE")"
XFERCMD="cp"
fi
if [[ "$DSTDIR" = "" ]]; then
DSTDIR="$(dirname "$FILE")"
fi
mkdir -p "BetterPushback/$DSTDIR"
$XFERCMD "$FILE" "BetterPushback/$DSTDIR/$TGTFILE"
}
function install_xtra_files() {
for (( I=0; $I < ${#DIST_FILES[@]}; I=$I + 2 )); do
install_xtra_file "${DIST_FILES[$I]}" "${DIST_FILES[$I + 1]}"
done
}
function install_audio_files() {
FILES=(
'connected.opus'
'disco.opus'
'done_left.opus'
'done_right.opus'
'driving_up.opus'
'op_complete.opus'
'plan_end.opus'
'plan_start.opus'
'ready2conn.opus'
'start_pb.opus'
'start_tow.opus'
'connected.opus'
'disco.opus'
'driving_up.opus'
'op_complete.opus'
'plan_end.opus'
'plan_start.opus'
'ready2conn.opus'
'start_pb.opus'
'start_tow.opus'
'winch.opus'
)
find data/msgs -type f -iname '*.opus' | while read; do
install_xtra_file "$REPLY" ""
done
}
function install_icon_files() {
FILES=(
'accept_plan.png'
'conn_first.png'
'delete_seg.png'
'place_seg.png'
'cancel_plan.png'
'move_view.png'
'rotate_seg.png'
'disconnect.png'
'reconnect.png'
)
for DIR in data/icons/[a-z][a-z]; do
for FILE in ${FILES[@]}; do
install_xtra_file "$DIR/$FILE" ""
done
done
}
function install_tug_files() {
FILES=( $( find objects/tugs/*.tug -type f \
'(' -iname '*.obj' -or -iname '*.cfg' -or -iname '*.wav' -or \
-iname '*.opus' -or -iname '*.png' ')' ) )
for FILE in ${FILES[@]}; do
install_xtra_file "$FILE" ""
done
}
function install_po_files() {
FILES=( $( find data/po -iname '*.po' ) )
for FILE in ${FILES[@]}; do
install_xtra_file "$FILE" ""
done
}
function install_font_files() {
FILES=( $( find data/fonts -iname '*.otf' -or -iname '*.ttf' ) )
for FILE in ${FILES[@]}; do
install_xtra_file "$FILE" ""
done
}
function install_override_files() {
FILES=( $( find objects/override -iname '*.acf' ) )
for FILE in ${FILES[@]}; do
install_xtra_file "$FILE" ""
done
}
while getopts "nh" o; do
case "${o}" in
n)
if [[ $(uname) != "Darwin" ]]; then
echo "Codesigning and notarization can only be done" \
"on macOS" >&2
exit 1
fi
notarize=1
;;
h)
cat << EOF
Usage: $0 [-nh]
-n : (macOS-only) Codesign & notarize the resulting XPL after build
Note: requires that you create a file named user.make in the
notarize directory with DEVELOPER_USERNAME and DEVELOPER_PASSWORD
set. See notarize/notarize.make for more information.
-h : show this help screen and exit.
EOF
exit
;;
*)
echo "Unknown option $o. Try $0 -h for help." >&2
exit 1
;;
esac
done
rm -rf BetterPushback
mkdir -p BetterPushback
set -e
# We'll try to build on N+1 CPUs we have available. The extra +1 is to allow
# for one make instance to be blocking on disk.
HOST_OS="$(uname)"
if [[ "$HOST_OS" = "Darwin" ]]; then
NCPUS=$(( $(sysctl -n hw.ncpu) + 1 ))
else
NCPUS=$(( $(grep 'processor[[:space:]]\+:' /proc/cpuinfo | wc -l) + \
1 ))
fi
case `uname` in
Linux)
( cd src && rm -f CMakeCache.txt && \
cmake $CMAKE_OPTS_COMMON -DCMAKE_TOOLCHAIN_FILE=XCompile.cmake \
-DHOST=x86_64-w64-mingw32 . && make clean && make -j${NCPUS} &&
rm -f libBetterPushback.xpl.dll.a )
( cd src && rm -f CMakeCache.txt && cmake $CMAKE_OPTS_COMMON . \
&& make clean && make -j${NCPUS} )
strip {win_x64,lin_x64}/BetterPushback.xpl
cp -r {win_x64,lin_x64} BetterPushback
;;
Darwin)
( cd src && rm -f CMakeCache.txt && cmake $CMAKE_OPTS_COMMON . \
&& make clean && make -j${NCPUS} )
if [ -n "$notarize" ]; then
make -f notarize/notarize.make notarize
fi
cp -r mac_x64 BetterPushback
;;
*)
echo "Unsupported platform" >&2
exit 1
;;
esac
install_xtra_files
install_po_files
install_audio_files
install_icon_files
install_tug_files
install_override_files
install_font_files
# Build Delivery
zip -r ${ZIP_DELIVERY_FILE} BetterPushback
set +e