blob: 20e5d339c9a8e8a3d49dfe9d6602d456b5dd711d [file] [log] [blame]
Jayant Chowdharyea86c042018-01-25 12:07:55 -08001#!/bin/bash -ex
2
Logan Chienee954192018-10-04 10:52:41 +08003# 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 Chowdharyea86c042018-01-25 12:07:55 -080017if [ -z "${OUT_DIR}" ]; then
Logan Chien6c5889e2018-10-04 11:18:06 +080018 echo "error: Must set OUT_DIR"
Jayant Chowdharyea86c042018-01-25 12:07:55 -080019 exit 1
20fi
21
Logan Chien179da4c2018-10-04 11:21:59 +080022if [ ! -e "build/envsetup.sh" ]; then
23 echo "error: Current working directory must be ANDROID_BUILD_TOP"
24 exit 1
25fi
Jayant Chowdharyea86c042018-01-25 12:07:55 -080026
Logan Chien179da4c2018-10-04 11:21:59 +080027TOP="$(pwd)"
28
29# Read PLATFORM_SDK_VERSION
30set +x
31source "build/envsetup.sh"
32PLATFORM_SDK_VERSION="$(get_build_var PLATFORM_SDK_VERSION)"
33set -x
34
35# Read OS name
Jayant Chowdharyea86c042018-01-25 12:07:55 -080036UNAME="$(uname)"
Logan Chien6c5889e2018-10-04 11:18:06 +080037case "${UNAME}" in
Jayant Chowdharyea86c042018-01-25 12:07:55 -080038Linux)
39 OS='linux'
40 ;;
41Darwin)
42 OS='darwin'
43 ;;
44*)
Logan Chien6c5889e2018-10-04 11:18:06 +080045 echo "error: Unknown uname: ${UNAME}"
Jayant Chowdharyea86c042018-01-25 12:07:55 -080046 exit 1
47 ;;
48esac
49
Logan Chien6c5889e2018-10-04 11:18:06 +080050# Setup Soong configuration
51SOONG_OUT="${OUT_DIR}/soong"
52SOONG_HOST_OUT="${OUT_DIR}/soong/host/${OS}-x86"
53rm -rf "${SOONG_OUT}"
54mkdir -p "${SOONG_OUT}"
55cat > "${SOONG_OUT}/soong.variables" << __EOF__
Jayant Chowdharyea86c042018-01-25 12:07:55 -080056{
57 "Allow_missing_dependencies": true,
Logan Chien179da4c2018-10-04 11:21:59 +080058
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 Chowdharyea86c042018-01-25 12:07:55 -080068}
Logan Chien6c5889e2018-10-04 11:18:06 +080069__EOF__
70
71# Targets to be built
Jayant Chowdharyea86c042018-01-25 12:07:55 -080072SOONG_BINARIES=(
Logan Chien6c5889e2018-10-04 11:18:06 +080073 "header-abi-linker"
74 "header-abi-dumper"
75 "header-abi-diff"
76 "merge-abi-diff"
Jayant Chowdharyea86c042018-01-25 12:07:55 -080077)
78
Logan Chien6c5889e2018-10-04 11:18:06 +080079binaries=()
80for name in "${SOONG_BINARIES[@]}"; do
81 binaries+=("${SOONG_HOST_OUT}/bin/${name}")
82done
Jayant Chowdharyea86c042018-01-25 12:07:55 -080083
Logan Chien6c5889e2018-10-04 11:18:06 +080084# Build binaries and shared libs
85build/soong/soong_ui.bash --make-mode --skip-make "${binaries[@]}"
Jayant Chowdharyea86c042018-01-25 12:07:55 -080086
Logan Chien6c5889e2018-10-04 11:18:06 +080087# Copy binaries and shared libs
88mkdir -p "${SOONG_OUT}/dist/bin"
89cp "${binaries[@]}" "${SOONG_OUT}/dist/bin/"
90cp -R "${SOONG_HOST_OUT}/lib"* "${SOONG_OUT}/dist/"
Jayant Chowdharyea86c042018-01-25 12:07:55 -080091
Logan Chienc3d85932018-10-04 11:24:13 +080092# Copy clang headers
93cp -R "external/clang/lib/Headers" "${SOONG_OUT}/dist/clang-headers"
94
Logan Chien6c5889e2018-10-04 11:18:06 +080095# Package binaries and shared libs
Jayant Chowdharyea86c042018-01-25 12:07:55 -080096(
Logan Chien6c5889e2018-10-04 11:18:06 +080097 cd "${SOONG_OUT}/dist"
Jayant Chowdharyea86c042018-01-25 12:07:55 -080098 zip -qryX build-prebuilts.zip *
99)
100
101if [ -n "${DIST_DIR}" ]; then
Logan Chien6c5889e2018-10-04 11:18:06 +0800102 mkdir -p "${DIST_DIR}" || true
103 cp "${SOONG_OUT}/dist/build-prebuilts.zip" "${DIST_DIR}/"
Jayant Chowdharyea86c042018-01-25 12:07:55 -0800104fi