Skip to content

Commit 0723681

Browse files
committed
tvOS classical build support
1 parent aaa066f commit 0723681

File tree

6 files changed

+482
-4
lines changed

6 files changed

+482
-4
lines changed

Dockerfile.tvos

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
ARG img_version
2+
FROM godot-osx:${img_version}
3+
4+
ARG mono_version
5+
6+
ENV TVOS_SDK=14.2
7+
8+
RUN dnf -y install --setopt=install_weak_deps=False \
9+
automake autoconf clang gcc gcc-c++ gcc-objc gcc-objc++ cmake libicu-devel libtool libxml2-devel llvm-devel openssl-devel perl python yasm
10+
11+
RUN git clone --progress https://github.com/tpoechtrager/cctools-port.git && \
12+
cd /root/cctools-port && \
13+
git checkout 634a084377ee2e2932c66459b0396edf76da2e9f && \
14+
yes | cp -rf /root/files/tvos_toolchain/tvos_example.sh usage_examples/ios_toolchain/build.sh && \
15+
yes | cp -rf /root/files/tvos_toolchain/tvos_wrapper.c usage_examples/ios_toolchain/wrapper.c && \
16+
chmod +x usage_examples/ios_toolchain/build.sh
17+
18+
RUN cd /root/cctools-port && \
19+
usage_examples/ios_toolchain/build.sh /root/files/AppleTVOS${TVOS_SDK}.sdk.tar.xz arm64 && \
20+
mkdir -p /root/ioscross/arm64 && \
21+
mv usage_examples/ios_toolchain/target/* /root/ioscross/arm64 && \
22+
mkdir /root/ioscross/arm64/usr && \
23+
ln -s /root/ioscross/arm64/bin /root/ioscross/arm64/usr/bin
24+
25+
RUN cd /root/cctools-port && \
26+
sed -i 's#AppleTVOS#AppleTVSimulator#' usage_examples/ios_toolchain/build.sh && \
27+
sed -i 's#-mappletvos-version-min=#-mappletvsimulator-version-min=#' usage_examples/ios_toolchain/wrapper.c && \
28+
sed -i 's#^TRIPLE=.*#TRIPLE="x86_64-apple-darwin11"#' usage_examples/ios_toolchain/build.sh && \
29+
usage_examples/ios_toolchain/build.sh /root/files/AppleTVSimulator${TVOS_SDK}.sdk.tar.xz x86_64 && \
30+
mkdir -p /root/ioscross/x86_64 && \
31+
mv usage_examples/ios_toolchain/target/* /root/ioscross/x86_64 && \
32+
mkdir /root/ioscross/x86_64/usr && \
33+
ln -s /root/ioscross/x86_64/bin /root/ioscross/x86_64/usr/bin
34+
35+
ENV OSXCROSS_TVOS=not_nothing
36+
ENV TVOSCROSS_ROOT=/root/ioscross
37+
ENV PATH="/root/ioscross/arm64/bin:/root/ioscross/x86_64/bin:${PATH}"
38+
39+
CMD /bin/bash

Dockerfile.xcode

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ RUN dnf -y install --setopt=install_weak_deps=False \
1515
clang -O3 -llzma -lxar -I /usr/local/include pbzx.c -o pbzx
1616

1717
CMD mkdir -p /root/xcode && \
18+
# macOS
1819
cd /root/xcode && \
1920
xar -xf /root/files/Xcode_12.2.xip && \
2021
/root/pbzx/pbzx -n Content | cpio -i && \
@@ -29,19 +30,39 @@ CMD mkdir -p /root/xcode && \
2930
cd /tmp && \
3031
tar -cJf /root/files/${OSX_SDK}.tar.xz ${OSX_SDK} && \
3132
rm -rf ${OSX_SDK} && \
33+
# iOS
3234
cd /root/xcode && \
3335
export IOS_SDK=iPhoneOS14.2.sdk && \
34-
export IOS_SIMULATOR_SDK=iPhoneSimulator14.2.sdk && \
3536
cp -r Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk /tmp/${IOS_SDK} && \
3637
mkdir -p /tmp/${IOS_SDK}/usr/include/c++ && \
3738
cp -r Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1 /tmp/${IOS_SDK}/usr/include/c++/ && \
3839
cd /tmp && \
3940
tar -cJf /root/files/${IOS_SDK}.tar.xz ${IOS_SDK} && \
4041
rm -rf ${IOS_SDK} && \
42+
# iOS Simulator
4143
cd /root/xcode && \
44+
export IOS_SIMULATOR_SDK=iPhoneSimulator14.2.sdk && \
4245
cp -r Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk /tmp/${IOS_SDK} && \
4346
mkdir -p /tmp/${IOS_SDK}/usr/include/c++ && \
4447
cp -r Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1 /tmp/${IOS_SDK}/usr/include/c++/ && \
4548
cd /tmp && \
4649
tar -cJf /root/files/${IOS_SIMULATOR_SDK}.tar.xz ${IOS_SDK} && \
47-
rm -rf ${IOS_SDK}
50+
rm -rf ${IOS_SDK} && \
51+
# tvOS
52+
cd /root/xcode && \
53+
export TVOS_SDK=AppleTVOS14.2.sdk && \
54+
cp -r Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk /tmp/${TVOS_SDK} && \
55+
mkdir -p /tmp/${TVOS_SDK}/usr/include/c++ && \
56+
cp -r Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1 /tmp/${TVOS_SDK}/usr/include/c++/ && \
57+
cd /tmp && \
58+
tar -cJf /root/files/${TVOS_SDK}.tar.xz ${TVOS_SDK} && \
59+
rm -rf ${TVOS_SDK} && \
60+
# tvOS Simulator
61+
cd /root/xcode && \
62+
export TVOS_SIMULATOR_SDK=AppleTVSimulator14.2.sdk && \
63+
cp -r Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator.sdk /tmp/${TVOS_SIMULATOR_SDK} && \
64+
mkdir -p /tmp/${TVOS_SIMULATOR_SDK}/usr/include/c++ && \
65+
cp -r Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1 /tmp/${TVOS_SIMULATOR_SDK}/usr/include/c++/ && \
66+
cd /tmp && \
67+
tar -cJf /root/files/${TVOS_SIMULATOR_SDK}.tar.xz ${TVOS_SIMULATOR_SDK} && \
68+
rm -rf ${TVOS_SIMULATOR_SDK}

build.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,19 +122,21 @@ $podman_build_mono -t godot-android:${img_version} -f Dockerfile.android . 2>&1
122122
XCODE_SDK=12.2
123123
OSX_SDK=11.0
124124
IOS_SDK=14.2
125-
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
125+
TVOS_SDK=14.2
126+
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 ] || [ ! -e files/AppleTVOS${TVOS_SDK}.sdk.tar.xz ] || [ ! -e files/AppleTVSimulator${TVOS_SDK}.sdk.tar.xz ]; then
126127
if [ ! -e files/Xcode_${XCODE_SDK}.xip ]; then
127128
echo "files/Xcode_${XCODE_SDK}.xip is required. It can be downloaded from https://developer.apple.com/download/more/ with a valid apple ID."
128129
exit 1
129130
fi
130131

131-
echo "Building OSX and iOS SDK packages. This will take a while"
132+
echo "Building OSX, iOS and tvOS SDK packages. This will take a while"
132133
$podman_build -t godot-xcode-packer:${img_version} -f Dockerfile.xcode -v ${files_root}:/root/files . 2>&1 | tee logs/xcode.log
133134
$podman run -it --rm -v ${files_root}:/root/files godot-xcode-packer:${img_version} 2>&1 | tee logs/xcode_packer.log
134135
fi
135136

136137
$podman_build_mono -t godot-osx:${img_version} -f Dockerfile.osx . 2>&1 | tee logs/osx.log
137138
$podman_build_mono -t godot-ios:${img_version} -f Dockerfile.ios . 2>&1 | tee logs/ios.log
139+
$podman_build_mono -t godot-tvos:${img_version} -f Dockerfile.tvos . 2>&1 | tee logs/tvos.log
138140

139141
if [ ! -e files/msvc2017.tar ]; then
140142
echo

files/tvos_toolchain/tvos_example.sh

Lines changed: 220 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,220 @@
1+
#!/usr/bin/env bash
2+
3+
export LC_ALL=C
4+
pushd "${0%/*}" &>/dev/null
5+
6+
PLATFORM=$(uname -s)
7+
OPERATING_SYSTEM=$(uname -o || echo "-")
8+
9+
if [ $OPERATING_SYSTEM == "Android" ]; then
10+
export CC="clang -D__ANDROID_API__=26"
11+
export CXX="clang++ -D__ANDROID_API__=26"
12+
fi
13+
14+
if [ -z "$LLVM_DSYMUTIL" ]; then
15+
LLVM_DSYMUTIL=llvm-dsymutil
16+
fi
17+
18+
if [ -z "$JOBS" ]; then
19+
JOBS=$(nproc 2>/dev/null || ncpus 2>/dev/null || echo 1)
20+
fi
21+
22+
set -e
23+
24+
function verbose_cmd
25+
{
26+
echo "$@"
27+
eval "$@"
28+
}
29+
30+
function extract()
31+
{
32+
echo "extracting $(basename $1) ..."
33+
local tarflags="xf"
34+
35+
case $1 in
36+
*.tar.xz)
37+
xz -dc $1 | tar $tarflags -
38+
;;
39+
*.tar.gz)
40+
gunzip -dc $1 | tar $tarflags -
41+
;;
42+
*.tar.bz2)
43+
bzip2 -dc $1 | tar $tarflags -
44+
;;
45+
*)
46+
echo "unhandled archive type" 1>&2
47+
exit 1
48+
;;
49+
esac
50+
}
51+
52+
function git_clone_repository
53+
{
54+
local url=$1
55+
local branch=$2
56+
local directory
57+
58+
directory=$(basename $url)
59+
directory=${directory/\.git/}
60+
61+
if [ -n "$CCTOOLS_IOS_DEV" ]; then
62+
rm -rf $directory
63+
cp -r $CCTOOLS_IOS_DEV/$directory .
64+
return
65+
fi
66+
67+
if [ ! -d $directory ]; then
68+
local args=""
69+
test "$branch" = "master" && args="--depth 1"
70+
git clone $url $args
71+
fi
72+
73+
pushd $directory &>/dev/null
74+
75+
git reset --hard
76+
git clean -fdx
77+
git checkout $branch
78+
git pull origin $branch
79+
80+
popd &>/dev/null
81+
}
82+
83+
84+
if [ $# -lt 2 ]; then
85+
echo "usage: $0 AppleTVOS.sdk.tar* <target cpu>" 1>&2
86+
echo "i.e. $0 /path/to/AppleTVOS.sdk.tar.xz armv7" 1>&2
87+
exit 1
88+
fi
89+
90+
TRIPLE="arm-apple-darwin11"
91+
TARGETDIR="$PWD/target"
92+
SDKDIR="$TARGETDIR/SDK"
93+
94+
if [ -d $TARGETDIR ]; then
95+
echo "cleaning up ..."
96+
rm -rf $TARGETDIR
97+
fi
98+
99+
mkdir -p $TARGETDIR
100+
mkdir -p $TARGETDIR/bin
101+
mkdir -p $SDKDIR
102+
103+
echo ""
104+
echo "*** extracting SDK ***"
105+
echo ""
106+
107+
pushd $SDKDIR &>/dev/null
108+
SDK_VERSION=$(echo $1 | grep -P -o "[0-9][0-9].[0-9]+" | head -1)
109+
if [ -z "$SDK_VERSION" ]; then
110+
SDK_VERSION=$(echo $1 | grep -P -o "[0-9].[0-9]+" | head -1)
111+
fi
112+
if [ -z "$SDK_VERSION" ]; then
113+
echo "AppleTVOS Version must be in the SDK filename!" 1>&2
114+
exit 1
115+
fi
116+
extract $1
117+
SYSLIB=$(find $SDKDIR -name libSystem.dylib -o -name libSystem.tbd | head -n1)
118+
if [ -z "$SYSLIB" ]; then
119+
echo "SDK should contain libSystem{.dylib,.tbd}" 1>&2
120+
exit 1
121+
fi
122+
WRAPPER_SDKDIR=$(echo AppleTVOS*sdk | head -n1)
123+
if [ -z "$WRAPPER_SDKDIR" ]; then
124+
echo "broken SDK" 1>&2
125+
exit 1
126+
fi
127+
popd &>/dev/null
128+
129+
echo ""
130+
echo "*** building wrapper ***"
131+
echo ""
132+
133+
OK=0
134+
135+
set +e
136+
which $LLVM_DSYMUTIL &>/dev/null
137+
if [ $? -eq 0 ]; then
138+
case $($LLVM_DSYMUTIL --version | \
139+
grep "LLVM version" | head -1 | awk '{print $3}') in
140+
3.8*|3.9*|4.0*|5.0*|6.0*|7.0*|8.0*|9.0*) OK=1 ;;
141+
esac
142+
fi
143+
set -e
144+
145+
if [ $OK -eq 1 ]; then
146+
ln -sf $(which $LLVM_DSYMUTIL) $TARGETDIR/bin/dsymutil
147+
pushd $TARGETDIR/bin &>/dev/null
148+
ln -sf $TRIPLE-lipo lipo
149+
popd &>/dev/null
150+
elif ! which dsymutil &>/dev/null; then
151+
echo "int main(){return 0;}" | cc -xc -O2 -o $TARGETDIR/bin/dsymutil -
152+
fi
153+
154+
verbose_cmd cc -O2 -Wall -Wextra -pedantic wrapper.c \
155+
-DSDK_DIR=\"\\\"$WRAPPER_SDKDIR\\\"\" \
156+
-DTARGET_CPU=\"\\\"$2\\\"\" \
157+
-DOS_VER_MIN=\"\\\"$SDK_VERSION\\\"\" \
158+
-o $TARGETDIR/bin/$TRIPLE-clang
159+
160+
pushd $TARGETDIR/bin &>/dev/null
161+
verbose_cmd ln -sf $TRIPLE-clang $TRIPLE-clang++
162+
popd &>/dev/null
163+
164+
echo ""
165+
echo "*** building ldid ***"
166+
echo ""
167+
168+
rm -rf tmp
169+
170+
mkdir -p tmp
171+
pushd tmp &>/dev/null
172+
git_clone_repository https://github.com/tpoechtrager/ldid.git master
173+
pushd ldid &>/dev/null
174+
make INSTALLPREFIX=$TARGETDIR -j$JOBS install
175+
popd &>/dev/null
176+
popd &>/dev/null
177+
178+
echo ""
179+
echo "*** building apple-libtapi ***"
180+
echo ""
181+
182+
pushd tmp &>/dev/null
183+
git_clone_repository https://github.com/tpoechtrager/apple-libtapi.git 1100.0.11
184+
pushd apple-libtapi &>/dev/null
185+
INSTALLPREFIX=$TARGETDIR ./build.sh
186+
./install.sh
187+
popd &>/dev/null
188+
popd &>/dev/null
189+
190+
echo ""
191+
echo "*** building cctools / ld64 ***"
192+
echo ""
193+
194+
pushd ../../cctools &>/dev/null
195+
git clean -fdx &>/dev/null || true
196+
popd &>/dev/null
197+
198+
pushd tmp &>/dev/null
199+
mkdir -p cctools
200+
pushd cctools &>/dev/null
201+
../../../../cctools/configure --target=$TRIPLE --prefix=$TARGETDIR --with-libtapi=$TARGETDIR
202+
make -j$JOBS && make install
203+
popd &>/dev/null
204+
popd &>/dev/null
205+
206+
echo ""
207+
echo "*** checking toolchain ***"
208+
echo ""
209+
210+
export PATH=$TARGETDIR/bin:$PATH
211+
212+
echo "int main(){return 0;}" | $TRIPLE-clang -xc -O2 -o test - 1>/dev/null || exit 1
213+
rm test
214+
echo "OK"
215+
216+
echo ""
217+
echo "*** all done ***"
218+
echo ""
219+
echo "do not forget to add $TARGETDIR/bin to your PATH variable"
220+
echo ""

0 commit comments

Comments
 (0)