blob: 655d27e29a71ebc66d38b5c215dd5dafe50a2f23 [file] [log] [blame]
#!/bin/bash
set -o errtrace
trap 'echo Fatal error: script $0 aborting at line $LINENO, command \"$BASH_COMMAND\" returned $?; exit 1' ERR
# Build agnostic variables
readonly LOCAL_PATH=external/nss
if [ ! -d "${LOCAL_PATH}" ]; then
echo "Must be run from Eureka root"
exit 1
fi
export CURDIR=${PWD}
export NSS_SRC_TAR_GZ=${LOCAL_PATH}/nss-3.73-with-nspr-4.32.tar.gz
export NSS_TOP_DIR=nss-3.73
readonly GENERIC_CFLAGS="\
-Wa,--noexecstack \
-Werror=format-security \
-fno-short-enums \
-D_FORTIFY_SOURCE=2 \
-fPIC \
-Wno-psabi \
-Wall \
-Wno-unused \
-Winit-self \
-Wpointer-arith \
-Werror=return-type \
-Wnon-virtual-dtor \
-Werror=address \
-Werror=sequence-point \
-fgcse-after-reload \
-frerun-cse-after-loop \
-frename-registers \
-fomit-frame-pointer \
-fstrict-aliasing"
export TARGET_LDFLAGS="\
-static-libstdc++ \
-static-libgcc \
-Wl,-z,noexecstack \
-Wl,-z,relro,-z,now \
-Wl,--hash-style=both \
-ldl \
-lc \
-lrt \
-lpthread"
# Set build specific variables and execute build script
build_nss() {
DEVICE_TYPE=$1
export TARGET_ARCH=$2
SYSROOT_SOURCE=$3
export TARGET_CC=$4
export TARGET_CCC=$5
export TARGET_AR=$6
local PREBUILT_DIR=${LOCAL_PATH}/prebuilt/${TARGET_ARCH}
export TARGET_CFLAGS="${GENERIC_CFLAGS} $7"
export TARGET_OUT=${LOCAL_PATH}/out/${DEVICE_TYPE}
export HOST_OUT=${LOCAL_PATH}/out/host
TARGET_SYSROOT=${TARGET_OUT}/build_sysroot
export INSTALL_SYSROOT=${PREBUILT_DIR}/${DEVICE_TYPE}/files
mkdir -p ${HOST_OUT} ${TARGET_SYSROOT}
# Install the sysroot
rsync -a ${SYSROOT_SOURCE}/ ${TARGET_SYSROOT} --delete-excluded
# Update the sysroot
rsync -a ${PREBUILT_DIR}/${DEVICE_TYPE}/sysroot/ ${TARGET_SYSROOT}
${LOCAL_PATH}/build.sh
}
readonly armv7a_sysroot=prebuilt/toolchain/armv7a/usr/armv7a-cros-linux-gnueabihf
readonly armv7a_CC=prebuilt/toolchain/armv7a/bin/armv7a-cros-linux-gnueabihf-gcc
readonly armv7a_CCC=prebuilt/toolchain/armv7a/bin/armv7a-cros-linux-gnueabihf-g++
readonly armv7a_AR=prebuilt/toolchain/armv7a/bin/armv7a-cros-linux-gnueabihf-ar
readonly armv7a_ARCH=arm
readonly armv7a_CFLAGS=${GENERIC_CFLAGS}
readonly aarch64_sysroot=prebuilt/toolchain/aarch64/usr/aarch64-cros-linux-gnu
readonly aarch64_CC=prebuilt/toolchain/aarch64/bin/aarch64-cros-linux-gnu-gcc
readonly aarch64_CCC=prebuilt/toolchain/aarch64/bin/aarch64-cros-linux-gnu-g++
readonly aarch64_AR=prebuilt/toolchain/aarch64/bin/aarch64-cros-linux-gnu-ar
readonly aarch64_ARCH=aarch64
readonly aarch64_CFLAGS="${GENERIC_CFLAGS} -march=armv8-a -Wno-overflow -Wno-missing-braces -DNSS_USE_64 -DUSE_64"
build_nss armv7-a-neon ${armv7a_ARCH} ${armv7a_sysroot} ${armv7a_CC} \
${armv7a_CCC} ${armv7a_AR} "${armv7a_CFLAGS} -mfpu=neon"
build_nss armv7-a ${armv7a_ARCH} ${armv7a_sysroot} ${armv7a_CC} \
${armv7a_CCC} ${armv7a_AR} "${armv7a_CFLAGS} "
build_nss armv8-a-neon ${armv7a_ARCH} ${armv7a_sysroot} ${armv7a_CC} \
${armv7a_CCC} ${armv7a_AR} \
"${armv7a_CFLAGS} -march=armv8-a -mfpu=crypto-neon-fp-armv8"
build_nss armv8-a-neon ${aarch64_ARCH} ${aarch64_sysroot} ${aarch64_CC} \
${aarch64_CCC} ${aarch64_AR} "${aarch64_CFLAGS} "
# Skip the vendor portion. As of right now. There are no vendors needing NSS
# prebuilts.
exit
# Some vendors build nss with custom toolchains. Find scripts in the vendor
# directories named update_nss_prebuilts.sh and run them to update the prebuilt
# binaries. Note that the resulting binaries may end up in a vendor project.
# Please do not forget to submit the updated binaries to git.
for vendor_script in `find vendor/ -name update_nss_prebuilts.sh`; do
echo "Running ${vendor_script}";
$vendor_script;
done;