Skip to content

Commit

Permalink
Merge pull request #74 from alicerunsonfedora/marquis/arm-builds
Browse files Browse the repository at this point in the history
Add Apple Silicion support in XCFramework
  • Loading branch information
migueldeicaza authored May 29, 2023
2 parents 0b13cf7 + 527e752 commit 2e8939b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 18 deletions.
11 changes: 9 additions & 2 deletions scripts/make-swiftgodot-framework
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,19 @@ esac

rm -rf $2
bdMac=$1/Build/Products/Debug/
bdMacArm="$(echo "$1" | rev | cut -c2- | rev)_arm/Build/Products/Debug/"
bdiOS=$1/Build/Products/Debug-iphoneos/
xcodebuild -create-xcframework -framework $bdMac/PackageFrameworks/SwiftGodot.framework -framework $bdiOS/PackageFrameworks/SwiftGodot.framework -output $2
fd=$2//macos-x86_64/SwiftGodot.framework
mkdir universal
echo $bdMacArm
cp -rf $bdMacArm/PackageFrameworks/SwiftGodot.framework universal/
lipo -create -output ./universal/SwiftGodot.framework/SwiftGodot $bdMac/PackageFrameworks/SwiftGodot.framework/SwiftGodot $bdMacArm/PackageFrameworks/SwiftGodot.framework/SwiftGodot
xcodebuild -create-xcframework -framework ./universal/SwiftGodot.framework -framework $bdiOS/PackageFrameworks/SwiftGodot.framework -output $2
rm -rf ./universal
fd=$2//macos-arm64_x86_64/SwiftGodot.framework
(cd $fd; mkdir -p Versions/Current/Headers; ln -sf Versions/Current/Headers .)
(cd $fd; mkdir -p Versions/Current/Modules; ln -sf Versions/Current/Modules .)
rsync -a $bdMac/SwiftGodot.swiftmodule $fd/Versions/Current/Modules/
rsync -a $bdMacArm/SwiftGodot.swiftmodule $fd/Versions/Current/Modules/

cat > $fd/Modules/module.modulemap << EOF
framework module SwiftGodot {
Expand Down
41 changes: 25 additions & 16 deletions scripts/release
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,25 @@ if test ! -e scripts/make-swiftgodot-framework; then
echo expected this to run from the SwiftGodot directory
exit 1
fi
if test ! -e ../SwiftGodotBinary; then
echo expected to have a peer directory SwiftGodotBinary to publish results
exit 1
fi

case $1 in
v*)
echo Tagging with $1
git tag $1
tag=$1
;;
*)
echo "version to tag should be vXXX"
exit 1
;;
esac
if [ -z "$SWIFT_GODOT_NODEPLOY" ]; then
if test ! -e ../SwiftGodotBinary; then
echo expected to have a peer directory SwiftGodotBinary to publish results
exit 1
fi

case $1 in
v*)
echo Tagging with $1
git tag $1
tag=$1
;;
*)
echo "version to tag should be vXXX"
exit 1
;;
esac
fi

outputDir=$HOME/sg-builds
dir=$outputDir/$$-build
Expand All @@ -42,9 +45,15 @@ echo DerivedData: $derivedData
echo ArchiveData: $archivePath

xcodebuild -scheme SwiftGodot -destination platform=generic/macOS,arch=x86_64 -derivedDataPath $derivedData -archivePath $archivePath >& $dir/x86_64.log
xcodebuild -scheme SwiftGodot -destination platform=generic/macOS,arch=arm64 -derivedDataPath "${derivedData}_arm" -archivePath $archivePath >& $dir/arm64.log
xcodebuild -scheme SwiftGodot -destination generic/platform=iOS -derivedDataPath $derivedData -archivePath $archivePath >& $dir/arm64.log
sh scripts/make-swiftgodot-framework $dir/derived/ $outputDir/SwiftGodot.xcframework

if [ ! -z "$SWIFT_GODOT_NODEPLOY" ]; then
echo "Skipping deployment stage."
exit
fi

(cd $outputDir; zip --symlinks -ru SwiftGodot.xcframework.zip SwiftGodot.xcframework)
csum=`swift package compute-checksum $outputDir/SwiftGodot.xcframework.zip`

Expand All @@ -71,4 +80,4 @@ let package = Package(
)
EOF

(cd ../SwiftGodotBinary; git tag $tag; git commit -m "Update to $tag" -a; git push)
(cd ../SwiftGodotBinary; git tag $tag; git commit -m "Update to $tag" -a; git push)

0 comments on commit 2e8939b

Please sign in to comment.