33set -eu
44set -o pipefail
55
6- export MASON_RELEASE=" ${MASON_RELEASE:- v0.14.1} "
7- export MASON_LLVM_RELEASE=" ${MASON_LLVM_RELEASE:- 4.0.1} "
8-
9- PLATFORM=$( uname | tr A-Z a-z)
10- if [[ ${PLATFORM} == ' darwin' ]]; then
11- PLATFORM=" osx"
12- fi
13-
14- MASON_URL=" https://s3.amazonaws.com/mason-binaries/${PLATFORM} -$( uname -m) "
15-
16- llvm_toolchain_dir=" $( pwd) /.toolchain"
6+ export MASON_LLVM_RELEASE=" ${MASON_LLVM_RELEASE:- 5.0.0} "
177
188function run() {
199 local config=${1}
@@ -23,57 +13,23 @@ function run() {
2313 echo ' shell_session_update() { :; }' > ~ /.direnvrc
2414 fi
2515
26- #
27- # COMPILER TOOLCHAIN
28- #
29-
30- # We install clang++ without the mason client for a couple reasons:
31- # 1) decoupling makes it viable to use a custom branch of mason that might
32- # modify the upstream s3 bucket in a such a way that does not give
33- # it access to build tools like clang++
34- # 2) Allows us to short-circuit and use a global clang++ install if it
35- # is available to save space for local builds.
36- GLOBAL_CLANG=" ${HOME} /.mason/mason_packages/${PLATFORM} -$( uname -m) /clang++/${MASON_LLVM_RELEASE} "
37- GLOBAL_LLVM=" ${HOME} /.mason/mason_packages/${PLATFORM} -$( uname -m) /llvm/${MASON_LLVM_RELEASE} "
38- if [[ -d ${GLOBAL_LLVM} ]]; then
39- echo " Detected '${GLOBAL_LLVM} /bin/clang++', using it"
40- local llvm_toolchain_dir=${GLOBAL_LLVM}
41- elif [[ -d ${GLOBAL_CLANG} ]]; then
42- echo " Detected '${GLOBAL_CLANG} /bin/clang++', using it"
43- local llvm_toolchain_dir=${GLOBAL_CLANG}
44- elif [[ -d ${GLOBAL_CLANG} ]]; then
45- echo " Detected '${GLOBAL_CLANG} /bin/clang++', using it"
46- local llvm_toolchain_dir=${GLOBAL_CLANG}
47- elif [[ ! -d ${llvm_toolchain_dir} ]]; then
48- BINARY=" ${MASON_URL} /clang++/${MASON_LLVM_RELEASE} .tar.gz"
49- echo " Downloading ${BINARY} "
50- mkdir -p ${llvm_toolchain_dir}
51- curl -sSfL ${BINARY} | tar --gunzip --extract --strip-components=1 --directory=${llvm_toolchain_dir}
16+ # Ensure toolchain is installed via mason-js
17+ if [[ ! -f ./node_modules/.bin/mason-js ]]; then
18+ npm install mason-js-sdk
5219 fi
5320
54- #
55- # MASON
56- #
57-
58- function setup_mason() {
59- local install_dir=${1}
60- local mason_release=${2}
61- mkdir -p ${install_dir}
62- curl -sSfL https://github.com/mapbox/mason/archive/${mason_release} .tar.gz | tar --gunzip --extract --strip-components=1 --directory=${install_dir}
63- }
64-
65- setup_mason $( pwd) /.mason ${MASON_RELEASE}
21+ node_modules/.bin/mason-js install clang++=${MASON_LLVM_RELEASE} --type=compiled
22+ node_modules/.bin/mason-js link clang++=${MASON_LLVM_RELEASE} --type=compiled
6623
6724 #
6825 # ENV SETTINGS
6926 #
7027
71- echo " export PATH=${llvm_toolchain_dir} /bin:$( pwd) /.mason:$( pwd) /mason_packages/.link/bin:" ' ${PATH}' > ${config}
72- echo " export CXX=${CXX:- ${llvm_toolchain_dir} / bin/ clang++} " >> ${config}
73- echo " export MASON_RELEASE=${MASON_RELEASE} " >> ${config}
28+ echo " export PATH=$( pwd) /.mason:$( pwd) /mason_packages/.link/bin:" ' ${PATH}' > ${config}
29+ echo " export CXX=${CXX:- $(pwd)/ mason_packages/ .link/ bin/ clang++} " >> ${config}
7430 echo " export MASON_LLVM_RELEASE=${MASON_LLVM_RELEASE} " >> ${config}
7531 # https://github.com/google/sanitizers/wiki/AddressSanitizerAsDso
76- RT_BASE=${llvm_toolchain_dir} /lib/clang/${MASON_LLVM_RELEASE} /lib/$( uname | tr A-Z a-z) /libclang_rt
32+ RT_BASE=$( pwd ) /mason_packages/.link /lib/clang/${MASON_LLVM_RELEASE} /lib/$( uname | tr A-Z a-z) /libclang_rt
7733 if [[ $( uname -s) == ' Darwin' ]]; then
7834 RT_PRELOAD=${RT_BASE} .asan_osx_dynamic.dylib
7935 else
@@ -85,8 +41,8 @@ function run() {
8541 echo " leak:v8::internal" >> ${SUPPRESSION_FILE}
8642 echo " leak:node::CreateEnvironment" >> ${SUPPRESSION_FILE}
8743 echo " leak:node::Init" >> ${SUPPRESSION_FILE}
88- echo " export ASAN_SYMBOLIZER_PATH=${llvm_toolchain_dir} /bin/llvm-symbolizer" >> ${config}
89- echo " export MSAN_SYMBOLIZER_PATH=${llvm_toolchain_dir} /bin/llvm-symbolizer" >> ${config}
44+ echo " export ASAN_SYMBOLIZER_PATH=$( pwd ) /mason_packages/.link /bin/llvm-symbolizer" >> ${config}
45+ echo " export MSAN_SYMBOLIZER_PATH=$( pwd ) /mason_packages/.link /bin/llvm-symbolizer" >> ${config}
9046 echo " export UBSAN_OPTIONS=print_stacktrace=1" >> ${config}
9147 echo " export LSAN_OPTIONS=suppressions=${SUPPRESSION_FILE} " >> ${config}
9248 echo " export ASAN_OPTIONS=symbolize=1:abort_on_error=1:detect_container_overflow=1:check_initialization_order=1:detect_stack_use_after_return=1" >> ${config}
@@ -129,4 +85,4 @@ case $i in
12985 usage
13086 ;;
13187esac
132- done
88+ done
0 commit comments