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# If $JAVAC is set, it will call that instead of 'javac'. 21# 22# 23# Script-specific args: 24# --mode=[host|target|jvm]: 25# Select between host,target,jvm bootclasspath (default target). 26# --core-only: Use only "core" bootclasspath (e.g. do not include framework). 27# Ignored with --mode=jvm. 28# --show-commands: Print the javac command being executed. 29# --help: Print above list of args. 30# 31# All other args are forwarded to javac 32# 33 34DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 35TOP=$DIR/../.. 36 37if [[ -z $JAVAC ]]; then 38 JAVAC=javac 39fi 40 41bootjars_args= 42mode=target 43showcommands=n 44while true; do 45 case $1 in 46 --help) 47 echo "Usage: $0 [--mode=host|target|jvm] [--core-only] [--show-commands] <javac args>" 48 exit 0 49 ;; 50 --mode=host) 51 bootjars_args="$bootjars_args --host" 52 mode=host 53 ;; 54 --mode=target) 55 bootjars_args="$bootjars_args --target" 56 mode=target 57 ;; 58 --mode=jvm) 59 mode=jvm 60 ;; 61 --mode=*) 62 echo "Unsupported $0 usage with --mode=$1" >&2 63 exit 1 64 ;; 65 --core-only) 66 bootjars_args="$bootjars_args --core" 67 ;; 68 --show-commands) 69 showcommands=y 70 ;; 71 *) 72 break 73 ;; 74 esac 75 shift 76done 77 78if [[ $mode == jvm ]]; then 79 # For --mode=jvm: 80 # Do not prepend a -bootclasspath, which will use the default bootclasspath instead. 81 javac_args=() 82else 83 # For --mode=host or --mode=target, look up the correct -bootclasspath for libcore. 84 javac_bootclasspath=() 85 boot_class_path_list=$($TOP/art/tools/bootjars.sh $bootjars_args --path) 86 87 for path in $boot_class_path_list; do 88 javac_bootclasspath+=("$path") 89 done 90 91 if [[ ${#javac_bootclasspath[@]} -eq 0 ]]; then 92 echo "FATAL: Missing bootjars.sh file path list" >&2 93 exit 1 94 fi 95 96 function join_by { local IFS="$1"; shift; echo "$*"; } 97 bcp_arg="$(join_by ":" "${javac_bootclasspath[@]}")" 98 javac_args=(-bootclasspath "$bcp_arg") 99fi 100 101if [[ $showcommands == y ]]; then 102 echo ${JAVAC} "${javac_args[@]}" "$@" 103fi 104 105${JAVAC} "${javac_args[@]}" "$@" 106