blob: ae7bf0a48b5ba484582a408d0aca76981f69a67c [file] [log] [blame]
Igor Murashkin2a337752017-06-16 14:34:40 +00001#!/bin/bash
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#
18# Calls desugar.jar with the --bootclasspath_entry values passed in automatically.
19# (This avoids having to manually set a boot class path).
20#
21#
22# Script-specific args:
23# --mode=[host|target]: Select between host or target bootclasspath (default target).
24# --core-only: Use only "core" bootclasspath (e.g. do not include framework).
25# --show-commands: Print the desugar command being executed.
26# --help: Print above list of args.
27#
28# All other args are forwarded to desugar.jar
29#
30
31DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
32TOP=$DIR/../..
33
34pushd "$TOP" >/dev/null # back to android root.
35
36out=${OUT_DIR:-out}
37desugar_jar=$out/host/linux-x86/framework/desugar.jar
38
39if ! [[ -f $desugar_jar ]]; then
40 echo "Error: Missing $desugar_jar; did you do a build?" >&2
41 exit 1
42fi
43
44desugar_jar=$(readlink -f "$desugar_jar") # absolute path to desugar jar
45popd >/dev/null
46
47bootjars_args=
48mode=target
49showcommands=n
50while true; do
51 case $1 in
52 --help)
53 echo "Usage: $0 [--mode=host|target] [--core-only] [--show-commands] <desugar args>"
54 exit 0
55 ;;
56 --mode=host)
57 bootjars_args="$bootjars_args --host"
58 ;;
59 --mode=target)
60 bootjars_args="$bootjars_args --target"
61 ;;
62 --core-only)
63 bootjars_args="$bootjars_args --core"
64 ;;
65 --show-commands)
66 showcommands=y
67 ;;
68 *)
69 break
70 ;;
71 esac
72 shift
73done
74
Igor Murashkin69196392017-06-16 15:25:32 -070075desugar_args=(--min_sdk_version=10000)
Igor Murashkin2a337752017-06-16 14:34:40 +000076boot_class_path_list=$($TOP/art/tools/bootjars.sh $bootjars_args --path)
77
78for path in $boot_class_path_list; do
79 desugar_args+=(--bootclasspath_entry="$path")
80done
81
82if [[ ${#desugar_args[@]} -eq 0 ]]; then
83 echo "FATAL: Missing bootjars.sh file path list" >&2
84 exit 1
85fi
86
87if [[ $showcommands == y ]]; then
88 echo java -jar "$desugar_jar" "${desugar_args[@]}" "$@"
89fi
90
91java -jar "$desugar_jar" "${desugar_args[@]}" "$@"