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 | 179da4c | 2018-10-04 11:21:59 +0800 | [diff] [blame] | 22 | if [ ! -e "build/envsetup.sh" ]; then |
| 23 | echo "error: Current working directory must be ANDROID_BUILD_TOP" |
| 24 | exit 1 |
| 25 | fi |
Jayant Chowdhary | ea86c04 | 2018-01-25 12:07:55 -0800 | [diff] [blame] | 26 | |
Logan Chien | 179da4c | 2018-10-04 11:21:59 +0800 | [diff] [blame] | 27 | TOP="$(pwd)" |
| 28 | |
| 29 | # Read PLATFORM_SDK_VERSION |
| 30 | set +x |
| 31 | source "build/envsetup.sh" |
| 32 | PLATFORM_SDK_VERSION="$(get_build_var PLATFORM_SDK_VERSION)" |
| 33 | set -x |
| 34 | |
| 35 | # Read OS name |
Jayant Chowdhary | ea86c04 | 2018-01-25 12:07:55 -0800 | [diff] [blame] | 36 | UNAME="$(uname)" |
Logan Chien | 6c5889e | 2018-10-04 11:18:06 +0800 | [diff] [blame] | 37 | case "${UNAME}" in |
Jayant Chowdhary | ea86c04 | 2018-01-25 12:07:55 -0800 | [diff] [blame] | 38 | Linux) |
| 39 | OS='linux' |
| 40 | ;; |
| 41 | Darwin) |
| 42 | OS='darwin' |
| 43 | ;; |
| 44 | *) |
Logan Chien | 6c5889e | 2018-10-04 11:18:06 +0800 | [diff] [blame] | 45 | echo "error: Unknown uname: ${UNAME}" |
Jayant Chowdhary | ea86c04 | 2018-01-25 12:07:55 -0800 | [diff] [blame] | 46 | exit 1 |
| 47 | ;; |
| 48 | esac |
| 49 | |
Logan Chien | 6c5889e | 2018-10-04 11:18:06 +0800 | [diff] [blame] | 50 | # Setup Soong configuration |
| 51 | SOONG_OUT="${OUT_DIR}/soong" |
| 52 | SOONG_HOST_OUT="${OUT_DIR}/soong/host/${OS}-x86" |
| 53 | rm -rf "${SOONG_OUT}" |
| 54 | mkdir -p "${SOONG_OUT}" |
| 55 | cat > "${SOONG_OUT}/soong.variables" << __EOF__ |
Jayant Chowdhary | ea86c04 | 2018-01-25 12:07:55 -0800 | [diff] [blame] | 56 | { |
| 57 | "Allow_missing_dependencies": true, |
Logan Chien | 179da4c | 2018-10-04 11:21:59 +0800 | [diff] [blame] | 58 | |
| 59 | "HostArch":"x86_64", |
| 60 | |
| 61 | "DeviceAbi": ["arm64-v8a"], |
| 62 | "DeviceArch":"arm64", |
| 63 | "DeviceArchVariant": "armv8-a", |
| 64 | "DeviceCpuVariant": "generic", |
| 65 | "DeviceName": "generic_arm64", |
| 66 | |
| 67 | "Platform_sdk_version": ${PLATFORM_SDK_VERSION} |
Jayant Chowdhary | ea86c04 | 2018-01-25 12:07:55 -0800 | [diff] [blame] | 68 | } |
Logan Chien | 6c5889e | 2018-10-04 11:18:06 +0800 | [diff] [blame] | 69 | __EOF__ |
| 70 | |
| 71 | # Targets to be built |
Jayant Chowdhary | ea86c04 | 2018-01-25 12:07:55 -0800 | [diff] [blame] | 72 | SOONG_BINARIES=( |
Logan Chien | 6c5889e | 2018-10-04 11:18:06 +0800 | [diff] [blame] | 73 | "header-abi-linker" |
| 74 | "header-abi-dumper" |
| 75 | "header-abi-diff" |
| 76 | "merge-abi-diff" |
Jayant Chowdhary | ea86c04 | 2018-01-25 12:07:55 -0800 | [diff] [blame] | 77 | ) |
| 78 | |
Logan Chien | 6c5889e | 2018-10-04 11:18:06 +0800 | [diff] [blame] | 79 | binaries=() |
| 80 | for name in "${SOONG_BINARIES[@]}"; do |
| 81 | binaries+=("${SOONG_HOST_OUT}/bin/${name}") |
| 82 | done |
Jayant Chowdhary | ea86c04 | 2018-01-25 12:07:55 -0800 | [diff] [blame] | 83 | |
Logan Chien | 6c5889e | 2018-10-04 11:18:06 +0800 | [diff] [blame] | 84 | # Build binaries and shared libs |
| 85 | build/soong/soong_ui.bash --make-mode --skip-make "${binaries[@]}" |
Jayant Chowdhary | ea86c04 | 2018-01-25 12:07:55 -0800 | [diff] [blame] | 86 | |
Logan Chien | 6c5889e | 2018-10-04 11:18:06 +0800 | [diff] [blame] | 87 | # Copy binaries and shared libs |
| 88 | mkdir -p "${SOONG_OUT}/dist/bin" |
| 89 | cp "${binaries[@]}" "${SOONG_OUT}/dist/bin/" |
| 90 | cp -R "${SOONG_HOST_OUT}/lib"* "${SOONG_OUT}/dist/" |
Jayant Chowdhary | ea86c04 | 2018-01-25 12:07:55 -0800 | [diff] [blame] | 91 | |
Logan Chien | c3d8593 | 2018-10-04 11:24:13 +0800 | [diff] [blame^] | 92 | # Copy clang headers |
| 93 | cp -R "external/clang/lib/Headers" "${SOONG_OUT}/dist/clang-headers" |
| 94 | |
Logan Chien | 6c5889e | 2018-10-04 11:18:06 +0800 | [diff] [blame] | 95 | # Package binaries and shared libs |
Jayant Chowdhary | ea86c04 | 2018-01-25 12:07:55 -0800 | [diff] [blame] | 96 | ( |
Logan Chien | 6c5889e | 2018-10-04 11:18:06 +0800 | [diff] [blame] | 97 | cd "${SOONG_OUT}/dist" |
Jayant Chowdhary | ea86c04 | 2018-01-25 12:07:55 -0800 | [diff] [blame] | 98 | zip -qryX build-prebuilts.zip * |
| 99 | ) |
| 100 | |
| 101 | if [ -n "${DIST_DIR}" ]; then |
Logan Chien | 6c5889e | 2018-10-04 11:18:06 +0800 | [diff] [blame] | 102 | mkdir -p "${DIST_DIR}" || true |
| 103 | cp "${SOONG_OUT}/dist/build-prebuilts.zip" "${DIST_DIR}/" |
Jayant Chowdhary | ea86c04 | 2018-01-25 12:07:55 -0800 | [diff] [blame] | 104 | fi |