Jayant Chowdhary | ea86c04 | 2018-01-25 12:07:55 -0800 | [diff] [blame] | 1 | #!/bin/bash -ex |
| 2 | |
Logan Chien | ee95419 | 2018-10-04 10:52:41 +0800 | [diff] [blame] | 3 | # Copyright 2018 Google Inc. All rights reserved. |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
Jayant Chowdhary | ea86c04 | 2018-01-25 12:07:55 -0800 | [diff] [blame] | 17 | if [ -z "${OUT_DIR}" ]; then |
Logan Chien | 6c5889e | 2018-10-04 11:18:06 +0800 | [diff] [blame] | 18 | echo "error: Must set OUT_DIR" |
Jayant Chowdhary | ea86c04 | 2018-01-25 12:07:55 -0800 | [diff] [blame] | 19 | exit 1 |
| 20 | fi |
| 21 | |
Logan Chien | f59e2ee | 2018-10-04 13:43:49 +0000 | [diff] [blame] | 22 | TOP=$(pwd) |
Jayant Chowdhary | ea86c04 | 2018-01-25 12:07:55 -0800 | [diff] [blame] | 23 | |
| 24 | UNAME="$(uname)" |
Logan Chien | 6c5889e | 2018-10-04 11:18:06 +0800 | [diff] [blame] | 25 | case "${UNAME}" in |
Jayant Chowdhary | ea86c04 | 2018-01-25 12:07:55 -0800 | [diff] [blame] | 26 | Linux) |
| 27 | OS='linux' |
| 28 | ;; |
| 29 | Darwin) |
| 30 | OS='darwin' |
| 31 | ;; |
| 32 | *) |
Logan Chien | 6c5889e | 2018-10-04 11:18:06 +0800 | [diff] [blame] | 33 | echo "error: Unknown uname: ${UNAME}" |
Jayant Chowdhary | ea86c04 | 2018-01-25 12:07:55 -0800 | [diff] [blame] | 34 | exit 1 |
| 35 | ;; |
| 36 | esac |
| 37 | |
Logan Chien | 6c5889e | 2018-10-04 11:18:06 +0800 | [diff] [blame] | 38 | # Setup Soong configuration |
| 39 | SOONG_OUT="${OUT_DIR}/soong" |
| 40 | SOONG_HOST_OUT="${OUT_DIR}/soong/host/${OS}-x86" |
| 41 | rm -rf "${SOONG_OUT}" |
| 42 | mkdir -p "${SOONG_OUT}" |
| 43 | cat > "${SOONG_OUT}/soong.variables" << __EOF__ |
Jayant Chowdhary | ea86c04 | 2018-01-25 12:07:55 -0800 | [diff] [blame] | 44 | { |
| 45 | "Allow_missing_dependencies": true, |
Logan Chien | f59e2ee | 2018-10-04 13:43:49 +0000 | [diff] [blame] | 46 | "HostArch":"x86_64" |
Jayant Chowdhary | ea86c04 | 2018-01-25 12:07:55 -0800 | [diff] [blame] | 47 | } |
Logan Chien | 6c5889e | 2018-10-04 11:18:06 +0800 | [diff] [blame] | 48 | __EOF__ |
| 49 | |
| 50 | # Targets to be built |
Jayant Chowdhary | ea86c04 | 2018-01-25 12:07:55 -0800 | [diff] [blame] | 51 | SOONG_BINARIES=( |
Logan Chien | 6c5889e | 2018-10-04 11:18:06 +0800 | [diff] [blame] | 52 | "header-abi-linker" |
| 53 | "header-abi-dumper" |
| 54 | "header-abi-diff" |
| 55 | "merge-abi-diff" |
Jayant Chowdhary | ea86c04 | 2018-01-25 12:07:55 -0800 | [diff] [blame] | 56 | ) |
| 57 | |
Logan Chien | 6c5889e | 2018-10-04 11:18:06 +0800 | [diff] [blame] | 58 | binaries=() |
| 59 | for name in "${SOONG_BINARIES[@]}"; do |
| 60 | binaries+=("${SOONG_HOST_OUT}/bin/${name}") |
| 61 | done |
Jayant Chowdhary | ea86c04 | 2018-01-25 12:07:55 -0800 | [diff] [blame] | 62 | |
Logan Chien | 6c5889e | 2018-10-04 11:18:06 +0800 | [diff] [blame] | 63 | # Build binaries and shared libs |
| 64 | build/soong/soong_ui.bash --make-mode --skip-make "${binaries[@]}" |
Jayant Chowdhary | ea86c04 | 2018-01-25 12:07:55 -0800 | [diff] [blame] | 65 | |
Logan Chien | 6c5889e | 2018-10-04 11:18:06 +0800 | [diff] [blame] | 66 | # Copy binaries and shared libs |
| 67 | mkdir -p "${SOONG_OUT}/dist/bin" |
| 68 | cp "${binaries[@]}" "${SOONG_OUT}/dist/bin/" |
| 69 | cp -R "${SOONG_HOST_OUT}/lib"* "${SOONG_OUT}/dist/" |
Jayant Chowdhary | ea86c04 | 2018-01-25 12:07:55 -0800 | [diff] [blame] | 70 | |
Logan Chien | c3d8593 | 2018-10-04 11:24:13 +0800 | [diff] [blame] | 71 | # Copy clang headers |
| 72 | cp -R "external/clang/lib/Headers" "${SOONG_OUT}/dist/clang-headers" |
Logan Chien | c612557 | 2018-10-08 10:32:16 +0800 | [diff] [blame] | 73 | cp "prebuilts/clang/host/${OS}-x86/clang-3289846/lib64/clang/3.8/include/arm_neon.h" "${SOONG_OUT}/dist/clang-headers" |
| 74 | rm "${SOONG_OUT}/dist/clang-headers/CMakeLists.txt" |
Logan Chien | c3d8593 | 2018-10-04 11:24:13 +0800 | [diff] [blame] | 75 | |
Logan Chien | 6c5889e | 2018-10-04 11:18:06 +0800 | [diff] [blame] | 76 | # Package binaries and shared libs |
Jayant Chowdhary | ea86c04 | 2018-01-25 12:07:55 -0800 | [diff] [blame] | 77 | ( |
Logan Chien | 6c5889e | 2018-10-04 11:18:06 +0800 | [diff] [blame] | 78 | cd "${SOONG_OUT}/dist" |
Jayant Chowdhary | ea86c04 | 2018-01-25 12:07:55 -0800 | [diff] [blame] | 79 | zip -qryX build-prebuilts.zip * |
| 80 | ) |
| 81 | |
| 82 | if [ -n "${DIST_DIR}" ]; then |
Logan Chien | 6c5889e | 2018-10-04 11:18:06 +0800 | [diff] [blame] | 83 | mkdir -p "${DIST_DIR}" || true |
| 84 | cp "${SOONG_OUT}/dist/build-prebuilts.zip" "${DIST_DIR}/" |
Jayant Chowdhary | ea86c04 | 2018-01-25 12:07:55 -0800 | [diff] [blame] | 85 | fi |