Colin Cross | 0ffa5a0 | 2016-04-01 16:45:40 -0700 | [diff] [blame] | 1 | #!/bin/bash -ex |
| 2 | |
| 3 | if [ -z "${OUT_DIR}" ]; then |
| 4 | echo Must set OUT_DIR |
| 5 | exit 1 |
| 6 | fi |
| 7 | |
| 8 | TOP=$(pwd) |
| 9 | |
| 10 | UNAME="$(uname)" |
| 11 | case "$UNAME" in |
| 12 | Linux) |
| 13 | OS='linux' |
| 14 | ;; |
| 15 | Darwin) |
| 16 | OS='darwin' |
| 17 | ;; |
| 18 | *) |
| 19 | exit 1 |
| 20 | ;; |
| 21 | esac |
| 22 | |
| 23 | build_soong=1 |
| 24 | if [ -d ${TOP}/toolchain/go ]; then |
| 25 | build_go=1 |
| 26 | fi |
Colin Cross | 0ffa5a0 | 2016-04-01 16:45:40 -0700 | [diff] [blame] | 27 | |
| 28 | if [ -n ${build_soong} ]; then |
| 29 | # ckati and makeparallel (Soong) |
| 30 | SOONG_OUT=${OUT_DIR}/soong |
| 31 | SOONG_HOST_OUT=${OUT_DIR}/soong/host/${OS}-x86 |
| 32 | rm -rf ${SOONG_OUT} |
| 33 | mkdir -p ${SOONG_OUT} |
| 34 | cat > ${SOONG_OUT}/soong.variables << EOF |
| 35 | { |
| 36 | "Allow_missing_dependencies": true, |
Dan Willemsen | 0455a26 | 2018-08-28 17:50:21 -0700 | [diff] [blame] | 37 | "HostArch":"x86_64" |
Colin Cross | 0ffa5a0 | 2016-04-01 16:45:40 -0700 | [diff] [blame] | 38 | } |
| 39 | EOF |
Colin Cross | c5042c7 | 2017-06-20 17:22:32 -0700 | [diff] [blame] | 40 | SOONG_BINARIES=( |
| 41 | acp |
Dan Willemsen | 52503bb | 2017-11-17 10:11:03 -0800 | [diff] [blame] | 42 | aidl |
Dan Willemsen | 10aabfe | 2018-01-08 17:12:38 -0800 | [diff] [blame] | 43 | bison |
Colin Cross | c5042c7 | 2017-06-20 17:22:32 -0700 | [diff] [blame] | 44 | bpfmt |
| 45 | ckati |
| 46 | ckati_stamp_dump |
Dan Willemsen | 77ad4b9 | 2018-05-22 16:38:31 -0700 | [diff] [blame] | 47 | flex |
Dan Willemsen | c4e38f5 | 2018-10-04 17:41:49 -0700 | [diff] [blame] | 48 | make |
Colin Cross | c5042c7 | 2017-06-20 17:22:32 -0700 | [diff] [blame] | 49 | makeparallel |
Colin Cross | c5042c7 | 2017-06-20 17:22:32 -0700 | [diff] [blame] | 50 | ninja |
| 51 | soong_zip |
Dan Willemsen | 9672d7a | 2018-03-09 01:00:47 -0800 | [diff] [blame] | 52 | xz |
Colin Cross | c5042c7 | 2017-06-20 17:22:32 -0700 | [diff] [blame] | 53 | zip2zip |
Dan Willemsen | 52503bb | 2017-11-17 10:11:03 -0800 | [diff] [blame] | 54 | zipalign |
Colin Cross | c5042c7 | 2017-06-20 17:22:32 -0700 | [diff] [blame] | 55 | ziptime |
| 56 | ) |
Colin Cross | 14cd25f | 2017-09-22 14:27:44 -0700 | [diff] [blame] | 57 | SOONG_ASAN_BINARIES=( |
| 58 | acp |
Dan Willemsen | 52503bb | 2017-11-17 10:11:03 -0800 | [diff] [blame] | 59 | aidl |
Colin Cross | 14cd25f | 2017-09-22 14:27:44 -0700 | [diff] [blame] | 60 | ckati |
| 61 | makeparallel |
| 62 | ninja |
Dan Willemsen | 52503bb | 2017-11-17 10:11:03 -0800 | [diff] [blame] | 63 | zipalign |
Colin Cross | 14cd25f | 2017-09-22 14:27:44 -0700 | [diff] [blame] | 64 | ziptime |
| 65 | ) |
| 66 | SOONG_JAVA_LIBRARIES=( |
| 67 | desugar |
| 68 | dx |
Nan Zhang | ac1bdea | 2017-10-24 14:46:58 -0700 | [diff] [blame] | 69 | turbine |
Colin Cross | 14cd25f | 2017-09-22 14:27:44 -0700 | [diff] [blame] | 70 | ) |
| 71 | SOONG_JAVA_WRAPPERS=( |
| 72 | dx |
Colin Cross | 14cd25f | 2017-09-22 14:27:44 -0700 | [diff] [blame] | 73 | ) |
Dan Willemsen | 7c8949f | 2018-10-29 11:00:43 -0700 | [diff] [blame] | 74 | if [[ $OS == "linux" ]]; then |
| 75 | SOONG_BINARIES+=( |
| 76 | toybox |
| 77 | ) |
| 78 | SOONG_ASAN_BINARIES+=( |
| 79 | toybox |
| 80 | ) |
| 81 | fi |
Colin Cross | 14cd25f | 2017-09-22 14:27:44 -0700 | [diff] [blame] | 82 | |
| 83 | binaries=$(for i in "${SOONG_BINARIES[@]}"; do echo ${SOONG_HOST_OUT}/bin/${i}; done) |
Dan Willemsen | d447508 | 2017-10-04 15:40:35 -0700 | [diff] [blame] | 84 | asan_binaries=$(for i in "${SOONG_ASAN_BINARIES[@]}"; do echo ${SOONG_HOST_OUT}/bin/${i}; done) |
Colin Cross | 14cd25f | 2017-09-22 14:27:44 -0700 | [diff] [blame] | 85 | jars=$(for i in "${SOONG_JAVA_LIBRARIES[@]}"; do echo ${SOONG_HOST_OUT}/framework/${i}.jar; done) |
| 86 | wrappers=$(for i in "${SOONG_JAVA_WRAPPERS[@]}"; do echo ${SOONG_HOST_OUT}/bin/${i}; done) |
| 87 | |
| 88 | # Build everything |
| 89 | build/soong/soong_ui.bash --make-mode --skip-make \ |
| 90 | ${binaries} \ |
| 91 | ${wrappers} \ |
| 92 | ${jars} \ |
Colin Cross | acad53f | 2017-12-12 10:59:25 -0800 | [diff] [blame] | 93 | ${SOONG_HOST_OUT}/nativetest64/ninja_test/ninja_test \ |
Dan Willemsen | fe85be0 | 2018-02-15 13:59:35 -0800 | [diff] [blame] | 94 | ${SOONG_HOST_OUT}/nativetest64/ckati_test/find_test \ |
Colin Cross | acad53f | 2017-12-12 10:59:25 -0800 | [diff] [blame] | 95 | soong_docs |
Colin Cross | 14cd25f | 2017-09-22 14:27:44 -0700 | [diff] [blame] | 96 | |
| 97 | # Run ninja tests |
Dan Willemsen | 7674849 | 2016-04-21 12:40:04 -0700 | [diff] [blame] | 98 | ${SOONG_HOST_OUT}/nativetest64/ninja_test/ninja_test |
Colin Cross | 14cd25f | 2017-09-22 14:27:44 -0700 | [diff] [blame] | 99 | |
Dan Willemsen | fe85be0 | 2018-02-15 13:59:35 -0800 | [diff] [blame] | 100 | # Run ckati tests |
| 101 | ${SOONG_HOST_OUT}/nativetest64/ckati_test/find_test |
| 102 | |
Colin Cross | 14cd25f | 2017-09-22 14:27:44 -0700 | [diff] [blame] | 103 | # Copy arch-specific binaries |
Dan Willemsen | 6adbc36 | 2016-10-05 22:41:25 -0700 | [diff] [blame] | 104 | mkdir -p ${SOONG_OUT}/dist/bin |
Colin Cross | 14cd25f | 2017-09-22 14:27:44 -0700 | [diff] [blame] | 105 | cp ${binaries} ${SOONG_OUT}/dist/bin/ |
Dan Willemsen | 6adbc36 | 2016-10-05 22:41:25 -0700 | [diff] [blame] | 106 | cp -R ${SOONG_HOST_OUT}/lib* ${SOONG_OUT}/dist/ |
| 107 | |
Colin Cross | 14cd25f | 2017-09-22 14:27:44 -0700 | [diff] [blame] | 108 | # Copy jars and wrappers |
| 109 | mkdir -p ${SOONG_OUT}/dist-common/bin ${SOONG_OUT}/dist-common/framework |
| 110 | cp ${wrappers} ${SOONG_OUT}/dist-common/bin |
| 111 | cp ${jars} ${SOONG_OUT}/dist-common/framework |
| 112 | |
Dan Willemsen | 10aabfe | 2018-01-08 17:12:38 -0800 | [diff] [blame] | 113 | cp -r external/bison/data ${SOONG_OUT}/dist-common/bison |
| 114 | |
Dan Willemsen | 6adbc36 | 2016-10-05 22:41:25 -0700 | [diff] [blame] | 115 | if [[ $OS == "linux" ]]; then |
| 116 | # Build ASAN versions |
| 117 | export ASAN_OPTIONS=detect_leaks=0 |
| 118 | cat > ${SOONG_OUT}/soong.variables << EOF |
| 119 | { |
| 120 | "Allow_missing_dependencies": true, |
| 121 | "HostArch":"x86_64", |
Dan Willemsen | 6adbc36 | 2016-10-05 22:41:25 -0700 | [diff] [blame] | 122 | "SanitizeHost": ["address"] |
| 123 | } |
| 124 | EOF |
Colin Cross | 14cd25f | 2017-09-22 14:27:44 -0700 | [diff] [blame] | 125 | |
| 126 | # Clean up non-ASAN installed versions |
Colin Cross | 85c2d92 | 2017-05-09 20:30:40 -0700 | [diff] [blame] | 127 | rm -rf ${SOONG_HOST_OUT} |
Colin Cross | 14cd25f | 2017-09-22 14:27:44 -0700 | [diff] [blame] | 128 | |
| 129 | # Build everything with ASAN |
| 130 | build/soong/soong_ui.bash --make-mode --skip-make \ |
Dan Willemsen | d447508 | 2017-10-04 15:40:35 -0700 | [diff] [blame] | 131 | ${asan_binaries} \ |
Dan Willemsen | fe85be0 | 2018-02-15 13:59:35 -0800 | [diff] [blame] | 132 | ${SOONG_HOST_OUT}/nativetest64/ninja_test/ninja_test \ |
| 133 | ${SOONG_HOST_OUT}/nativetest64/ckati_test/find_test |
Colin Cross | 14cd25f | 2017-09-22 14:27:44 -0700 | [diff] [blame] | 134 | |
| 135 | # Run ninja tests |
Dan Willemsen | 6adbc36 | 2016-10-05 22:41:25 -0700 | [diff] [blame] | 136 | ${SOONG_HOST_OUT}/nativetest64/ninja_test/ninja_test |
Colin Cross | 14cd25f | 2017-09-22 14:27:44 -0700 | [diff] [blame] | 137 | |
Dan Willemsen | fe85be0 | 2018-02-15 13:59:35 -0800 | [diff] [blame] | 138 | # Run ckati tests |
| 139 | ${SOONG_HOST_OUT}/nativetest64/ckati_test/find_test |
| 140 | |
Colin Cross | 14cd25f | 2017-09-22 14:27:44 -0700 | [diff] [blame] | 141 | # Copy arch-specific binaries |
Dan Willemsen | 6adbc36 | 2016-10-05 22:41:25 -0700 | [diff] [blame] | 142 | mkdir -p ${SOONG_OUT}/dist/asan/bin |
Dan Willemsen | d447508 | 2017-10-04 15:40:35 -0700 | [diff] [blame] | 143 | cp ${asan_binaries} ${SOONG_OUT}/dist/asan/bin/ |
Dan Willemsen | 6adbc36 | 2016-10-05 22:41:25 -0700 | [diff] [blame] | 144 | cp -R ${SOONG_HOST_OUT}/lib* ${SOONG_OUT}/dist/asan/ |
| 145 | fi |
| 146 | |
Colin Cross | 14cd25f | 2017-09-22 14:27:44 -0700 | [diff] [blame] | 147 | # Package arch-specific prebuilts |
Dan Willemsen | 6adbc36 | 2016-10-05 22:41:25 -0700 | [diff] [blame] | 148 | ( |
| 149 | cd ${SOONG_OUT}/dist |
| 150 | zip -qryX build-prebuilts.zip * |
| 151 | ) |
Colin Cross | 14cd25f | 2017-09-22 14:27:44 -0700 | [diff] [blame] | 152 | |
| 153 | # Package common prebuilts |
| 154 | ( |
| 155 | cd ${SOONG_OUT}/dist-common |
| 156 | zip -qryX build-common-prebuilts.zip * |
| 157 | ) |
Colin Cross | 0ffa5a0 | 2016-04-01 16:45:40 -0700 | [diff] [blame] | 158 | fi |
| 159 | |
| 160 | # Go |
| 161 | if [ -n ${build_go} ]; then |
| 162 | GO_OUT=${OUT_DIR}/obj/go |
| 163 | rm -rf ${GO_OUT} |
| 164 | mkdir -p ${GO_OUT} |
| 165 | cp -a ${TOP}/toolchain/go/* ${GO_OUT}/ |
| 166 | ( |
| 167 | cd ${GO_OUT}/src |
| 168 | export GOROOT_BOOTSTRAP=${TOP}/prebuilts/go/${OS}-x86 |
Colin Cross | 42f43d9 | 2016-04-18 12:31:06 -0700 | [diff] [blame] | 169 | export GOROOT_FINAL=./prebuilts/go/${OS}-x86 |
Colin Cross | 0ffa5a0 | 2016-04-01 16:45:40 -0700 | [diff] [blame] | 170 | export GO_TEST_TIMEOUT_SCALE=100 |
| 171 | ./make.bash |
Dan Willemsen | 817bd2e | 2017-02-21 14:37:36 -0800 | [diff] [blame] | 172 | rm -rf ../pkg/bootstrap |
Dan Willemsen | 77ba553 | 2018-07-23 10:48:27 -0700 | [diff] [blame] | 173 | rm -rf ../pkg/obj |
Colin Cross | 0ffa5a0 | 2016-04-01 16:45:40 -0700 | [diff] [blame] | 174 | GOROOT=$(pwd)/.. ../bin/go install -race std |
| 175 | ) |
| 176 | ( |
| 177 | cd ${GO_OUT} |
| 178 | zip -qryX go.zip * |
| 179 | ) |
| 180 | fi |
| 181 | |
| 182 | if [ -n "${DIST_DIR}" ]; then |
| 183 | mkdir -p ${DIST_DIR} || true |
| 184 | |
| 185 | if [ -n ${build_soong} ]; then |
Dan Willemsen | 6adbc36 | 2016-10-05 22:41:25 -0700 | [diff] [blame] | 186 | cp ${SOONG_OUT}/dist/build-prebuilts.zip ${DIST_DIR}/ |
Colin Cross | 14cd25f | 2017-09-22 14:27:44 -0700 | [diff] [blame] | 187 | cp ${SOONG_OUT}/dist-common/build-common-prebuilts.zip ${DIST_DIR}/ |
Colin Cross | acad53f | 2017-12-12 10:59:25 -0800 | [diff] [blame] | 188 | cp ${SOONG_OUT}/docs/soong_build.html ${DIST_DIR}/ |
Colin Cross | 0ffa5a0 | 2016-04-01 16:45:40 -0700 | [diff] [blame] | 189 | fi |
Colin Cross | 0ffa5a0 | 2016-04-01 16:45:40 -0700 | [diff] [blame] | 190 | if [ -n ${build_go} ]; then |
| 191 | cp ${GO_OUT}/go.zip ${DIST_DIR}/ |
| 192 | fi |
| 193 | fi |