-
-
Notifications
You must be signed in to change notification settings - Fork 76
Apple: add visionOS and tvOS build support; unify build container #154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 | ||
|
|
||
| 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
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I removed the 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
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| 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." |
There was a problem hiding this comment.
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
RUNto 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.