Igor Murashkin | 2a33775 | 2017-06-16 14:34:40 +0000 | [diff] [blame] | 1 | #!/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 | |
| 31 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" |
| 32 | TOP=$DIR/../.. |
| 33 | |
| 34 | pushd "$TOP" >/dev/null # back to android root. |
| 35 | |
| 36 | out=${OUT_DIR:-out} |
| 37 | desugar_jar=$out/host/linux-x86/framework/desugar.jar |
| 38 | |
| 39 | if ! [[ -f $desugar_jar ]]; then |
| 40 | echo "Error: Missing $desugar_jar; did you do a build?" >&2 |
| 41 | exit 1 |
| 42 | fi |
| 43 | |
| 44 | desugar_jar=$(readlink -f "$desugar_jar") # absolute path to desugar jar |
| 45 | popd >/dev/null |
| 46 | |
| 47 | bootjars_args= |
| 48 | mode=target |
| 49 | showcommands=n |
| 50 | while 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 |
| 73 | done |
| 74 | |
Igor Murashkin | 6919639 | 2017-06-16 15:25:32 -0700 | [diff] [blame] | 75 | desugar_args=(--min_sdk_version=10000) |
Igor Murashkin | 2a33775 | 2017-06-16 14:34:40 +0000 | [diff] [blame] | 76 | boot_class_path_list=$($TOP/art/tools/bootjars.sh $bootjars_args --path) |
| 77 | |
| 78 | for path in $boot_class_path_list; do |
| 79 | desugar_args+=(--bootclasspath_entry="$path") |
| 80 | done |
| 81 | |
| 82 | if [[ ${#desugar_args[@]} -eq 0 ]]; then |
| 83 | echo "FATAL: Missing bootjars.sh file path list" >&2 |
| 84 | exit 1 |
| 85 | fi |
| 86 | |
| 87 | if [[ $showcommands == y ]]; then |
| 88 | echo java -jar "$desugar_jar" "${desugar_args[@]}" "$@" |
| 89 | fi |
| 90 | |
| 91 | java -jar "$desugar_jar" "${desugar_args[@]}" "$@" |