Igor Murashkin | 1c843e9 | 2017-06-19 14:33:06 -0700 | [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 javac with the -bootclasspath 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 javac |
| 29 | # |
| 30 | |
| 31 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" |
| 32 | TOP=$DIR/../.. |
| 33 | |
| 34 | if [[ -z $JAVAC ]]; then |
| 35 | JAVAC=javac |
| 36 | fi |
| 37 | |
| 38 | bootjars_args= |
| 39 | mode=target |
| 40 | showcommands=n |
| 41 | while true; do |
| 42 | case $1 in |
| 43 | --help) |
| 44 | echo "Usage: $0 [--mode=host|target] [--core-only] [--show-commands] <javac args>" |
| 45 | exit 0 |
| 46 | ;; |
| 47 | --mode=host) |
| 48 | bootjars_args="$bootjars_args --host" |
| 49 | ;; |
| 50 | --mode=target) |
| 51 | bootjars_args="$bootjars_args --target" |
| 52 | ;; |
| 53 | --core-only) |
| 54 | bootjars_args="$bootjars_args --core" |
| 55 | ;; |
| 56 | --show-commands) |
| 57 | showcommands=y |
| 58 | ;; |
| 59 | *) |
| 60 | break |
| 61 | ;; |
| 62 | esac |
| 63 | shift |
| 64 | done |
| 65 | |
| 66 | javac_bootclasspath=() |
| 67 | boot_class_path_list=$($TOP/art/tools/bootjars.sh $bootjars_args --path) |
| 68 | |
| 69 | |
| 70 | for path in $boot_class_path_list; do |
| 71 | javac_bootclasspath+=("$path") |
| 72 | done |
| 73 | |
| 74 | if [[ ${#javac_bootclasspath[@]} -eq 0 ]]; then |
| 75 | echo "FATAL: Missing bootjars.sh file path list" >&2 |
| 76 | exit 1 |
| 77 | fi |
| 78 | |
| 79 | function join_by { local IFS="$1"; shift; echo "$*"; } |
| 80 | bcp_arg="$(join_by ":" "${javac_bootclasspath[@]}")" |
| 81 | javac_args=(-bootclasspath "$bcp_arg") |
| 82 | |
| 83 | if [[ $showcommands == y ]]; then |
| 84 | echo ${JAVAC} "${javac_args[@]}" "$@" |
| 85 | fi |
| 86 | |
| 87 | ${JAVAC} "${javac_args[@]}" "$@" |