From fa6ea561e2b4796c5297485ffb8864015469d126 Mon Sep 17 00:00:00 2001 From: Sammy Khamis Date: Thu, 13 Jul 2023 14:26:01 -1000 Subject: [PATCH] Build NSS for iPhoneSimulator target --- libs/build-all-ios.sh | 7 +++++-- libs/build-nss-ios.sh | 13 ++++++++++++- megazords/ios-rust/build-xcframework.sh | 4 +++- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/libs/build-all-ios.sh b/libs/build-all-ios.sh index 5db17b6e3..40057002f 100755 --- a/libs/build-all-ios.sh +++ b/libs/build-all-ios.sh @@ -2,9 +2,10 @@ set -euvx +# This probably needs to be updated, but also includes the toolchain? IOS_MIN_SDK_VERSION="11.0" # Our short-names for the architectures. -TARGET_ARCHS=("x86_64" "arm64") +TARGET_ARCHS=("x86_64" "arm64" "arm64-sim") if [[ "${#}" -ne 1 ]] then @@ -25,7 +26,9 @@ function universal_lib() { mkdir -p "${UNIVERSAL_DIR}/lib" CMD="lipo" for ARCH in "${@}"; do - CMD="${CMD} -arch ${ARCH} ios/${ARCH}/${DIR_NAME}/lib/${LIB_NAME}" + if [[ "${ARCH}" != "arm64-sim" ]]; then + CMD="${CMD} -arch ${ARCH} ios/${ARCH}/${DIR_NAME}/lib/${LIB_NAME}" + fi done CMD="${CMD} -output ${LIB_PATH} -create" ${CMD} diff --git a/libs/build-nss-ios.sh b/libs/build-nss-ios.sh index e00ffc0e9..75b6abc84 100755 --- a/libs/build-nss-ios.sh +++ b/libs/build-nss-ios.sh @@ -25,10 +25,21 @@ if [[ "${ARCH}" == "x86_64" ]]; then OS_COMPILER="iPhoneSimulator" TARGET="x86_64-apple-darwin" GYP_ARCH="x64" + EXTRA_TARGET="x86_64-apple-ios-simulator" elif [[ "${ARCH}" == "arm64" ]]; then OS_COMPILER="iPhoneOS" TARGET="aarch64-apple-darwin" GYP_ARCH="arm64" + EXTRA_TARGET="arm64-apple-ios" +elif [[ "${ARCH}" == "arm64-sim" ]]; then + # We need to build nss for M1 sims ahead of time + OS_COMPILER="iPhoneSimulator" + TARGET="aarch64-apple-darwin" + GYP_ARCH="arm64" + # ARCH is used further down the line, but arm64-sim doesn't exist so we swap it back + # to the original + ARCH="arm64" + EXTRA_TARGET="arm64-apple-ios-simulator" else echo "Unsupported architecture" exit 1 @@ -39,7 +50,7 @@ CROSS_TOP="${DEVELOPER}/Platforms/${OS_COMPILER}.platform/Developer" CROSS_SDK="${OS_COMPILER}.sdk" TOOLCHAIN_BIN="${DEVELOPER}/Toolchains/XcodeDefault.xctoolchain/usr/bin" ISYSROOT="${CROSS_TOP}/SDKs/${CROSS_SDK}" -CC="${TOOLCHAIN_BIN}/clang -arch ${ARCH} -isysroot ${ISYSROOT} -mios-version-min=${IOS_MIN_SDK_VERSION}" +CC="${TOOLCHAIN_BIN}/clang -target ${EXTRA_TARGET} -arch ${ARCH} -isysroot ${ISYSROOT} -mios-version-min=${IOS_MIN_SDK_VERSION}" # Build NSPR NSPR_BUILD_DIR=$(mktemp -d) diff --git a/megazords/ios-rust/build-xcframework.sh b/megazords/ios-rust/build-xcframework.sh index fed6fea1b..0d0788f3f 100755 --- a/megazords/ios-rust/build-xcframework.sh +++ b/megazords/ios-rust/build-xcframework.sh @@ -77,7 +77,9 @@ cargo_build () { case $TARGET in x86_64*) LIBS_DIR="$REPO_ROOT/libs/ios/x86_64";; - aarch64*) + aarch64-apple-ios-sim) + LIBS_DIR="$REPO_ROOT/libs/ios/arm64-sim";; + aarch64-apple-ios) LIBS_DIR="$REPO_ROOT/libs/ios/arm64";; *) echo "Unexpected target architecture: $TARGET" && exit 1;;