Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions Dockerfile.appleembedded
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
ARG img_version
FROM godot-osx:${img_version}

RUN dnf -y install --setopt=install_weak_deps=False \
automake autoconf gcc gcc-c++ gcc-objc gcc-objc++ cmake libicu-devel libtool libxml2-devel openssl-devel perl python yasm

ENV IOS_SDK=18.5
ENV TVOS_SDK=18.5
ENV XROS_SDK=2.5

# Extract the SDKs for iOS, tvOS and XROS, including the simulator SDKs
# into separate layers, so this work is not repeated each time the image is built.
RUN mkdir -p /root/SDKs
RUN cd /root/SDKs && tar xf /root/files/iPhoneOS${IOS_SDK}.sdk.tar.xz
RUN cd /root/SDKs && tar xf /root/files/iPhoneSimulator${IOS_SDK}.sdk.tar.xz
RUN cd /root/SDKs && tar xf /root/files/AppleTVOS${TVOS_SDK}.sdk.tar.xz
RUN cd /root/SDKs && tar xf /root/files/AppleTVSimulator${TVOS_SDK}.sdk.tar.xz
RUN cd /root/SDKs && tar xf /root/files/XROS${XROS_SDK}.sdk.tar.xz
RUN cd /root/SDKs && tar xf /root/files/XRSimulator${XROS_SDK}.sdk.tar.xz
Comment on lines +11 to +19
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the impact on disk usage to have all this in individual layers?

I usually try to keep things that are always going to be modified together in the same RUN to avoid having a ton of intermediate layers. Here for example all SDKs are tied to an Xcode version so we would likely never run this with only some of the SDKs requiring to be extracted, it's all or nothing.


RUN git clone --depth 1 --no-checkout https://github.com/tpoechtrager/cctools-port.git && \
cd /root/cctools-port && \
git fetch --depth 1 origin 7224fd5c9390ea15cff6ee69ff92ea677b40014b && \
git checkout 7224fd5c9390ea15cff6ee69ff92ea677b40014b

COPY files/appleembedded/build.sh /root/cctools-port/usage_examples/ios_toolchain/build.sh
COPY files/appleembedded/wrapper.c /root/cctools-port/usage_examples/ios_toolchain/wrapper.c

RUN chmod +x /root/cctools-port/usage_examples/ios_toolchain/build.sh

RUN cd /root/cctools-port && \
usage_examples/ios_toolchain/build.sh arm64 && \
mkdir -p /root/ioscross/arm64 && \
mv usage_examples/ios_toolchain/target/* /root/ioscross/arm64 && \
mkdir /root/ioscross/arm64/usr && \
ln -s /root/ioscross/arm64/bin /root/ioscross/arm64/usr/bin

RUN cd /root/cctools-port && \
usage_examples/ios_toolchain/build.sh x86_64 && \
mkdir -p /root/ioscross/x86_64 && \
mv usage_examples/ios_toolchain/target/* /root/ioscross/x86_64 && \
mkdir /root/ioscross/x86_64/usr && \
ln -s /root/ioscross/x86_64/bin /root/ioscross/x86_64/usr/bin

RUN PATH=/root/ioscross/arm64/bin:$PATH /root/files/appleembedded/check-arm.sh

ENV OSXCROSS_IOS=not_nothing
ENV OSXCROSS_TVOS=not_nothing
ENV OSXCROSS_VISIONOS=not_nothing
ENV OSXCROSS_APPLEEMBEDDED=not_nothing
Comment on lines +47 to +50
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the XROS one which was unused (SCons checks OSXCROSS_VISIONOS).
OSXCROSS_APPLEEMBEDDED is also unused but I kept it for now in case we want to unify things upstream behind OSXCROSS_APPLEEMBEDDED.

It's a bit of a weird system though where we set an environment variable to whatever just to say we want to support osxcross. Maybe we should change it upstream to instead use osxcross=yes on the command line. But it's not super important.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree - as that would make it more obvious when cross-compiling with scons. A future update?


ENV PATH="/root/ioscross/arm64/bin:/root/ioscross/x86_64/bin:${PATH}"

CMD /bin/bash
39 changes: 0 additions & 39 deletions Dockerfile.ios

This file was deleted.

3 changes: 3 additions & 0 deletions Dockerfile.osx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ RUN dnf -y install --setopt=install_weak_deps=False \
git clone --progress https://github.com/tpoechtrager/osxcross && \
cd /root/osxcross && \
git checkout 310196974007fc916f9be1877731b716a4854f72 && \
# Patch to fix visionOS support.
# See: https://github.com/llvm/llvm-project/issues/142502
patch -p1 < /root/files/patches/osxcross-fix-visionos.patch && \
ln -s /root/files/MacOSX${OSX_SDK}.sdk.tar.xz /root/osxcross/tarballs && \
export UNATTENDED=1 && \
export SDK_VERSION=${OSX_SDK} && \
Expand Down
27 changes: 6 additions & 21 deletions Dockerfile.xcode
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,10 @@ RUN dnf -y install --setopt=install_weak_deps=False \
ENV XCODE_SDKV=
ENV OSX_SDKV=
ENV IOS_SDKV=
ENV TVOS_SDKV=
ENV VISIONOS_SDKV=

CMD mkdir -p /root/xcode && \
cd /root/xcode && \
xar -xf /root/files/Xcode_${XCODE_SDKV}.xip && \
/root/pbzx/pbzx -n Content | cpio -i && \
export OSX_SDK=MacOSX${OSX_SDKV}.sdk && \
cp -r Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk /tmp/${OSX_SDK} && \
cd /tmp && \
tar -cJf /root/files/${OSX_SDK}.tar.xz ${OSX_SDK} && \
rm -rf ${OSX_SDK} && \
cd /root/xcode && \
export IOS_SDK=iPhoneOS${IOS_SDKV}.sdk && \
export IOS_SIMULATOR_SDK=iPhoneSimulator${IOS_SDKV}.sdk && \
cp -r Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk /tmp/${IOS_SDK} && \
cd /tmp && \
tar -cJf /root/files/${IOS_SDK}.tar.xz ${IOS_SDK} && \
rm -rf ${IOS_SDK} && \
cd /root/xcode && \
cp -r Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk /tmp/${IOS_SIMULATOR_SDK} && \
cd /tmp && \
tar -cJf /root/files/${IOS_SIMULATOR_SDK}.tar.xz ${IOS_SIMULATOR_SDK} && \
rm -rf ${IOS_SIMULATOR_SDK}
COPY extract_xcode_sdks.sh /root/extract_xcode_sdks.sh
RUN chmod +x /root/extract_xcode_sdks.sh

CMD /root/extract_xcode_sdks.sh
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not against it, but was there a specific reason you had to move this to a new script? Was the previous logic not doing a clear enough extraction of the SDKs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was easier to debug and test the individual commands as a separate script, so I figured I would just reuse it for the container.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ These are the expected container image sizes, so you can plan your disk usage in
localhost/godot-web 4.5-f42 2.35 GB
localhost/godot-android 4.5-f42 4.19 GB
localhost/godot-osx 4.5-f42 5.30 GB
localhost/godot-ios 4.5-f42 6.11 GB
localhost/godot-appleembedded 4.5-f42 14.1 GB

In addition to this, generating containers will also require some host disk space
(up to 10 GB) for the dependencies (Xcode).
Expand All @@ -93,4 +93,4 @@ These are the toolchains currently in use for Godot 4.3 and later:
- Android: Android NDK 28.1.13356709, build-tools 35.0.0, platform android-35, CMake 3.31.6, JDK 21
- Apple: Xcode 16.4 with Apple Clang (LLVM 19.1.4), cctools 1024.3, ld64 955.13
* macOS: MacOSX SDK 15.5
* iOS: iPhoneOS SDK 18.5
* Apple Embedded: iPhoneOS and iPhoneSimulator SDKs 18.5, AppleTVOS and AppleTVSimulator SDKs 18.5, XROS and XRSimulator SDKs 2.5
12 changes: 9 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,24 +61,30 @@ podman_build android
XCODE_SDK=16.4
OSX_SDK=15.5
IOS_SDK=18.5
if [ ! -e "${files_root}"/MacOSX${OSX_SDK}.sdk.tar.xz ] || [ ! -e "${files_root}"/iPhoneOS${IOS_SDK}.sdk.tar.xz ] || [ ! -e "${files_root}"/iPhoneSimulator${IOS_SDK}.sdk.tar.xz ]; then
TVOS_SDK=18.5
VISIONOS_SDK=2.5
if [ ! -e "${files_root}"/MacOSX${OSX_SDK}.sdk.tar.xz ] || [ ! -e "${files_root}"/iPhoneOS${IOS_SDK}.sdk.tar.xz ] || [ ! -e "${files_root}"/iPhoneSimulator${IOS_SDK}.sdk.tar.xz ] \
|| [ ! -e "${files_root}"/AppleTVOS${TVOS_SDK}.sdk.tar.xz ] || [ ! -e "${files_root}"/AppleTVSimulator${TVOS_SDK}.sdk.tar.xz ] \
|| [ ! -e "${files_root}"/XROS${VISIONOS_SDK}.sdk.tar.xz ] || [ ! -e "${files_root}"/XRSimulator${VISIONOS_SDK}.sdk.tar.xz ]; then
if [ ! -r "${files_root}"/Xcode_${XCODE_SDK}.xip ]; then
echo
echo "Error: 'files/Xcode_${XCODE_SDK}.xip' is required for Apple platforms, but was not found or couldn't be read."
echo "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"
echo "Extracting Apple SDK packages. This will take a while."
podman_build xcode
"$podman" run -it --rm \
-v "${files_root}":/root/files:z \
-e XCODE_SDKV="${XCODE_SDK}" \
-e OSX_SDKV="${OSX_SDK}" \
-e IOS_SDKV="${IOS_SDK}" \
-e TVOS_SDKV="${TVOS_SDK}" \
-e VISIONOS_SDKV="${VISIONOS_SDK}" \
godot-xcode:${img_version} \
2>&1 | tee logs/xcode_packer.log
fi

podman_build osx
podman_build ios
podman_build appleembedded
151 changes: 151 additions & 0 deletions extract_xcode_sdks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
#!/usr/bin/env bash

set -euo pipefail

# Configurable variables (can be set via env)
XCODE_APP_PATH="${XCODE_APP_PATH:-/root/xcode/Xcode.app}"
XCODE_XIP_PATH="${XCODE_XIP_PATH:-/root/files/Xcode_${XCODE_SDKV}.xip}"
EXTRACT_FROM_XIP="${EXTRACT_FROM_XIP:-1}"

OUT_DIR="${OUT_DIR:-/root/files}"

# SDK versions (should be set via env or Dockerfile)
OSX_SDKV="${OSX_SDKV:-}"
IOS_SDKV="${IOS_SDKV:-}"
TVOS_SDKV="${TVOS_SDKV:-}"
VISIONOS_SDKV="${VISIONOS_SDKV:-}"

# Which SDKs to extract (set to 1 to enable)
# Note: These defaults are overridden below based on execution context

# Optionally extract Xcode.app from .xip if needed
if [[ "$EXTRACT_FROM_XIP" == "1" ]]; then
mkdir -p /root/xcode
cd /root/xcode
xar -xf "$XCODE_XIP_PATH"
/root/pbzx/pbzx -n Content | cpio -i
XCODE_APP_PATH="/root/xcode/Xcode.app"
fi

if [[ "${EXTRACT_FROM_XIP:-1}" == "1" ]]; then
EXTRACT_MACOS="${EXTRACT_MACOS:-1}"
EXTRACT_IOS="${EXTRACT_IOS:-1}"
EXTRACT_IOS_SIM="${EXTRACT_IOS_SIM:-1}"
EXTRACT_TVOS="${EXTRACT_TVOS:-1}"
EXTRACT_TVOS_SIM="${EXTRACT_TVOS_SIM:-1}"
EXTRACT_VISIONOS="${EXTRACT_VISIONOS:-1}"
EXTRACT_VISIONOS_SIM="${EXTRACT_VISIONOS_SIM:-1}"
else
# When called manually, require explicit SDK selection
EXTRACT_MACOS="${EXTRACT_MACOS:-0}"
EXTRACT_IOS="${EXTRACT_IOS:-0}"
EXTRACT_IOS_SIM="${EXTRACT_IOS_SIM:-0}"
EXTRACT_TVOS="${EXTRACT_TVOS:-0}"
EXTRACT_TVOS_SIM="${EXTRACT_TVOS_SIM:-0}"
EXTRACT_VISIONOS="${EXTRACT_VISIONOS:-0}"
EXTRACT_VISIONOS_SIM="${EXTRACT_VISIONOS_SIM:-0}"
fi

extract_and_pack() {
local sdk_dir="$1"
local sdk_name="$2"
local versioned_name="$3"
local tar_name="$4"

if [[ -d "$sdk_dir/$sdk_name" ]]; then

# Use tar to copy and preserve everything, then repackage
echo "=== Copying SDK using tar to preserve special files ==="
cd "$sdk_dir"
tar -cf - "$sdk_name" | (cd "/tmp" && tar -xf -)

# Rename to versioned name
mv "/tmp/$sdk_name" "/tmp/$versioned_name"

# Verify SDKSettings.json exists and has content
if [[ -f "/tmp/$versioned_name/SDKSettings.json" ]]; then
echo "=== SDKSettings.json found, size: $(wc -c < "/tmp/$versioned_name/SDKSettings.json") bytes ==="
echo "=== MD5 check ==="
echo "Source file MD5: $(md5sum "$sdk_dir/$sdk_name/SDKSettings.json" | cut -d' ' -f1)"
echo "Copied file MD5: $(md5sum "/tmp/$versioned_name/SDKSettings.json" | cut -d' ' -f1)"
else
echo "⚠️ Warning: SDKSettings.json not found in extracted SDK"
fi

# Create tar with versioned directory name
tar -cJf "$OUT_DIR/$tar_name" -C "/tmp" "$versioned_name"

# Clean up temporary directory
rm -rf "/tmp/$versioned_name"

echo "✓ Packed $tar_name"
else
echo "✗ SDK not found: $sdk_dir/$sdk_name"
exit 1
fi
}

# macOS SDK
if [[ "$EXTRACT_MACOS" == "1" ]]; then
extract_and_pack \
"$XCODE_APP_PATH/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs" \
"MacOSX.sdk" \
"MacOSX${OSX_SDKV}.sdk" \
"MacOSX${OSX_SDKV}.sdk.tar.xz"
fi

# iOS SDK
if [[ "$EXTRACT_IOS" == "1" ]]; then
extract_and_pack \
"$XCODE_APP_PATH/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs" \
"iPhoneOS.sdk" \
"iPhoneOS${IOS_SDKV}.sdk" \
"iPhoneOS${IOS_SDKV}.sdk.tar.xz"
fi

# iOS Simulator SDK
if [[ "$EXTRACT_IOS_SIM" == "1" ]]; then
extract_and_pack \
"$XCODE_APP_PATH/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs" \
"iPhoneSimulator.sdk" \
"iPhoneSimulator${IOS_SDKV}.sdk" \
"iPhoneSimulator${IOS_SDKV}.sdk.tar.xz"
fi

# tvOS SDK
if [[ "$EXTRACT_TVOS" == "1" ]]; then
extract_and_pack \
"$XCODE_APP_PATH/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs" \
"AppleTVOS.sdk" \
"AppleTVOS${TVOS_SDKV}.sdk" \
"AppleTVOS${TVOS_SDKV}.sdk.tar.xz"
fi

# tvOS Simulator SDK
if [[ "$EXTRACT_TVOS_SIM" == "1" ]]; then
extract_and_pack \
"$XCODE_APP_PATH/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs" \
"AppleTVSimulator.sdk" \
"AppleTVSimulator${TVOS_SDKV}.sdk" \
"AppleTVSimulator${TVOS_SDKV}.sdk.tar.xz"
fi

# visionOS SDK
if [[ "$EXTRACT_VISIONOS" == "1" ]]; then
extract_and_pack \
"$XCODE_APP_PATH/Contents/Developer/Platforms/XROS.platform/Developer/SDKs" \
"XROS.sdk" \
"XROS${VISIONOS_SDKV}.sdk" \
"XROS${VISIONOS_SDKV}.sdk.tar.xz"
fi

# visionOS Simulator SDK
if [[ "$EXTRACT_VISIONOS_SIM" == "1" ]]; then
extract_and_pack \
"$XCODE_APP_PATH/Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs" \
"XRSimulator.sdk" \
"XRSimulator${VISIONOS_SDKV}.sdk" \
"XRSimulator${VISIONOS_SDKV}.sdk.tar.xz"
fi

echo "Done extracting selected SDKs."
Loading