|
1 | 1 | export REPO_ROOT=`pwd` |
2 | 2 | export PATH=$PATH:$REPO_ROOT/tools/bin |
3 | 3 |
|
4 | | -# There are limitations in `xcodebuild` command that disallow maccatalyst and maccatalyst-arm64 |
5 | | -# to be used simultaneously: Doing that and we will get an error |
6 | | -# |
7 | | -# Both ios-x86_64-maccatalyst and ios-arm64-maccatalyst represent two equivalent library definitions. |
8 | | -# |
9 | | -# To provide binary for both, `lipo` is probably needed. |
10 | | -# Likewise, `maccatalyst` and `macosx` cannot be used together. So unfortunately for now, one will |
11 | | -# needs multiple xcframeworks for x86_64-based and ARM-based Mac development computer. |
12 | | - |
13 | | -# maccatalyst-arm64 macosx macosx-arm64 |
14 | | -#if [[ $(arch) == 'arm64' ]]; then |
15 | | -AVAILABLE_PLATFORMS=(iphoneos iphonesimulator-arm64 maccatalyst-arm64) |
16 | | -#else |
17 | | -#AVAILABLE_PLATFORMS=(iphoneos iphonesimulator maccatalyst) |
18 | | -#fi |
| 4 | +# List of platforms-architecture that we support |
| 5 | +# Note that there are limitations in `xcodebuild` command that disallows `maccatalyst` and `macosx` (native macOS lib) in the same xcframework. |
| 6 | +AVAILABLE_PLATFORMS=(iphoneos iphonesimulator iphonesimulator-arm64 maccatalyst maccatalyst-arm64) # macosx macosx-arm64 |
| 7 | + |
| 8 | +# List of frameworks included in the XCFramework (= AVAILABLE_PLATFORMS without architecture specifications) |
| 9 | +XCFRAMEWORK_PLATFORMS=(iphoneos iphonesimulator maccatalyst) |
| 10 | + |
| 11 | +# List of platforms that need to be merged using lipo due to presence of multiple architectures |
| 12 | +LIPO_PLATFORMS=(iphonesimulator maccatalyst) |
19 | 13 |
|
20 | 14 | # Download build tools |
21 | 15 | test -d tools || wget -q https://github.com/light-tech/LLVM-On-iOS/releases/download/llvm12.0.0/tools.tar.xz |
@@ -57,10 +51,10 @@ function setup_variables() { |
57 | 51 | SYSROOT=`xcodebuild -version -sdk iphonesimulator Path` |
58 | 52 | CMAKE_ARGS+=(-DCMAKE_OSX_ARCHITECTURES=$ARCH -DCMAKE_OSX_SYSROOT=$SYSROOT);; |
59 | 53 |
|
60 | | - "iphonesimulator-arm64") |
61 | | - ARCH=arm64 |
62 | | - SYSROOT=`xcodebuild -version -sdk iphonesimulator Path` |
63 | | - CMAKE_ARGS+=(-DCMAKE_OSX_ARCHITECTURES=$ARCH -DCMAKE_OSX_SYSROOT=$SYSROOT);; |
| 54 | + "iphonesimulator-arm64") |
| 55 | + ARCH=arm64 |
| 56 | + SYSROOT=`xcodebuild -version -sdk iphonesimulator Path` |
| 57 | + CMAKE_ARGS+=(-DCMAKE_OSX_ARCHITECTURES=$ARCH -DCMAKE_OSX_SYSROOT=$SYSROOT);; |
64 | 58 |
|
65 | 59 | "maccatalyst") |
66 | 60 | ARCH=x86_64 |
@@ -123,7 +117,7 @@ function build_openssl() { |
123 | 117 |
|
124 | 118 | "iphonesimulator"|"iphonesimulator-arm64") |
125 | 119 | TARGET_OS=iossimulator-xcrun |
126 | | - export CFLAGS="-isysroot $SYSROOT";; |
| 120 | + export CFLAGS="-isysroot $SYSROOT -arch $ARCH";; |
127 | 121 |
|
128 | 122 | "maccatalyst"|"maccatalyst-arm64") |
129 | 123 | TARGET_OS=darwin64-$ARCH-cc |
@@ -237,8 +231,15 @@ for p in ${AVAILABLE_PLATFORMS[@]}; do |
237 | 231 | libtool -static -o libgit2.a lib/*.a |
238 | 232 | done |
239 | 233 |
|
| 234 | +# Merge the libgit2.a for iphonesimulator & iphonesimulator-arm64 as well as maccatalyst & maccatalyst-arm64 using lipo |
| 235 | +for p in ${LIPO_PLATFORMS[@]}; do |
| 236 | + cd $REPO_ROOT/install/$p |
| 237 | + lipo libgit2.a ../$p-arm64/libgit2.a -output libgit2_all_archs.a -create |
| 238 | + test -f libgit2_all_archs.a && rm libgit2.a && mv libgit2_all_archs.a libgit2.a |
| 239 | +done |
| 240 | + |
240 | 241 | # Build raw libgit2 XCFramework for Objective-C usage |
241 | | -build_xcframework libgit2 ${AVAILABLE_PLATFORMS[@]} |
| 242 | +build_xcframework libgit2 ${XCFRAMEWORK_PLATFORMS[@]} |
242 | 243 | zip -r libgit2.xcframework.zip libgit2.xcframework/ |
243 | 244 |
|
244 | 245 | # Build Clibgit2 XCFramework for use with SwiftGit2 |
|
0 commit comments