• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash -e
2#
3# Copyright (C) 2022 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 usage() {
19  cat <<EOF
20Usage: $0 -d device-name -p product-name -r dist-dir -i build-id [targets]
21Builds a vendor image for given product and analyze ninja inputs.
22
23  -d  device name to build (e.g. vsoc_x86_64)
24  -p  product name to build (e.g. cf_x86_64_phone)
25  -r  directory for dist (e.g. out/dist)
26  -i  build ID
27  -u  whether it is an unbundled build
28  -h  display this help and exit
29
30EOF
31  exit 1
32}
33
34while getopts d:p:r:i:uh flag
35do
36    case "${flag}" in
37        d) device=${OPTARG};;
38        p) product=${OPTARG};;
39        r) dist_dir=${OPTARG};;
40        i) build_id=${OPTARG};;
41        u) unbundled_build=true;;
42        h) usage;;
43        *) usage;;
44    esac
45done
46
47extra_targets=${@: ${OPTIND}}
48
49if [[ -z "$device" || -z "$product" || -z "$dist_dir" || -z "$build_id" ]]; then
50  echo "missing arguments"
51  usage
52fi
53
54if [[ "$unbundled_build" = true ]]; then
55  export TARGET_BUILD_UNBUNDLED_IMAGE=true
56fi
57
58export ALLOW_MISSING_DEPENDENCIES=true
59export SKIP_VNDK_VARIANTS_CHECK=true
60export DIST_DIR=$dist_dir
61
62build/soong/soong_ui.bash --make-mode vendorimage collect_ninja_inputs dist $extra_targets \
63  TARGET_PRODUCT=$product TARGET_BUILD_VARIANT=userdebug
64
65cp out/target/product/$device/vendor.img $dist_dir
66
67out/host/linux-x86/bin/collect_ninja_inputs -n prebuilts/build-tools/linux-x86/bin/ninja \
68  -f out/combined-$product.ninja -t vendorimage -m $dist_dir/manifest_$build_id.xml \
69  --out $dist_dir/logs/ninja_inputs
70