Skip to content

Commit

Permalink
chore: testing ios with catalyst support
Browse files Browse the repository at this point in the history
  • Loading branch information
jerson committed May 24, 2024
1 parent 2101e67 commit 27346e6
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 18 deletions.
41 changes: 27 additions & 14 deletions Makefile.ios
Original file line number Diff line number Diff line change
Expand Up @@ -7,46 +7,59 @@ binding_ios: binding_ios_arm64 binding_ios_x86_64_sim
cp $(IOS_BINDING_OUTPUT)/arm64/*.h $(IOS_BINDING_OUTPUT)
rm -rf $(IOS_BINDING_OUTPUT)/arm64 $(IOS_BINDING_OUTPUT)/x86_64_sim $(IOS_BINDING_OUTPUT)/armv7

binding_ios_test: binding_ios_arm64 binding_ios_all_sim
lipo $(IOS_BINDING_OUTPUT)/sim/$(IOS_BINDING_NAME) $(IOS_BINDING_OUTPUT)/arm64/$(IOS_BINDING_NAME) -create -output $(IOS_BINDING_OUTPUT)/$(IOS_BINDING_NAME)
cp $(IOS_BINDING_OUTPUT)/arm64/*.h $(IOS_BINDING_OUTPUT)
rm -rf $(IOS_BINDING_OUTPUT)/arm64

binding_ios_xcframework: binding_ios_arm64 binding_ios_all_sim
binding_ios_xcframework: binding_ios_all_iphone binding_ios_all_sim binding_ios_all_catalyst
mkdir -p $(IOS_BINDING_OUTPUT)/headers
cp $(IOS_BINDING_OUTPUT)/arm64/*.h $(IOS_BINDING_OUTPUT)/headers
rm -rf $(IOS_BINDING_OUTPUT)/Openpgp.xcframework
xcodebuild -create-xcframework \
-library $(IOS_BINDING_OUTPUT)/arm64/$(IOS_BINDING_NAME) -headers $(IOS_BINDING_OUTPUT)/headers \
-library $(IOS_BINDING_OUTPUT)/sim/$(IOS_BINDING_NAME) -headers $(IOS_BINDING_OUTPUT)/headers \
-library $(IOS_BINDING_OUTPUT)/catalyst/$(IOS_BINDING_NAME) -headers $(IOS_BINDING_OUTPUT)/headers \
-output $(IOS_BINDING_OUTPUT)/Openpgp.xcframework
rm -rf $(IOS_BINDING_OUTPUT)/arm64 $(IOS_BINDING_OUTPUT)/sim $(IOS_BINDING_OUTPUT)/headers
rm -rf $(IOS_BINDING_OUTPUT)/arm64 $(IOS_BINDING_OUTPUT)/sim $(IOS_BINDING_OUTPUT)/catalyst $(IOS_BINDING_OUTPUT)/headers

binding_ios_arm64:
BINDING_FILE=$(IOS_OUTPUT)/arm64/$(IOS_BINDING_NAME) BUILD_MODE="c-archive" \
SDK=iphoneos CC=$(PWD)/clangwrap.sh CGO_CFLAGS="-fembed-bitcode" \
GOOS=ios GOARCH=arm64 CGO_ENABLED=1 \
make binding
binding_ios_all_iphone: binding_ios_arm64

binding_ios_all_sim: binding_ios_x86_64_sim binding_ios_arm64_sim
mkdir -p $(IOS_BINDING_OUTPUT)/sim
lipo $(IOS_BINDING_OUTPUT)/x86_64_sim/$(IOS_BINDING_NAME) $(IOS_BINDING_OUTPUT)/arm64_sim/$(IOS_BINDING_NAME) -create -output $(IOS_BINDING_OUTPUT)/sim/$(IOS_BINDING_NAME)
rm -rf $(IOS_BINDING_OUTPUT)/x86_64_sim $(IOS_BINDING_OUTPUT)/arm64_sim

binding_ios_all_catalyst: binding_ios_x86_64_catalyst binding_ios_arm64_catalyst
mkdir -p $(IOS_BINDING_OUTPUT)/catalyst
lipo $(IOS_BINDING_OUTPUT)/x86_64_catalyst/$(IOS_BINDING_NAME) $(IOS_BINDING_OUTPUT)/arm64_catalyst/$(IOS_BINDING_NAME) -create -output $(IOS_BINDING_OUTPUT)/catalyst/$(IOS_BINDING_NAME)
rm -rf $(IOS_BINDING_OUTPUT)/x86_64_catalyst $(IOS_BINDING_OUTPUT)/arm64_catalyst

binding_ios_x86_64_catalyst:
BINDING_FILE=$(IOS_OUTPUT)/x86_64_catalyst/$(IOS_BINDING_NAME) BUILD_MODE="c-archive" \
SDK=macosx CC=$(PWD)/clangwrap.sh \
GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 \
make binding

binding_ios_arm64_catalyst:
BINDING_FILE=$(IOS_OUTPUT)/arm64_catalyst/$(IOS_BINDING_NAME) BUILD_MODE="c-archive" \
SDK=macosx CC=$(PWD)/clangwrap.sh \
GOOS=darwin GOARCH=arm64 CGO_ENABLED=1 \
make binding

binding_ios_x86_64_sim:
CGO_LDFLAGS="-target arm64-apple-ios10-simulator" \
BINDING_FILE=$(IOS_OUTPUT)/x86_64_sim/$(IOS_BINDING_NAME) BUILD_MODE="c-archive" \
SDK=iphonesimulator CC=$(PWD)/clangwrap.sh \
GOOS=ios GOARCH=amd64 CGO_ENABLED=1 \
make binding

binding_ios_arm64_sim:
CGO_LDFLAGS="-target arm64-apple-ios10-simulator" \
BINDING_FILE=$(IOS_OUTPUT)/arm64_sim/$(IOS_BINDING_NAME) BUILD_MODE="c-archive" \
SDK=iphonesimulator CC=$(PWD)/clangwrap.sh \
GOOS=ios GOARCH=arm64 CGO_ENABLED=1 \
make binding

binding_ios_arm64:
BINDING_FILE=$(IOS_OUTPUT)/arm64/$(IOS_BINDING_NAME) BUILD_MODE="c-archive" \
SDK=iphoneos CC=$(PWD)/clangwrap.sh CGO_CFLAGS="-fembed-bitcode" \
GOOS=ios GOARCH=arm64 CGO_ENABLED=1 \
make binding

binding_ios_armv7:
BINDING_FILE=$(IOS_OUTPUT)/armv7/$(IOS_BINDING_NAME) BUILD_MODE="c-archive" \
SDK=iphoneos CC=$(PWD)/clangwrap.sh CGO_CFLAGS="-fembed-bitcode" \
Expand Down
17 changes: 13 additions & 4 deletions clangwrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

SDK_PATH=`xcrun --sdk $SDK --show-sdk-path`
CLANG=`xcrun --sdk $SDK --find clang`
MIN_VERSION=10
IOS_TARGET=10
EXTRA_ARGS=""

if [ "$GOARCH" == "amd64" ]; then
CARCH="x86_64"
Expand All @@ -17,9 +18,17 @@ elif [ "$GOARCH" == "386" ]; then
fi

if [ "$SDK" = "iphoneos" ]; then
TARGET="$CARCH-apple-ios$MIN_VERSION"
EXTRA_ARGS="-fembed-bitcode -miphoneos-version-min==$IOS_TARGET"
TARGET="$CARCH-apple-ios$IOS_TARGET"
elif [ "$SDK" = "iphonesimulator" ]; then
TARGET="$CARCH-apple-ios$MIN_VERSION-simulator"
EXTRA_ARGS="-fembed-bitcode -mios-simulator-version-min=$IOS_TARGET"
TARGET="$CARCH-apple-ios$IOS_TARGET-simulator"
elif [ "$SDK" = "macosx" ]; then
IOS_TARGET=14
TARGET="$CARCH-apple-ios$IOS_TARGET-macabi"
if [ "$GOARCH" == "arm64" ]; then
EXTRA_ARGS="-fembed-bitcode"
fi
fi

exec $CLANG -arch $CARCH -target $TARGET -isysroot $SDK_PATH "$@"
exec $CLANG -target $TARGET $EXTRA_ARGS -isysroot $SDK_PATH "$@"

0 comments on commit 27346e6

Please sign in to comment.