forked from godotengine/build-containers
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sh
executable file
·152 lines (134 loc) · 6.3 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
#!/bin/bash
set -e
podman=`which podman || true`
if [ -z $podman ]; then
echo "podman needs to be in PATH for this script to work."
exit 1
fi
if ! grep -rq '/usr/bin/wine' /proc/sys/fs/binfmt_misc; then
echo "binfmt_misc support for PE pointing to /usr/bin/wine must be enabled to build the Windows mono container."
echo "This can be done by:"
echo 'mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc'
echo 'echo ":windows:M::MZ::/usr/bin/wine:" > /proc/sys/fs/binfmt_misc/register'
echo 'echo ":windowsPE:M::PE::/usr/bin/wine:" > /proc/sys/fs/binfmt_misc/register'
exit 1
fi
if [ -z "$1" -o -z "$2" ]; then
echo "Usage: $0 <godot branch> <mono version> [<mono branch> <mono commit hash>]"
echo
echo "Examples: $0 3.x mono-6.12.0.122"
echo " $0 master mono-6.6.0.160 2019-08 bef1e6335812d32f8eab648c0228fc624b9f8357"
echo
echo "godot branch:"
echo "mono version:"
echo " These are combined to form the docker image tag, e.g. 'master-mono-6.6.0.160'."
echo " Git will then clone the branch/tag that matches the mono version."
echo
echo "mono branch:"
echo " If specified, git will clone this mono branch/tag instead. Requires specifying a commit."
echo
echo "mono commit:"
echo " If specified, git will check out this commit after cloning."
echo
exit 1
fi
godot_branch=$1
mono_version=$2
img_version=$godot_branch-$mono_version
files_root=$(pwd)/files
mono_commit=
mono_commit_str=
# If optional Mono git branch and commit hash were passed, use them.
if [ ! -z "$3" -a ! -z "$4" ]; then
mono_version=$3
mono_commit=$4
mono_commit_str="-${mono_commit:0:7}"
fi
# If mono branch does not start with mono-, prepend it to the folder name.
if [ ${mono_version:0:5} != "mono-" ]; then
mono_root="${files_root}/mono-${mono_version}${mono_commit_str}"
else
mono_root="${files_root}/${mono_version}${mono_commit_str}"
fi
# Confirm settings
echo "Docker image tag: ${img_version}"
echo "Mono branch: ${mono_version}"
if [ ! -z "$mono_commit" ]; then
echo "Mono commit: ${mono_commit}"
fi
if [ -e ${mono_root} ]; then
mono_exists="(exists)"
fi
echo "Mono source folder: ${mono_root} ${mono_exists}"
echo
while true; do
read -p "Is this correct? [y/n] " yn
case $yn in
[Yy]* ) break;;
[Nn]* ) exit 1;;
* ) echo "Please answer yes or no.";;
esac
done
mkdir -p logs
# Check out and patch Mono version
if [ ! -e ${mono_root} ]; then
if [ ! -z "${mono_commit}" ]; then
# If a commit is specified, get the full history
git clone -b ${mono_version} --single-branch --progress https://github.com/mono/mono ${mono_root}
pushd ${mono_root}
git checkout ${mono_commit}
else
# Otherwise, get a shallow repo
git clone -b ${mono_version} --single-branch --progress --depth 1 https://github.com/mono/mono ${mono_root}
pushd ${mono_root}
fi
# Download all submodules, up to 6 at a time
git submodule update --init --recursive --recommend-shallow -j 6 --progress
# Set up godot-mono-builds in tree
git clone --progress https://github.com/godotengine/godot-mono-builds
pushd godot-mono-builds
git checkout df330ce0bec35836a33b97db27c1e72014571103
export MONO_SOURCE_ROOT=${mono_root}
python3 patch_mono.py
popd
popd
fi
# You can add --no-cache as an option to podman_build below to rebuild all containers from scratch
export podman_build="$podman build --build-arg img_version=${img_version}"
export podman_build_mono="$podman_build --build-arg mono_version=${mono_version} -v ${files_root}:/root/files"
$podman build -v ${files_root}:/root/files -t godot-fedora:${img_version} -f Dockerfile.base . 2>&1 | tee logs/base.log
$podman_build -t godot-export:${img_version} -f Dockerfile.export . 2>&1 | tee logs/export.log
$podman_build_mono -t godot-mono:${img_version} -f Dockerfile.mono . 2>&1 | tee logs/mono.log
$podman_build_mono -t godot-mono-glue:${img_version} -f Dockerfile.mono-glue . 2>&1 | tee logs/mono-glue.log
# The ulimit below is necessary to use Wine to workaround Mono cross-compilation bugs (see GH-32).
$podman_build_mono -t godot-windows:${img_version} -f Dockerfile.windows --ulimit nofile=65536 . 2>&1 | tee logs/windows.log
$podman_build_mono -t godot-ubuntu-64:${img_version} -f Dockerfile.ubuntu-64 . 2>&1 | tee logs/ubuntu-64.log
$podman_build_mono -t godot-ubuntu-32:${img_version} -f Dockerfile.ubuntu-32 . 2>&1 | tee logs/ubuntu-32.log
$podman_build_mono -t godot-javascript:${img_version} -f Dockerfile.javascript . 2>&1 | tee logs/javascript.log
$podman_build_mono -t godot-android:${img_version} -f Dockerfile.android . 2>&1 | tee logs/android.log
XCODE_SDK=12.4
OSX_SDK=11.1
IOS_SDK=14.4
if [ ! -e files/MacOSX${OSX_SDK}.sdk.tar.xz ] || [ ! -e files/iPhoneOS${IOS_SDK}.sdk.tar.xz ] || [ ! -e files/iPhoneSimulator${IOS_SDK}.sdk.tar.xz ]; then
if [ ! -e files/Xcode_${XCODE_SDK}.xip ]; then
echo "files/Xcode_${XCODE_SDK}.xip is required. It can be downloaded from https://developer.apple.com/download/more/ with a valid apple ID."
exit 1
fi
echo "Building OSX and iOS SDK packages. This will take a while"
$podman_build -t godot-xcode-packer:${img_version} -f Dockerfile.xcode -v ${files_root}:/root/files . 2>&1 | tee logs/xcode.log
$podman run -it --rm -v ${files_root}:/root/files godot-xcode-packer:${img_version} 2>&1 | tee logs/xcode_packer.log
fi
$podman_build_mono -t godot-osx:${img_version} -f Dockerfile.osx . 2>&1 | tee logs/osx.log
$podman_build_mono -t godot-ios:${img_version} -f Dockerfile.ios . 2>&1 | tee logs/ios.log
if [ ! -e files/msvc2017.tar ]; then
echo
echo "files/msvc2017.tar is missing. This file can be created on a Windows 7 or 10 machine by downloading the 'Visual Studio Tools' installer."
echo "here: https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2017"
echo "The required components can be installed by running"
echo "vs_buildtools.exe --add Microsoft.VisualStudio.Workload.UniversalBuildTools --add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Component.Windows10SDK.16299.Desktop --add Microsoft.VisualStudio.Component.Windows10SDK.16299.UWP.Native --passive"
echo "after that create a zipfile of C:/Program Files (x86)/Microsoft Visual Studio"
echo "tar -cf msvc2017.tar -C \"c:/Program Files (x86)/ Microsoft Visual Studio\""
echo
exit 1
fi
$podman_build -t godot-msvc:${img_version} -f Dockerfile.msvc -v ${files_root}:/root/files . 2>&1 | tee logs/msvc.log