• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
31DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
32TOP=$DIR/../..
33
34if [[ -z $JAVAC ]]; then
35  JAVAC=javac
36fi
37
38bootjars_args=
39mode=target
40showcommands=n
41while 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
64done
65
66javac_bootclasspath=()
67boot_class_path_list=$($TOP/art/tools/bootjars.sh $bootjars_args --path)
68
69
70for path in $boot_class_path_list; do
71  javac_bootclasspath+=("$path")
72done
73
74if [[ ${#javac_bootclasspath[@]} -eq 0 ]]; then
75  echo "FATAL: Missing bootjars.sh file path list" >&2
76  exit 1
77fi
78
79function join_by { local IFS="$1"; shift; echo "$*"; }
80bcp_arg="$(join_by ":" "${javac_bootclasspath[@]}")"
81javac_args=(-bootclasspath "$bcp_arg")
82
83if [[ $showcommands == y ]]; then
84  echo ${JAVAC} "${javac_args[@]}" "$@"
85fi
86
87${JAVAC} "${javac_args[@]}" "$@"
88