blob: f4dabf3b9773e9dfe5f3b487329b5c9eca0a1252 [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 Chienf59e2ee2018-10-04 13:43:49 +000022TOP=$(pwd)
Jayant Chowdharyea86c042018-01-25 12:07:55 -080023
24UNAME="$(uname)"
Logan Chien6c5889e2018-10-04 11:18:06 +080025case "${UNAME}" in
Jayant Chowdharyea86c042018-01-25 12:07:55 -080026Linux)
27 OS='linux'
28 ;;
29Darwin)
30 OS='darwin'
31 ;;
32*)
Logan Chien6c5889e2018-10-04 11:18:06 +080033 echo "error: Unknown uname: ${UNAME}"
Jayant Chowdharyea86c042018-01-25 12:07:55 -080034 exit 1
35 ;;
36esac
37
Logan Chien6c5889e2018-10-04 11:18:06 +080038# Setup Soong configuration
39SOONG_OUT="${OUT_DIR}/soong"
40SOONG_HOST_OUT="${OUT_DIR}/soong/host/${OS}-x86"
41rm -rf "${SOONG_OUT}"
42mkdir -p "${SOONG_OUT}"
43cat > "${SOONG_OUT}/soong.variables" << __EOF__
Jayant Chowdharyea86c042018-01-25 12:07:55 -080044{
45 "Allow_missing_dependencies": true,
Logan Chienf59e2ee2018-10-04 13:43:49 +000046 "HostArch":"x86_64"
Jayant Chowdharyea86c042018-01-25 12:07:55 -080047}
Logan Chien6c5889e2018-10-04 11:18:06 +080048__EOF__
49
50# Targets to be built
Jayant Chowdharyea86c042018-01-25 12:07:55 -080051SOONG_BINARIES=(
Logan Chien6c5889e2018-10-04 11:18:06 +080052 "header-abi-linker"
53 "header-abi-dumper"
54 "header-abi-diff"
55 "merge-abi-diff"
Jayant Chowdharyea86c042018-01-25 12:07:55 -080056)
57
Logan Chien6c5889e2018-10-04 11:18:06 +080058binaries=()
59for name in "${SOONG_BINARIES[@]}"; do
60 binaries+=("${SOONG_HOST_OUT}/bin/${name}")
61done
Jayant Chowdharyea86c042018-01-25 12:07:55 -080062
Logan Chien6c5889e2018-10-04 11:18:06 +080063# Build binaries and shared libs
64build/soong/soong_ui.bash --make-mode --skip-make "${binaries[@]}"
Jayant Chowdharyea86c042018-01-25 12:07:55 -080065
Logan Chien6c5889e2018-10-04 11:18:06 +080066# Copy binaries and shared libs
67mkdir -p "${SOONG_OUT}/dist/bin"
68cp "${binaries[@]}" "${SOONG_OUT}/dist/bin/"
69cp -R "${SOONG_HOST_OUT}/lib"* "${SOONG_OUT}/dist/"
Jayant Chowdharyea86c042018-01-25 12:07:55 -080070
Logan Chienc3d85932018-10-04 11:24:13 +080071# Copy clang headers
72cp -R "external/clang/lib/Headers" "${SOONG_OUT}/dist/clang-headers"
Logan Chienc6125572018-10-08 10:32:16 +080073cp "prebuilts/clang/host/${OS}-x86/clang-3289846/lib64/clang/3.8/include/arm_neon.h" "${SOONG_OUT}/dist/clang-headers"
74rm "${SOONG_OUT}/dist/clang-headers/CMakeLists.txt"
Logan Chienc3d85932018-10-04 11:24:13 +080075
Logan Chien6c5889e2018-10-04 11:18:06 +080076# Package binaries and shared libs
Jayant Chowdharyea86c042018-01-25 12:07:55 -080077(
Logan Chien6c5889e2018-10-04 11:18:06 +080078 cd "${SOONG_OUT}/dist"
Jayant Chowdharyea86c042018-01-25 12:07:55 -080079 zip -qryX build-prebuilts.zip *
80)
81
82if [ -n "${DIST_DIR}" ]; then
Logan Chien6c5889e2018-10-04 11:18:06 +080083 mkdir -p "${DIST_DIR}" || true
84 cp "${SOONG_OUT}/dist/build-prebuilts.zip" "${DIST_DIR}/"
Jayant Chowdharyea86c042018-01-25 12:07:55 -080085fi