forked from godotengine/godot-build-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·216 lines (184 loc) · 6.5 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
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
#!/bin/bash
set -e
OPTIND=1
# Config
# For default registry and number of cores.
if [ ! -e config.sh ]; then
echo "No config.sh, copying default values from config.sh.in."
cp config.sh.in config.sh
fi
source ./config.sh
if [ -z "${BUILD_NAME}" ]; then
export BUILD_NAME="custom_build"
fi
if [ -z "${NUM_CORES}" ]; then
export NUM_CORES=16
fi
registry="${REGISTRY}"
username=""
password=""
godot_version=""
git_treeish="master"
build_classical=1
build_mono=1
force_download=0
skip_download=1
skip_git_checkout=0
while getopts "h?r:u:p:v:g:b:fsc" opt; do
case "$opt" in
h|\?)
echo "Usage: $0 [OPTIONS...]"
echo
echo " -r registry"
echo " -u username"
echo " -p password"
echo " -v godot version (e.g. 3.1-alpha5) [mandatory]"
echo " -g git treeish (e.g. master)"
echo " -b all|classical|mono (default: all)"
echo " -f force redownload of all images"
echo " -s skip downloading"
echo " -c skip checkout"
echo
exit 1
;;
r)
registry=$OPTARG
;;
u)
username=$OPTARG
;;
p)
password=$OPTARG
;;
v)
godot_version=$OPTARG
;;
g)
git_treeish=$OPTARG
;;
b)
if [ "$OPTARG" == "classical" ]; then
build_mono=0
elif [ "$OPTARG" == "mono" ]; then
build_classical=0
fi
;;
f)
force_download=1
;;
s)
skip_download=1
;;
c)
skip_git_checkout=1
;;
esac
done
export podman=${PODMAN}
if [ $UID != 0 ]; then
echo "WARNING: Running as non-root may cause problems for the uwp build"
fi
if [ -z "${godot_version}" ]; then
echo "-v <version> is mandatory!"
exit 1
fi
IFS=- read version status <<< "$godot_version"
echo "Building Godot ${version} ${status} from commit or branch ${git_treeish}."
read -p "Is this correct (y/n)? " choice
case "$choice" in
y|Y ) echo "yes";;
n|N ) echo "No, aborting."; exit 0;;
* ) echo "Invalid choice, aborting."; exit 1;;
esac
export GODOT_VERSION_STATUS="${status}"
if [ ! -z "${username}" ] && [ ! -z "${password}" ]; then
if ${podman} login ${registry} -u "${username}" -p "${password}"; then
export logged_in=true
fi
fi
if [ $skip_download == 0 ]; then
echo "Fetching images"
for image in windows linux web; do
if [ ${force_download} == 1 ] || ! ${podman} image exists godot/$image; then
if ! ${podman} pull ${registry}/godot/${image}; then
echo "ERROR: image $image does not exist and can't be downloaded"
exit 1
fi
fi
done
if [ ! -z "${logged_in}" ]; then
echo "Fetching private images"
for image in macosx android ios uwp; do
if [ ${force_download} == 1 ] || ! ${podman} image exists godot-private/$image; then
if ! ${podman} pull ${registry}/godot-private/${image}; then
echo "ERROR: image $image does not exist and can't be downloaded"
exit 1
fi
fi
done
fi
fi
# macOS and iOS need the Vulkan SDK
if [ ! -d "deps/vulkansdk-macos" ]; then
echo "Missing Vulkan SDK for macOS, we're going to run into issues!"
fi
# Keystore for Android editor signing
# Optional - the config.sh will be copied but if it's not filled in,
# it will do an unsigned build.
if [ ! -d "deps/keystore" ]; then
mkdir -p deps/keystore
cp config.sh deps/keystore/
if [ ! -z "$GODOT_ANDROID_SIGN_KEYSTORE" ]; then
cp "$GODOT_ANDROID_SIGN_KEYSTORE" deps/keystore/
sed -i deps/keystore/config.sh -e "s@$GODOT_ANDROID_SIGN_KEYSTORE@/root/keystore/$GODOT_ANDROID_SIGN_KEYSTORE@"
fi
fi
if [ "${skip_git_checkout}" == 0 ]; then
git clone https://github.com/godotengine/godot git || /bin/true
pushd git
git checkout -b ${git_treeish} origin/${git_treeish} || git checkout ${git_treeish}
git reset --hard
git clean -fdx
git pull origin ${git_treeish} || /bin/true
# Validate version
correct_version=$(python3 << EOF
import version;
if hasattr(version, "patch") and version.patch != 0:
git_version = f"{version.major}.{version.minor}.{version.patch}"
else:
git_version = f"{version.major}.{version.minor}"
print(git_version == "${version}")
EOF
)
if [[ "$correct_version" != "True" ]]; then
echo "Version in version.py doesn't match the passed ${version}."
exit 1
fi
sh misc/scripts/make_tarball.sh -v ${godot_version} -g ${git_treeish}
popd
fi
export basedir="$(pwd)"
mkdir -p ${basedir}/out
mkdir -p ${basedir}/out/logs
mkdir -p ${basedir}/mono-glue
export podman_run="${podman} run -it --rm --env BUILD_NAME --env GODOT_VERSION_STATUS --env NUM_CORES --env CLASSICAL=${build_classical} --env MONO=${build_mono} -v ${basedir}/godot-${godot_version}.tar.gz:/root/godot.tar.gz -v ${basedir}/mono-glue:/root/mono-glue -w /root/"
export img_version=$IMAGE_VERSION
mkdir -p ${basedir}/mono-glue
${podman_run} -v ${basedir}/build-mono-glue:/root/build localhost/godot-linux:${img_version} bash build/build.sh 2>&1 | tee ${basedir}/out/logs/mono-glue
mkdir -p ${basedir}/out/windows
${podman_run} -v ${basedir}/build-windows:/root/build -v ${basedir}/out/windows:/root/out localhost/godot-windows:${img_version} bash build/build.sh 2>&1 | tee ${basedir}/out/logs/windows
mkdir -p ${basedir}/out/linux
${podman_run} -v ${basedir}/build-linux:/root/build -v ${basedir}/out/linux:/root/out localhost/godot-linux:${img_version} bash build/build.sh 2>&1 | tee ${basedir}/out/logs/linux
mkdir -p ${basedir}/out/web
${podman_run} -v ${basedir}/build-web:/root/build -v ${basedir}/out/web:/root/out localhost/godot-web:${img_version} bash build/build.sh 2>&1 | tee ${basedir}/out/logs/web
mkdir -p ${basedir}/out/macos
${podman_run} -v ${basedir}/build-macos:/root/build -v ${basedir}/out/macos:/root/out -v ${basedir}/deps/vulkansdk-macos:/root/vulkansdk localhost/godot-osx:${img_version} bash build/build.sh 2>&1 | tee ${basedir}/out/logs/macos
mkdir -p ${basedir}/out/android
${podman_run} -v ${basedir}/build-android:/root/build -v ${basedir}/out/android:/root/out -v ${basedir}/deps/keystore:/root/keystore localhost/godot-android:${img_version} bash build/build.sh 2>&1 | tee ${basedir}/out/logs/android
mkdir -p ${basedir}/out/ios
${podman_run} -v ${basedir}/build-ios:/root/build -v ${basedir}/out/ios:/root/out localhost/godot-ios:${img_version} bash build/build.sh 2>&1 | tee ${basedir}/out/logs/ios
#mkdir -p ${basedir}/out/uwp
#${podman_run} --ulimit nofile=32768:32768 -v ${basedir}/build-uwp:/root/build -v ${basedir}/out/uwp:/root/out ${registry}/godot-private/uwp:latest bash build/build.sh 2>&1 | tee ${basedir}/out/logs/uwp
if [ ! -z "$SUDO_UID" ]; then
chown -R "${SUDO_UID}":"${SUDO_GID}" ${basedir}/git ${basedir}/out ${basedir}/mono-glue ${basedir}/godot*.tar.gz
fi