Skip to content

Gather XCode SDKs for OSXCROSS #51

Gather XCode SDKs for OSXCROSS

Gather XCode SDKs for OSXCROSS #51

name: Gather XCode SDKs for OSXCROSS
on:
workflow_dispatch:
inputs:
do_deploy:
description: Does this get deployed to Digital Ocean?
required: true
type: boolean
default: false
artifact:
description: Create a artifact?
required: true
type: boolean
default: false
tar_files:
description: Do you want to Tar Files?
required: true
type: boolean
default: false
xcode_version:
description: Version of Xcode to copy the SDKs from
required: true
type: string
default: "15.4"
build_type:
description: nightly, prerelease, release
required: true
type: string
default: "nightly"
env:
BASE_FOLDER: deps
XCODE_VERSION: ${{ inputs.xcode_version }}
jobs:
build-osxcross-sdk:
name: Build osxcross SDK for Linux
runs-on: macos-latest
if: false
steps:
- name: Install Required Dependencies
run: |
brew install coreutils llvm
echo "✅ Dependencies installed successfully." >> $GITHUB_STEP_SUMMARY
- name: Clone and Setup osxcross
run: |
git clone https://github.com/tpoechtrager/osxcross.git ${{ github.workspace }}/osxcross
cd ${{ github.workspace }}/osxcross
mkdir ${{ github.workspace }}/output
mkdir ${{ github.workspace }}/sdk
echo "✅ osxcross repository cloned." >> $GITHUB_STEP_SUMMARY
- name: Generate SDK Package
run: |
cd ${{ github.workspace }}/output
${{ github.workspace }}/osxcross/tools/gen_sdk_package.sh
ls -la
cp ${{ github.workspace }}/output/MacOSX14.5.sdk.tar.xz ${{ github.workspace }}/osxcross/tarballs
echo "✅ SDK package generated using gen_sdk_package.sh." >> $GITHUB_STEP_SUMMARY
- name: Generate Tools Package
run: |
cd ${{ github.workspace }}/output
XCODE_TOOLS=1 ${{ github.workspace }}/osxcross/tools/gen_sdk_package.sh
ls -la
echo "✅ SDK package generated using gen_sdk_package.sh." >> $GITHUB_STEP_SUMMARY
- name: Upload osxcross SDK as Artifact
uses: actions/upload-artifact@v4
with:
name: macos-sdk-packaged
path: ${{ github.workspace }}/output
# - name: Build osxcross
# run: |
# cd ${{ github.workspace }}/osxcross
# export OSXCROSS_ENABLE_WERROR_IMPLICIT_FUNCTION_DECLARATION=1
# export OSXCROSS_GCC_NO_STATIC_RUNTIME=1
# UNATTENDED=1 TARGET_DIR=${{ github.workspace }}/sdk ./build.sh
# echo "✅ osxcross built successfully." >> $GITHUB_STEP_SUMMARY
# - name: Validate osxcross Installation
# run: |
# ${{ github.workspace }}/sdk/bin/x86_64-apple-darwin20.2-clang --version
# ${{ github.workspace }}/sdk/bin/x86_64-apple-darwin20.2-gcc --version
# echo "✅ osxcross installation validated." >> $GITHUB_STEP_SUMMARY
# - name: Upload osxcross SDK as Artifact
# uses: actions/upload-artifact@v4
# with:
# name: osxcross-sdk-linux
# path: /usr/local/osxcross/
- name: Summary of Process
run: |
echo "### osxcross SDK Build Process Summary" >> $GITHUB_STEP_SUMMARY
echo "1. **Dependencies**: Installed cmake, wget, coreutils, and llvm." >> $GITHUB_STEP_SUMMARY
echo "2. **SDK Package Generation**: Used gen_sdk_package.sh with Xcode 15.4." >> $GITHUB_STEP_SUMMARY
# echo "3. **Clang Setup**: Built Clang for osxcross." >> $GITHUB_STEP_SUMMARY
# echo "4. **GCC Setup**: Built GCC version 12.2.0 with Fortran support." >> $GITHUB_STEP_SUMMARY
# echo "5. **osxcross Setup**: Built osxcross using the generated SDK package and installed to /usr/local/osxcross." >> $GITHUB_STEP_SUMMARY
# echo "6. **Environment**: Enabled -Werror=implicit-function-declaration and disabled static linking for libgcc/libstdc++." >> $GITHUB_STEP_SUMMARY
# echo "7. **Validation**: Verified both Clang and GCC cross-compilers." >> $GITHUB_STEP_SUMMARY
# echo "8. **Artifact**: osxcross SDK uploaded for Linux." >> $GITHUB_STEP_SUMMARY
- name: Cleanup
if: always()
run: |
rm -rf ~/osxcross
echo "✅ Cleanup completed." >> $GITHUB_STEP_SUMMARY
gather:
name: Process XCode SDKs
runs-on: "macos-latest"
steps:
- name: Set up Base Folder
id: base_folder
run: |
mkdir -p "$(pwd)/$BASE_FOLDER"
echo "base_folder=$(pwd)/$BASE_FOLDER" >> $GITHUB_OUTPUT
- name: XCode
run: |
xcode-select --print-path >> $GITHUB_STEP_SUMMARY
sudo xcodebuild -license accept
- name: List SDKs and Developer Platforms
run: |
echo '### Base Directory' >> $GITHUB_STEP_SUMMARY
ls -la /Applications/ >> $GITHUB_STEP_SUMMARY
ls -la /Applications/Xcode_$XCODE_VERSION.app/ >> $GITHUB_STEP_SUMMARY
ls -la /Applications/Xcode_$XCODE_VERSION.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk >> $GITHUB_STEP_SUMMARY
ls -la /Applications/Xcode_$XCODE_VERSION.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1 >> $GITHUB_STEP_SUMMARY
echo '### Toolchains Directory' >> $GITHUB_STEP_SUMMARY
ls -la /Applications/Xcode_$XCODE_VERSION.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/ >> $GITHUB_STEP_SUMMARY
ls -la /Applications/Xcode_$XCODE_VERSION.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr >> $GITHUB_STEP_SUMMARY
ls -la /Applications/Xcode_$XCODE_VERSION.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include >> $GITHUB_STEP_SUMMARY
ls -la /Applications/Xcode_$XCODE_VERSION.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib >> $GITHUB_STEP_SUMMARY
echo '### Platforms Directory' >> $GITHUB_STEP_SUMMARY
ls -la /Applications/Xcode_$XCODE_VERSION.app/Contents/Developer/Platforms/ >> $GITHUB_STEP_SUMMARY
ls -la /Applications/Xcode_$XCODE_VERSION.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs >> $GITHUB_STEP_SUMMARY
ls -la /Applications/Xcode_$XCODE_VERSION.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs >> $GITHUB_STEP_SUMMARY
ls -la /Applications/Xcode_$XCODE_VERSION.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs >> $GITHUB_STEP_SUMMARY
- name: Create tar.xz archives for iPhoneOS directories
if: ${{ inputs.tar_files }}
run: |
SDK_PATH="/Applications/Xcode_$XCODE_VERSION.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs"
echo "Working in directory: $(pwd)" >> $GITHUB_STEP_SUMMARY
echo "SDK Path: $SDK_PATH" >> $GITHUB_STEP_SUMMARY
function copy_linked_dirs()
{
local src="$1"
local dest="$2"
if [ -h "$src" ]; then
# Resolve symbolic link
local resolved_src="$(rreadlink "$src")"
echo "Resolved symlink: $src -> $resolved_src" >> $GITHUB_STEP_SUMMARY
cp -R "$resolved_src" "$dest"
else
cp -R "$src" "$dest"
fi
}
function rreadlink()
{
if [ ! -h "$1" ]; then
echo "$1"
else
local link="$(expr "$(command ls -ld -- "$1")" : '.*-> \(.*\)$')"
cd $(dirname $1)
rreadlink "$link" | sed "s|^\([^/].*\)\$|$(dirname $1)/\1|"
fi
}
LIBCXXDIR1="/Applications/Xcode_$XCODE_VERSION.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1"
LIBCXXDIR2="/Applications/Xcode_$XCODE_VERSION.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1"
LIBCXXDIR3="/Applications/Xcode_$XCODE_VERSION.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1"
MANDIR="/Applications/Xcode_$XCODE_VERSION.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/share/man"
echo "Looking for libc++ headers for iPhoneOS SDK..." >> $GITHUB_STEP_SUMMARY
for sdk in $(ls "$SDK_PATH" | grep iPhoneOS | grep -v iPhoneOS.sdk); do
echo "Processing SDK: $sdk" >> $GITHUB_STEP_SUMMARY
TMP_DIR=$(mktemp -d)
echo "Temporary directory created: $TMP_DIR" >> $GITHUB_STEP_SUMMARY
mkdir -p "$TMP_DIR/$sdk/usr/include/c++"
copy_linked_dirs "$(rreadlink "$SDK_PATH/$sdk")" "$TMP_DIR/$sdk"
# Copy libc++ headers
if [ ! -f "$TMP_DIR/$sdk/usr/include/c++/v1/version" ]; then
if [ -d $LIBCXXDIR1 ]; then
cp -rf $LIBCXXDIR1 "$TMP_DIR/$sdk/usr/include/c++"
echo "Found libc++ headers at $LIBCXXDIR1 for $sdk" >> $GITHUB_STEP_SUMMARY
elif [ -d $LIBCXXDIR2 ]; then
cp -rf $LIBCXXDIR2 "$TMP_DIR/$sdk/usr/include/c++"
echo "Found libc++ headers at $LIBCXXDIR2 for $sdk" >> $GITHUB_STEP_SUMMARY
elif [ -d $LIBCXXDIR3 ]; then
cp -rf $LIBCXXDIR3 "$TMP_DIR/$sdk/usr/include/c++"
echo "Found libc++ headers at $LIBCXXDIR3 for $sdk" >> $GITHUB_STEP_SUMMARY
else
echo "No libc++ headers found for $sdk" >> $GITHUB_STEP_SUMMARY
fi
fi
# Copy manual directory if it exists
if [ -d $MANDIR ]; then
mkdir -p "$TMP_DIR/$sdk/usr/share/man"
copy_linked_dirs $MANDIR "$TMP_DIR/$sdk/usr/share/man"
echo "Manual directory copied for $sdk" >> $GITHUB_STEP_SUMMARY
fi
echo "Contents of $TMP_DIR/$sdk:" >> $GITHUB_STEP_SUMMARY
ls -la $TMP_DIR/$sdk >> $GITHUB_STEP_SUMMARY
sudo tar -cJf "$(pwd)/$BASE_FOLDER/${sdk}.tar.xz" "$TMP_DIR/$sdk"
echo "Archive created: $(pwd)/$BASE_FOLDER/${sdk}.tar.xz" >> $GITHUB_STEP_SUMMARY
done
- name: Create tar.xz archives for iPhoneSimulator directories
if: ${{ inputs.tar_files }}
run: |
SDK_PATH="/Applications/Xcode_$XCODE_VERSION.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs"
echo "Working in directory: $(pwd)" >> $GITHUB_STEP_SUMMARY
echo "SDK Path: $SDK_PATH" >> $GITHUB_STEP_SUMMARY
function copy_linked_dirs()
{
local src="$1"
local dest="$2"
if [ -h "$src" ]; then
# Resolve symbolic link
local resolved_src="$(rreadlink "$src")"
echo "Resolved symlink: $src -> $resolved_src" >> $GITHUB_STEP_SUMMARY
cp -R "$resolved_src/*" "$dest"
else
cp -R "$src/*" "$dest"
fi
}
function rreadlink()
{
if [ ! -h "$1" ]; then
echo "$1"
else
local link="$(expr "$(command ls -ld -- "$1")" : '.*-> \(.*\)$')"
cd $(dirname $1)
rreadlink "$link" | sed "s|^\([^/].*\)\$|$(dirname $1)/\1|"
fi
}
LIBCXXDIR1="/Applications/Xcode_$XCODE_VERSION.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1"
LIBCXXDIR2="/Applications/Xcode_$XCODE_VERSION.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1"
LIBCXXDIR3="/Applications/Xcode_$XCODE_VERSION.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1"
MANDIR="/Applications/Xcode_$XCODE_VERSION.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/share/man"
echo "Looking for libc++ headers for iPhoneSimulator SDK..." >> $GITHUB_STEP_SUMMARY
for sdk in $(ls "$SDK_PATH" | grep iPhoneSimulator | grep -v iPhoneSimulator.sdk); do
echo "Processing SDK: $sdk" >> $GITHUB_STEP_SUMMARY
TMP_DIR=$(mktemp -d)
echo "Temporary directory created: $TMP_DIR" >> $GITHUB_STEP_SUMMARY
mkdir -p "$TMP_DIR/$sdk/usr/include/c++"
copy_linked_dirs "$(rreadlink "$SDK_PATH/$sdk")" "$TMP_DIR/$sdk"
# Copy libc++ headers
if [ ! -f "$TMP_DIR/$sdk/usr/include/c++/v1/version" ]; then
if [ -d $LIBCXXDIR1 ]; then
cp -rf $LIBCXXDIR1 "$TMP_DIR/$sdk/usr/include/c++"
echo "Found libc++ headers at $LIBCXXDIR1 for $sdk" >> $GITHUB_STEP_SUMMARY
elif [ -d $LIBCXXDIR2 ]; then
cp -rf $LIBCXXDIR2 "$TMP_DIR/$sdk/usr/include/c++"
echo "Found libc++ headers at $LIBCXXDIR2 for $sdk" >> $GITHUB_STEP_SUMMARY
elif [ -d $LIBCXXDIR3 ]; then
cp -rf $LIBCXXDIR3 "$TMP_DIR/$sdk/usr/include/c++"
echo "Found libc++ headers at $LIBCXXDIR3 for $sdk" >> $GITHUB_STEP_SUMMARY
else
echo "No libc++ headers found for $sdk" >> $GITHUB_STEP_SUMMARY
fi
fi
# Copy manual directory if it exists
if [ -d $MANDIR ]; then
mkdir -p "$TMP_DIR/$sdk/usr/share/man"
copy_linked_dirs $MANDIR "$TMP_DIR/$sdk/usr/share/man"
echo "Manual directory copied for $sdk" >> $GITHUB_STEP_SUMMARY
fi
echo "Contents of $TMP_DIR/$sdk:" >> $GITHUB_STEP_SUMMARY
ls -la $TMP_DIR/$sdk >> $GITHUB_STEP_SUMMARY
sudo tar -cJf "$(pwd)/$BASE_FOLDER/${sdk}.tar.xz" "$TMP_DIR/$sdk"
echo "Archive created: $(pwd)/$BASE_FOLDER/${sdk}.tar.xz" >> $GITHUB_STEP_SUMMARY
done
- name: Create tar.xz archives for MacOSX directories
if: ${{ inputs.tar_files }}
run: |
SDK_PATH="/Applications/Xcode_$XCODE_VERSION.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs"
echo "Working in directory: $(pwd)" >> $GITHUB_STEP_SUMMARY
echo "SDK Path: $SDK_PATH" >> $GITHUB_STEP_SUMMARY
function copy_linked_dirs()
{
local src="$1"
local dest="$2"
if [ -h "$src" ]; then
# Resolve symbolic link
local resolved_src="$(rreadlink "$src")"
echo "Resolved symlink: $src -> $resolved_src" >> $GITHUB_STEP_SUMMARY
cp -R "$resolved_src" "$dest"
else
cp -R "$src" "$dest"
fi
}
function rreadlink()
{
if [ ! -h "$1" ]; then
echo "$1"
else
local link="$(expr "$(command ls -ld -- "$1")" : '.*-> \(.*\)$')"
cd $(dirname $1)
rreadlink "$link" | sed "s|^\([^/].*\)\$|$(dirname $1)/\1|"
fi
}
LIBCXXDIR1="/Applications/Xcode_$XCODE_VERSION.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/c++/v1"
LIBCXXDIR2="/Applications/Xcode_$XCODE_VERSION.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1"
LIBCXXDIR3="/Applications/Xcode_$XCODE_VERSION.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1"
MANDIR="/Applications/Xcode_$XCODE_VERSION.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/share/man"
echo "Looking for libc++ headers for MacOSX SDK..." >> $GITHUB_STEP_SUMMARY
for sdk in $(ls "$SDK_PATH" | grep MacOSX | grep -v MacOSX.sdk); do
echo "Processing SDK: $sdk" >> $GITHUB_STEP_SUMMARY
TMP_DIR=$(mktemp -d)
echo "Temporary directory created: $TMP_DIR" >> $GITHUB_STEP_SUMMARY
mkdir -p "$TMP_DIR/$sdk/usr/include/c++"
copy_linked_dirs "$(rreadlink "$SDK_PATH/$sdk")" "$TMP_DIR/$sdk"
# Copy libc++ headers
if [ ! -f "$TMP_DIR/$sdk/usr/include/c++/v1/version" ]; then
if [ -d $LIBCXXDIR1 ]; then
cp -rf $LIBCXXDIR1 "$TMP_DIR/$sdk/usr/include/c++"
echo "Found libc++ headers at $LIBCXXDIR1 for $sdk" >> $GITHUB_STEP_SUMMARY
elif [ -d $LIBCXXDIR2 ]; then
cp -rf $LIBCXXDIR2 "$TMP_DIR/$sdk/usr/include/c++"
echo "Found libc++ headers at $LIBCXXDIR2 for $sdk" >> $GITHUB_STEP_SUMMARY
elif [ -d $LIBCXXDIR3 ]; then
cp -rf $LIBCXXDIR3 "$TMP_DIR/$sdk/usr/include/c++"
echo "Found libc++ headers at $LIBCXXDIR3 for $sdk" >> $GITHUB_STEP_SUMMARY
else
echo "No libc++ headers found for $sdk" >> $GITHUB_STEP_SUMMARY
fi
fi
# Copy manual directory if it exists
if [ -d $MANDIR ]; then
mkdir -p "$TMP_DIR/$sdk/usr/share/man"
copy_linked_dirs $MANDIR "$TMP_DIR/$sdk/usr/share/man"
echo "Manual directory copied for $sdk" >> $GITHUB_STEP_SUMMARY
fi
echo "Contents of $TMP_DIR/$sdk:" >> $GITHUB_STEP_SUMMARY
ls -la $TMP_DIR/$sdk >> $GITHUB_STEP_SUMMARY
sudo tar -cJf "$(pwd)/$BASE_FOLDER/${sdk}.tar.xz" "$TMP_DIR/$sdk"
echo "Archive created: $(pwd)/$BASE_FOLDER/${sdk}.tar.xz" >> $GITHUB_STEP_SUMMARY
done
- name: List Base Folder Contents and Add to Summary
if: ${{ inputs.tar_files }}
run: |
ls -la "$(pwd)/$BASE_FOLDER" >> $GITHUB_STEP_SUMMARY
- name: Upload SDKs as Artifact
if: ${{ inputs.artifact }}
uses: actions/upload-artifact@v4
with:
name: macos-sdks-packaged
path: ${{ env.BASE_FOLDER }}
- uses: BetaHuhn/do-spaces-action@v2
name: Deploy to DigitalOcean
if: ${{ inputs.do_deploy }}
id: spaces
with:
access_key: ${{ secrets.DO_ACCESS_KEY }}
secret_key: ${{ secrets.DO_SECRET_KEY }}
space_name: ${{ secrets.DO_SPACE_NAME }}
space_region: ${{ secrets.DO_SPACE_REGION }}
source: ${{ env.BASE_FOLDER }}
out_dir: pipeline