1#!/bin/bash -e
2#
3# Copyright (C) 2017 The Android Open Source Project
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#
17
18function die {
19  echo "$0: $*"
20  exit 1
21}
22
23function usage {
24  cat <<EOF
25Usage: $0 [OPTION]
26Build VNDK snapshots for all arches (arm64, arm, x86_64, x86).
27
28  -a, --build-artifacts   include exported header files and flags
29  -h, --help              display this help and exit
30
31EOF
32  exit
33}
34
35additional_option=
36arches="arm64 arm x86_64 x86"
37
38while [[ $# -gt 0 ]]; do
39  case "$1" in
40    (-a|--build-artifacts) additional_option="VNDK_SNAPSHOT_BUILD_ARTIFACTS=true";;
41    (-h|--help) usage;;
42    (*) die "Unknown option: '$1'
43Try '$0 --help' for more information.";;
44  esac
45  shift
46done
47
48export TARGET_BUILD_VARIANT=user
49export BOARD_VNDK_VERSION=current
50
51for arch in $arches; do
52  echo "-----Generating VNDK snapshot for $arch"
53  build/soong/soong_ui.bash --make-mode vndk dist TARGET_PRODUCT=aosp_$arch $additional_option
54done
55