Last active
July 19, 2025 16:06
-
-
Save sunnyyoung/68450a1988d7649afa68a3fe2b70c05f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/zsh | |
| set -e | |
| declare -r VERSION="20220613" | |
| declare -r SRC="$(pwd)/boringssl" | |
| declare -r DST="$(pwd)/boringssl.builds" | |
| declare -Ar ALL_PLATFORMS=( | |
| [MacOSX]="macOS" | |
| [iPhoneOS]="iOS" | |
| [iPhoneSimulator]="iOS" | |
| [AppleTVOS]="tvOS" | |
| [AppleTVSimulator]="tvOS" | |
| [XROS]="visionOS" | |
| [XRSimulator]="visionOS" | |
| ) | |
| declare -Ar ALL_ARCHS=( | |
| [MacOSX]="x86_64 arm64" | |
| [iPhoneOS]="arm64" | |
| [iPhoneSimulator]="x86_64 arm64" | |
| [AppleTVOS]="arm64" | |
| [AppleTVSimulator]="x86_64 arm64" | |
| [XROS]="arm64" | |
| [XRSimulator]="arm64" | |
| ) | |
| declare -Ar ALL_DEPLOYMENT_TARGETS=( | |
| [MacOSX]="10.11" | |
| [iPhoneOS]="9.0" | |
| [iPhoneSimulator]="9.0" | |
| [AppleTVOS]="9.0" | |
| [AppleTVSimulator]="9.0" | |
| [XROS]="1.0" | |
| [XRSimulator]="1.0" | |
| ) | |
| declare -Ar ALL_DESTINATIONS=( | |
| [MacOSX]="generic/platform=macOS" | |
| [iPhoneOS]="generic/platform=iOS" | |
| [iPhoneSimulator]="generic/platform=iOS Simulator" | |
| [AppleTVOS]="generic/platform=tvOS" | |
| [AppleTVSimulator]="generic/platform=tvOS Simulator" | |
| [XROS]="generic/platform=visionOS" | |
| [XRSimulator]="generic/platform=visionOS Simulator" | |
| ) | |
| echo "checking out boringssl..." | |
| if [ -d "${SRC}" ] || [ -d "${DST}" ]; then | |
| echo "source or destination folder not empty." && exit 1 | |
| else | |
| git clone "https://boringssl.googlesource.com/boringssl" --depth 1 --branch "fips-${VERSION}" | |
| sed \ | |
| -i '' \ | |
| 's/ set(C_CXX_FLAGS "${C_CXX_FLAGS} -Wall -fvisibility=hidden -fno-common")/ set(C_CXX_FLAGS "${C_CXX_FLAGS} -Wall -fno-common")/' \ | |
| "boringssl/CMakeLists.txt" | |
| fi | |
| for platform in ${PLATFORMS:-${(k)ALL_PLATFORMS}}; do | |
| for arch in ${ARCHS:-${=ALL_ARCHS[${platform}]}}; do | |
| echo "building libraries for ${platform}-${arch}..." | |
| mkdir -p "${DST}/${platform}-${arch}" | |
| pushd "${DST}/${platform}-${arch}" | |
| cmake \ | |
| -S "${SRC}" \ | |
| -DCMAKE_OSX_SYSROOT="$(xcrun --sdk ${(L)platform} --show-sdk-path)" \ | |
| -DCMAKE_OSX_ARCHITECTURES="${arch}" \ | |
| -DCMAKE_OSX_DEPLOYMENT_TARGET="${ALL_DEPLOYMENT_TARGETS[$platform]}" \ | |
| -DCMAKE_BUILD_TYPE=Release | |
| cmake \ | |
| --build . \ | |
| --parallel "$(sysctl -n hw.ncpu)" | |
| cmake \ | |
| --install . \ | |
| --prefix . | |
| popd | |
| done | |
| done | |
| echo "creating static xcframework..." | |
| pushd "${DST}" | |
| local args=() | |
| for platform in ${PLATFORMS:-${(k)ALL_PLATFORMS}}; do | |
| mkdir -p "libs/${platform}" | |
| libtool \ | |
| -static $(find ${platform}-*/lib -name "*.a") \ | |
| -o "libs/${platform}/libopenssl.a" | |
| args+=(-library "libs/${platform}/libopenssl.a") | |
| done | |
| xcodebuild -create-xcframework "${args[@]}" -output libopenssl.xcframework | |
| zip -ry9 libopenssl.xcframework.zip libopenssl.xcframework | |
| popd | |
| echo "creating dynamic xcframework..." | |
| echo " | |
| name: openssl | |
| options: | |
| deploymentTarget: | |
| macOS: 10.11 | |
| iOS: 9.0 | |
| tvOS: 9.0 | |
| visionOS: 1.0 | |
| targets: | |
| openssl: | |
| type: framework | |
| supportedDestinations: [ | |
| macOS, | |
| iOS, | |
| tvOS, | |
| visionOS | |
| ] | |
| settings: | |
| SKIP_INSTALL: NO | |
| DEFINES_MODULE: NO | |
| CODE_SIGNING_ALLOWED: NO | |
| GENERATE_INFOPLIST_FILE: YES | |
| BUILD_LIBRARY_FOR_DISTRIBUTION: YES | |
| OTHER_LDFLAGS: -all_load | |
| MARKETING_VERSION: ${VERSION} | |
| PRODUCT_BUNDLE_IDENTIFIER: framework.openssl | |
| sources: | |
| - path: ${SRC}/include | |
| buildPhase: headers | |
| headerVisibility: public | |
| dependencies: | |
| - framework: libopenssl.xcframework | |
| aggregateTargets: | |
| aggregate: | |
| buildScripts: | |
| - name: Create xcframework | |
| script: | | |
| xcodebuild archive \ | |
| -scheme openssl \ | |
| -destination 'generic/platform=macOS' \ | |
| -archivePath archives/openssl_macOS.xcarchive | |
| xcodebuild archive \ | |
| -scheme openssl \ | |
| -destination 'generic/platform=iOS' \ | |
| -archivePath archives/openssl_iOS.xcarchive | |
| xcodebuild archive \ | |
| -scheme openssl \ | |
| -destination 'generic/platform=iOS Simulator' \ | |
| -archivePath archives/openssl_iOS_Simulator.xcarchive | |
| xcodebuild archive \ | |
| -scheme openssl \ | |
| -destination 'generic/platform=tvOS' \ | |
| -archivePath archives/openssl_tvOS.xcarchive | |
| xcodebuild archive \ | |
| -scheme openssl \ | |
| -destination 'generic/platform=tvOS Simulator' \ | |
| -archivePath archives/openssl_tvOS_Simulator.xcarchive | |
| xcodebuild archive \ | |
| -scheme openssl \ | |
| -destination 'generic/platform=visionOS' \ | |
| -archivePath archives/openssl_visionOS.xcarchive | |
| xcodebuild archive \ | |
| -scheme openssl \ | |
| -destination 'generic/platform=visionOS Simulator' \ | |
| -archivePath archives/openssl_visionOS_Simulator.xcarchive | |
| xcodebuild -create-xcframework \ | |
| -archive 'archives/openssl_macOS.xcarchive' -framework openssl.framework \ | |
| -archive 'archives/openssl_iOS.xcarchive' -framework openssl.framework \ | |
| -archive 'archives/openssl_iOS_Simulator.xcarchive' -framework openssl.framework \ | |
| -archive 'archives/openssl_tvOS.xcarchive' -framework openssl.framework \ | |
| -archive 'archives/openssl_tvOS_Simulator.xcarchive' -framework openssl.framework \ | |
| -archive 'archives/openssl_visionOS.xcarchive' -framework openssl.framework \ | |
| -archive 'archives/openssl_visionOS_Simulator.xcarchive' -framework openssl.framework \ | |
| -output openssl.xcframework | |
| " > "${DST}/project.yml" | |
| pushd "${DST}" | |
| xcodegen && xcodebuild build -scheme aggregate | |
| zip -ry9 openssl.xcframework.zip openssl.xcframework | |
| popd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment