forked from vmware-labs/webassembly-language-runtimes
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwlr-build.sh
executable file
·91 lines (75 loc) · 2.36 KB
/
wlr-build.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
83
84
85
86
87
88
89
90
91
#!/usr/bin/env bash
if [[ ! -v WLR_ENV ]]
then
echo "WLR build environment is not set"
exit 1
fi
if [[ ! -v WASI_SDK_PATH ]]
then
echo WLR_ENV=${WLR_ENV}
echo "Please set WASI_SDK_PATH and run again"
exit 1
fi
if [[ ! -v WASI_SDK_ASSET_NAME ]]; then
echo "Please set WASI_SDK_ASSET_NAME (e.g. wasi-sdk-18.0) in order to create packages."
exit 1
fi
if [[ ! -v BINARYEN_PATH ]]
then
echo WLR_ENV=${WLR_ENV}
echo WASI_SDK_PATH=${WASI_SDK_PATH}
echo "Please set BINARYEN_PATH and run again"
exit 1
fi
function onExit {
echo "=============================================================="
echo "Build progress logs for ${WLR_ENV}:"
cat $WLR_OUTPUT/wlr-build-progress.log
unset -f logStatus
}
trap onExit EXIT
if [[ ! -v WLR_PROGRESS_LOG ]]
then
export WLR_PROGRESS_LOG=${WLR_OUTPUT}/wlr-build-progress.log
echo "$(date --iso-8601=ns) | Using WASI_SDK_PATH=$WASI_SDK_PATH " | tee ${WLR_PROGRESS_LOG}
fi
function logStatus {
echo "$(date --iso-8601=ns) | ${WLR_ENV_NAME}${WLR_BUILD_FLAVOR:+(${WLR_BUILD_FLAVOR})} | $@" | tee -a ${WLR_PROGRESS_LOG}
}
export -f logStatus
logStatus WASI_SDK_PATH=${WASI_SDK_PATH}
logStatus WASI_SDK_ASSET_NAME=${WASI_SDK_ASSET_NAME}
logStatus BINARYEN_PATH=${BINARYEN_PATH}
logStatus WABT_ROOT=${WABT_ROOT}
logStatus WASI_VFS_ROOT=${WASI_VFS_ROOT}
export WASI_SYSROOT="${WASI_SDK_PATH}/share/wasi-sysroot"
export CC=${WASI_SDK_PATH}/bin/clang
export LD=${WASI_SDK_PATH}/bin/wasm-ld
export CXX=${WASI_SDK_PATH}/bin/clang++
export NM=${WASI_SDK_PATH}/bin/llvm-nm
export AR=${WASI_SDK_PATH}/bin/llvm-ar
export RANLIB=${WASI_SDK_PATH}/bin/llvm-ranlib
logStatus CC+${CC}
logStatus LD+${LD}
logStatus CXX+${CXX}
logStatus NM+${NM}
logStatus AR+${AR}
logStatus RANLIB+${RANLIB}
if ! builtin type -P wasm-opt
then
logStatus "Using wasm-opt wrapper from ${WLR_REPO_ROOT}/scripts/wrappers"
export PATH="${WLR_REPO_ROOT}/scripts/wrappers:$PATH"
fi
logStatus "Checking dependencies..."
if [[ -f ${WLR_ENV}/wlr-info.json ]]
then
source ${WLR_REPO_ROOT}/scripts/build-helpers/wlr_dependencies.sh
wlr_dependencies_load ${WLR_ENV}/wlr-info.json "${WLR_BUILD_FLAVOR}"
fi
source ${WLR_REPO_ROOT}/scripts/build-helpers/wlr_package.sh
logStatus "Building with environment:"
for line in $(env | grep -E "WLR_\w+=" | sort); do
logStatus $line
done
logStatus "Building..."
source ${WLR_ENV}/wlr-build.sh