-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-prebuilts.sh
executable file
·202 lines (179 loc) · 4.89 KB
/
build-prebuilts.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
#!/bin/bash -ex
: "${OUT_DIR:?Must set OUT_DIR}"
TOP=$(pwd)
UNAME="$(uname)"
case "$UNAME" in
Linux)
OS='linux'
;;
Darwin)
OS='darwin'
;;
*)
exit 1
;;
esac
build_soong=1
[[ ! -d ${TOP}/toolchain/go ]] || build_go=1
clean=t
[[ "${1:-}" != '--resume' ]] || clean=''
if [ -n ${build_soong} ]; then
SOONG_OUT=${OUT_DIR}/soong
SOONG_HOST_OUT=${OUT_DIR}/soong/host/${OS}-x86
[[ -z "${clean}" ]] || rm -rf ${SOONG_OUT}
mkdir -p ${SOONG_OUT}
cat > ${SOONG_OUT}/soong.variables << EOF
{
"Allow_missing_dependencies": true,
"HostArch":"x86_64"
}
EOF
SOONG_BINARIES=(
acp
aidl
bison
bpfmt
bzip2
ckati
ckati_stamp_dump
flex
gavinhoward-bc
go_extractor
hidl-lint
m4
make
ninja
one-true-awk
py2-cmd
py3-cmd
soong_zip
toybox
xz
zip2zip
zipalign
ziptime
ziptool
)
SOONG_ASAN_BINARIES=(
acp
aidl
ckati
gavinhoward-bc
ninja
toybox
zipalign
ziptime
ziptool
)
SOONG_JAVA_LIBRARIES=(
desugar.jar
dx.jar
turbine.jar
javac_extractor.jar
)
SOONG_JAVA_WRAPPERS=(
dx
)
if [[ $OS == "linux" ]]; then
SOONG_BINARIES+=(
nsjail
)
fi
binaries="${SOONG_BINARIES[@]/#/${SOONG_HOST_OUT}/bin/}"
asan_binaries="${SOONG_ASAN_BINARIES[@]/#/${SOONG_HOST_OUT}/bin/}"
jars="${SOONG_JAVA_LIBRARIES[@]/#/${SOONG_HOST_OUT}/framework/}"
wrappers="${SOONG_JAVA_WRAPPERS[@]/#/${SOONG_HOST_OUT}/bin/}"
# Build everything
build/soong/soong_ui.bash --make-mode --skip-make \
${binaries} \
${wrappers} \
${jars} \
${SOONG_HOST_OUT}/nativetest64/ninja_test/ninja_test \
${SOONG_HOST_OUT}/nativetest64/ckati_test/find_test \
soong_docs
# Run ninja tests
${SOONG_HOST_OUT}/nativetest64/ninja_test/ninja_test
# Run ckati tests
${SOONG_HOST_OUT}/nativetest64/ckati_test/find_test
# Copy arch-specific binaries
mkdir -p ${SOONG_OUT}/dist/bin
cp ${binaries} ${SOONG_OUT}/dist/bin/
cp -R ${SOONG_HOST_OUT}/lib* ${SOONG_OUT}/dist/
# Copy jars and wrappers
mkdir -p ${SOONG_OUT}/dist-common/{bin,flex,framework}
cp ${wrappers} ${SOONG_OUT}/dist-common/bin
cp ${jars} ${SOONG_OUT}/dist-common/framework
cp -r external/bison/data ${SOONG_OUT}/dist-common/bison
cp external/bison/NOTICE ${SOONG_OUT}/dist-common/bison/
cp -r external/flex/src/FlexLexer.h ${SOONG_OUT}/dist-common/flex/
cp external/flex/NOTICE ${SOONG_OUT}/dist-common/flex/
if [[ $OS == "linux" ]]; then
# Build ASAN versions
export ASAN_OPTIONS=detect_leaks=0
cat > ${SOONG_OUT}/soong.variables << EOF
{
"Allow_missing_dependencies": true,
"HostArch":"x86_64",
"SanitizeHost": ["address"]
}
EOF
export ASAN_SYMBOLIZER_PATH=${PWD}/prebuilts/clang/host/linux-x86/llvm-binutils-stable/llvm-symbolizer
# Clean up non-ASAN installed versions
rm -rf ${SOONG_HOST_OUT}
# Build everything with ASAN
build/soong/soong_ui.bash --make-mode --skip-make \
${asan_binaries} \
${SOONG_HOST_OUT}/nativetest64/ninja_test/ninja_test \
${SOONG_HOST_OUT}/nativetest64/ckati_test/find_test
# Run ninja tests
${SOONG_HOST_OUT}/nativetest64/ninja_test/ninja_test
# Run ckati tests
${SOONG_HOST_OUT}/nativetest64/ckati_test/find_test
# Copy arch-specific binaries
mkdir -p ${SOONG_OUT}/dist/asan/bin
cp ${asan_binaries} ${SOONG_OUT}/dist/asan/bin/
cp -R ${SOONG_HOST_OUT}/lib* ${SOONG_OUT}/dist/asan/
fi
# Package arch-specific prebuilts
(
cd ${SOONG_OUT}/dist
zip -qryX build-prebuilts.zip *
)
# Package common prebuilts
(
cd ${SOONG_OUT}/dist-common
zip -qryX build-common-prebuilts.zip *
)
fi
# Go
if [ -n ${build_go} ]; then
GO_OUT=${OUT_DIR}/obj/go
rm -rf ${GO_OUT}
mkdir -p ${GO_OUT}
cp -a ${TOP}/toolchain/go/* ${GO_OUT}/
(
cd ${GO_OUT}/src
export GOROOT_BOOTSTRAP=${TOP}/prebuilts/go/${OS}-x86
export GOROOT_FINAL=./prebuilts/go/${OS}-x86
export GO_TEST_TIMEOUT_SCALE=100
./make.bash
rm -rf ../pkg/bootstrap
rm -rf ../pkg/obj
GOROOT=$(pwd)/.. ../bin/go install -race std
)
(
cd ${GO_OUT}
zip -qryX go.zip *
)
fi
if [ -n "${DIST_DIR}" ]; then
mkdir -p ${DIST_DIR} || true
if [ -n ${build_soong} ]; then
cp ${SOONG_OUT}/dist/build-prebuilts.zip ${DIST_DIR}/
cp ${SOONG_OUT}/dist-common/build-common-prebuilts.zip ${DIST_DIR}/
cp ${SOONG_OUT}/docs/*.html ${DIST_DIR}/
fi
if [ -n ${build_go} ]; then
cp ${GO_OUT}/go.zip ${DIST_DIR}/
fi
fi