Skip to content

Commit d01ac3f

Browse files
committed
tvOS build container
1 parent aaa066f commit d01ac3f

File tree

4 files changed

+503
-9
lines changed

4 files changed

+503
-9
lines changed

Dockerfile.tvos

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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+
15+
RUN cd /root/cctools-port && \
16+
yes | cp -rf /root/files/tvos_example.sh usage_examples/ios_toolchain/build.sh && \
17+
yes | cp -rf /root/files/tvos_wrapper.c usage_examples/ios_toolchain/wrapper.c && \
18+
chmod +x usage_examples/ios_toolchain/build.sh
19+
20+
RUN cd /root/cctools-port && \
21+
usage_examples/ios_toolchain/build.sh /root/files/AppleTVOS${TVOS_SDK}.sdk.tar.xz arm64
22+
23+
RUN cd /root/cctools-port && \
24+
mkdir -p /root/ioscross/arm64 && \
25+
mv usage_examples/ios_toolchain/target/* /root/ioscross/arm64 && \
26+
mkdir /root/ioscross/arm64/usr && \
27+
ln -s /root/ioscross/arm64/bin /root/ioscross/arm64/usr/bin
28+
29+
RUN cd /root/cctools-port && \
30+
sed -i 's#AppleTVOS#AppleTVSimulator#' usage_examples/ios_toolchain/build.sh && \
31+
sed -i 's#-mappletvos-version-min=#-mappletvsimulator-version-min=#' usage_examples/ios_toolchain/wrapper.c && \
32+
sed -i 's#^TRIPLE=.*#TRIPLE="x86_64-apple-darwin11"#' usage_examples/ios_toolchain/build.sh
33+
34+
RUN cd /root/cctools-port && \
35+
usage_examples/ios_toolchain/build.sh /root/files/AppleTVSimulator${TVOS_SDK}.sdk.tar.xz x86_64
36+
37+
RUN cd /root/cctools-port && \
38+
mkdir -p /root/ioscross/x86_64 && \
39+
mv usage_examples/ios_toolchain/target/* /root/ioscross/x86_64 && \
40+
mkdir /root/ioscross/x86_64/usr && \
41+
ln -s /root/ioscross/x86_64/bin /root/ioscross/x86_64/usr/bin
42+
43+
ENV OSXCROSS_TVOS=not_nothing
44+
ENV TVOSCROSS_ROOT=/root/ioscross
45+
ENV PATH="/root/ioscross/arm64/bin:/root/ioscross/x86_64/bin:${PATH}"
46+
47+
CMD /bin/bash

Dockerfile.xcode

+41-9
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,31 @@ ARG img_version
22
FROM godot-fedora:${img_version}
33

44
RUN dnf -y install --setopt=install_weak_deps=False \
5-
autoconf automake libtool clang cmake fuse fuse-devel libxml2-devel libicu-devel compat-openssl10-devel bzip2-devel kmod cpio && \
6-
git clone --progress https://github.com/mackyle/xar.git && \
7-
cd xar/xar && \
8-
git checkout 66d451dab1ef859dd0c83995f2379335d35e53c9 && \
9-
./autogen.sh --prefix=/usr && \
10-
make -j && make install && \
11-
cd /root && \
5+
autoconf automake libtool clang cmake fuse fuse-devel libxml2-devel libicu-devel compat-openssl10-devel bzip2-devel kmod cpio
6+
7+
RUN git clone --progress https://github.com/mackyle/xar.git
8+
9+
RUN cd xar/xar && \
10+
git checkout 66d451dab1ef859dd0c83995f2379335d35e53c9
11+
12+
RUN cd xar/xar && \
13+
export CC_FOR_BUILD=clang && \
14+
./autogen.sh --prefix=/usr
15+
16+
RUN cd xar/xar && \
17+
make -j
18+
19+
RUN cd xar/xar && \
20+
make install
21+
22+
RUN cd /root && \
1223
git clone --progress https://github.com/NiklasRosenstein/pbzx && \
1324
cd pbzx && \
1425
git checkout 2a4d7c3300c826d918def713a24d25c237c8ed53 && \
1526
clang -O3 -llzma -lxar -I /usr/local/include pbzx.c -o pbzx
1627

1728
CMD mkdir -p /root/xcode && \
29+
# macOS
1830
cd /root/xcode && \
1931
xar -xf /root/files/Xcode_12.2.xip && \
2032
/root/pbzx/pbzx -n Content | cpio -i && \
@@ -29,19 +41,39 @@ CMD mkdir -p /root/xcode && \
2941
cd /tmp && \
3042
tar -cJf /root/files/${OSX_SDK}.tar.xz ${OSX_SDK} && \
3143
rm -rf ${OSX_SDK} && \
44+
# iOS
3245
cd /root/xcode && \
3346
export IOS_SDK=iPhoneOS14.2.sdk && \
34-
export IOS_SIMULATOR_SDK=iPhoneSimulator14.2.sdk && \
3547
cp -r Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk /tmp/${IOS_SDK} && \
3648
mkdir -p /tmp/${IOS_SDK}/usr/include/c++ && \
3749
cp -r Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1 /tmp/${IOS_SDK}/usr/include/c++/ && \
3850
cd /tmp && \
3951
tar -cJf /root/files/${IOS_SDK}.tar.xz ${IOS_SDK} && \
4052
rm -rf ${IOS_SDK} && \
53+
# iOS Simulator
4154
cd /root/xcode && \
55+
export IOS_SIMULATOR_SDK=iPhoneSimulator14.2.sdk && \
4256
cp -r Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk /tmp/${IOS_SDK} && \
4357
mkdir -p /tmp/${IOS_SDK}/usr/include/c++ && \
4458
cp -r Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1 /tmp/${IOS_SDK}/usr/include/c++/ && \
4559
cd /tmp && \
4660
tar -cJf /root/files/${IOS_SIMULATOR_SDK}.tar.xz ${IOS_SDK} && \
47-
rm -rf ${IOS_SDK}
61+
rm -rf ${IOS_SDK} && \
62+
# tvOS
63+
cd /root/xcode && \
64+
export TVOS_SDK=AppleTVOS14.2.sdk && \
65+
cp -r Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk /tmp/${TVOS_SDK} && \
66+
mkdir -p /tmp/${TVOS_SDK}/usr/include/c++ && \
67+
cp -r Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1 /tmp/${TVOS_SDK}/usr/include/c++/ && \
68+
cd /tmp && \
69+
tar -cJf /root/files/${TVOS_SDK}.tar.xz ${TVOS_SDK} && \
70+
rm -rf ${TVOS_SDK} && \
71+
# tvOS Simulator
72+
cd /root/xcode && \
73+
export TVOS_SIMULATOR_SDK=AppleTVSimulator14.2.sdk && \
74+
cp -r Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator.sdk /tmp/${TVOS_SIMULATOR_SDK} && \
75+
mkdir -p /tmp/${TVOS_SIMULATOR_SDK}/usr/include/c++ && \
76+
cp -r Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1 /tmp/${TVOS_SIMULATOR_SDK}/usr/include/c++/ && \
77+
cd /tmp && \
78+
tar -cJf /root/files/${TVOS_SIMULATOR_SDK}.tar.xz ${TVOS_SIMULATOR_SDK} && \
79+
rm -rf ${TVOS_SIMULATOR_SDK}

files/tvos_example.sh

+220
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)