forked from mozilla/application-services
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-all-ios.sh
executable file
·82 lines (74 loc) · 2.77 KB
/
build-all-ios.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env bash
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" "arm64-sim")
if [[ "${#}" -ne 1 ]]
then
echo "Usage:"
echo "./build-all-ios.sh <NSS_SRC_PATH>"
exit 1
fi
NSS_SRC_PATH=${1}
function universal_lib() {
DIR_NAME="${1}"
LIB_NAME="${2}"
shift; shift
UNIVERSAL_DIR="ios/universal/${DIR_NAME}"
LIB_PATH="${UNIVERSAL_DIR}/lib/${LIB_NAME}"
if [[ ! -e "${LIB_PATH}" ]]; then
mkdir -p "${UNIVERSAL_DIR}/lib"
CMD="lipo"
for ARCH in "${@}"; do
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}
fi
}
echo "# Building NSS"
for i in "${!TARGET_ARCHS[@]}"; do
ARCH=${TARGET_ARCHS[${i}]}
DIST_DIR=$(abspath "ios/${ARCH}/nss")
if [[ -d "${DIST_DIR}" ]]; then
echo "${DIST_DIR} already exists. Skipping building nss."
else
./build-nss-ios.sh "${NSS_SRC_PATH}" "${DIST_DIR}" "${ARCH}" "${IOS_MIN_SDK_VERSION}" || exit 1
fi
done
universal_lib "nss" "libcertdb.a" "${TARGET_ARCHS[@]}"
universal_lib "nss" "libfreebl_static.a" "${TARGET_ARCHS[@]}"
universal_lib "nss" "libnssb.a" "${TARGET_ARCHS[@]}"
universal_lib "nss" "libnssutil.a" "${TARGET_ARCHS[@]}"
universal_lib "nss" "libpkcs7.a" "${TARGET_ARCHS[@]}"
universal_lib "nss" "libsmime.a" "${TARGET_ARCHS[@]}"
universal_lib "nss" "libcerthi.a" "${TARGET_ARCHS[@]}"
universal_lib "nss" "libnspr4.a" "${TARGET_ARCHS[@]}"
universal_lib "nss" "libnssdev.a" "${TARGET_ARCHS[@]}"
universal_lib "nss" "libpk11wrap_static.a" "${TARGET_ARCHS[@]}"
universal_lib "nss" "libplc4.a" "${TARGET_ARCHS[@]}"
universal_lib "nss" "libsoftokn_static.a" "${TARGET_ARCHS[@]}"
universal_lib "nss" "libcryptohi.a" "${TARGET_ARCHS[@]}"
universal_lib "nss" "libnss_static.a" "${TARGET_ARCHS[@]}"
universal_lib "nss" "libnsspki.a" "${TARGET_ARCHS[@]}"
universal_lib "nss" "libpkcs12.a" "${TARGET_ARCHS[@]}"
universal_lib "nss" "libplds4.a" "${TARGET_ARCHS[@]}"
universal_lib "nss" "libssl.a" "${TARGET_ARCHS[@]}"
universal_lib "nss" "libhw-acc-crypto-avx.a" "x86_64"
universal_lib "nss" "libhw-acc-crypto-avx2.a" "x86_64"
universal_lib "nss" "libgcm-aes-x86_c_lib.a" "x86_64"
universal_lib "nss" "libsha-x86_c_lib.a" "x86_64"
universal_lib "nss" "libgcm-aes-aarch64_c_lib.a" "arm64"
universal_lib "nss" "libarmv8_c_lib.a" "arm64"
HEADER_DIST_DIR="ios/universal/nss/include/nss"
if [[ ! -e "${HEADER_DIST_DIR}" ]]; then
mkdir -p ${HEADER_DIST_DIR}
# Choice of arm64 is arbitrary, it shouldn't matter.
HEADER_SRC_DIR=$(abspath "ios/arm64/nss/include/nss")
cp -L "${HEADER_SRC_DIR}"/*.h "${HEADER_DIST_DIR}"
fi
echo "# Ensure Glean checkout"
git submodule update --init