mirror of
https://github.com/godotengine/godot-build-scripts.git
synced 2026-01-02 17:48:21 +03:00
165 lines
5.3 KiB
Bash
Executable File
165 lines
5.3 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
OPTIND=1
|
|
|
|
# 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 "${NUM_CORES}" ]; then
|
|
export NUM_CORES=16
|
|
fi
|
|
|
|
registry="${REGISTRY}"
|
|
username=""
|
|
password=""
|
|
godot_version=""
|
|
git_treeish="master"
|
|
force_download=0
|
|
skip_download=0
|
|
skip_git_checkout=0
|
|
|
|
while getopts "h?r:u:p:v:g: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 " -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
|
|
;;
|
|
f) force_download=1
|
|
;;
|
|
s) skip_download=1
|
|
;;
|
|
c) skip_git_checkout=1
|
|
;;
|
|
esac
|
|
done
|
|
|
|
export podman=none
|
|
if which podman > /dev/null; then
|
|
export podman=podman
|
|
elif which docker > /dev/null; then
|
|
export podman=docker
|
|
fi
|
|
|
|
if [ "${podman}" == "none" ]; then
|
|
echo "Either podman or docker needs to be installed"
|
|
exit 1
|
|
fi
|
|
|
|
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
|
|
|
|
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 mono-glue windows ubuntu-64 ubuntu-32 javascript; 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
|
|
|
|
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
|
|
|
|
git archive --format=tar $git_treeish --prefix=godot-${godot_version}/ | gzip > ../godot.tar.gz
|
|
popd
|
|
fi
|
|
|
|
export basedir="$(pwd)"
|
|
mkdir -p ${basedir}/out
|
|
mkdir -p ${basedir}/out/logs
|
|
|
|
export podman_run="${podman} run -it --rm --env NUM_CORES -v ${basedir}/godot.tar.gz:/root/godot.tar.gz -v ${basedir}/mono-glue:/root/mono-glue -w /root/"
|
|
|
|
mkdir -p ${basedir}/mono-glue
|
|
${podman_run} -v ${basedir}/build-mono-glue:/root/build ${registry}/godot/mono-glue:latest 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 ${registry}/godot/windows:latest bash build/build.sh 2>&1 | tee ${basedir}/out/logs/windows
|
|
|
|
mkdir -p ${basedir}/out/linux/x64
|
|
${podman_run} -v ${basedir}/build-linux:/root/build -v ${basedir}/out/linux/x64:/root/out ${registry}/godot/ubuntu-64:latest bash build/build.sh 2>&1 | tee ${basedir}/out/logs/linux64
|
|
|
|
mkdir -p ${basedir}/out/linux/x86
|
|
${podman_run} -v ${basedir}/build-linux:/root/build -v ${basedir}/out/linux/x86:/root/out ${registry}/godot/ubuntu-32:latest bash build/build.sh 2>&1 | tee ${basedir}/out/logs/linux32
|
|
|
|
mkdir -p ${basedir}/out/server/x64
|
|
${podman_run} -v ${basedir}/build-server:/root/build -v ${basedir}/out/server/x64:/root/out ${registry}/godot/ubuntu-64:latest bash build/build.sh 2>&1 | tee ${basedir}/out/logs/server
|
|
|
|
mkdir -p ${basedir}/out/javascript
|
|
${podman_run} -v ${basedir}/build-javascript:/root/build -v ${basedir}/out/javascript:/root/out ${registry}/godot/javascript:latest bash build/build.sh 2>&1 | tee ${basedir}/out/logs/javascript
|
|
|
|
mkdir -p ${basedir}/out/macosx/x64
|
|
${podman_run} -v ${basedir}/build-macosx:/root/build -v ${basedir}/out/macosx/x64:/root/out ${registry}/godot-private/macosx:latest bash build/build.sh 2>&1 | tee ${basedir}/out/logs/macosx
|
|
|
|
mkdir -p ${basedir}/out/android
|
|
${podman_run} -v ${basedir}/build-android:/root/build -v ${basedir}/out/android:/root/out ${registry}/godot-private/android:latest 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 ${registry}/godot-private/ios:latest 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}/out
|
|
fi
|