Build NSS for iPhoneSimulator target

This commit is contained in:
Sammy Khamis 2023-07-13 14:26:01 -10:00
Родитель ccdeb10953
Коммит fa6ea561e2
3 изменённых файлов: 20 добавлений и 4 удалений

Просмотреть файл

@ -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}

Просмотреть файл

@ -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)

Просмотреть файл

@ -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;;