1#!/bin/sh
2#
3# Copyright (C) 2023 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
17ARG_SHORT=d:,t:,h
18ARG_LONG=dist_dir:,target_product:,help
19OPTS=$(getopt -n build_with_artifact --options $ARG_SHORT --longoptions $ARG_LONG -- "$@")
20
21eval set -- "$OPTS"
22
23function print_usage(){
24  echo "usage: development/treble/build_with_artifact.sh --dist_dir <dist_dir> --target_product <target_product>"
25  exit 2
26}
27
28while :
29do
30  case "$1" in
31    -d | --dist_dir )
32      DIST_DIR="$2"
33      shift 2
34      ;;
35    -t | --target_product )
36      TARGET_PRODUCT="$2"
37      shift 2
38      ;;
39    -h | --help )
40      print_usage
41      ;;
42    -- )
43      shift;
44      break
45      ;;
46    * )
47      print_usage
48      ;;
49  esac
50done
51
52if [ -z DIST_DIR ] || [ -z TARGET_PRODUCT ] ; then
53  print_usage
54fi
55
56BUILD_WITH_PARTIAL_ARTIFACT=true build/soong/soong_ui.bash --make-mode TARGET_PRODUCT=$TARGET_PRODUCT TARGET_BUILD_VARIANT=userdebug droid dist DIST_DIR=$DIST_DIR