build revision 2de6e083df95afcc27ab2c37a82448f927cb0d87
1#!/bin/bash
2#
3# Copyright 2018 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
17set -e
18
19# Special build logic to handle src-ex .java files which have code that only builds on RI.
20custom_build_logic() {
21  [[ -d ignore.src-ex ]] && mv ignore.src-ex src-ex
22  # src-ex uses code that can only build on RI.
23  ${JAVAC} -source 1.8 -target 1.8 -sourcepath src-ex -sourcepath src -d classes-ex $(find src-ex -name '*.java')
24  # remove src-ex so that default-build doesn't try to build it.
25  [[ -d src-ex ]] && mv src-ex ignore.src-ex
26}
27
28# Build the jars twice. First with applying hiddenapi, creating a boot jar, then
29# a second time without to create a normal jar. We need to do this because we
30# want to load the jar once as an app module and once as a member of the boot
31# class path. The DexFileVerifier would fail on the former as it does not allow
32# hidden API access flags in dex files. DexFileVerifier is not invoked on boot
33# class path dex files, so the boot jar loads fine in the latter case.
34
35export USE_HIDDENAPI=true
36custom_build_logic
37./default-build "$@"
38
39# Move the jar file into the resource folder to be bundled with the test.
40mkdir res
41mv ${TEST_NAME}.jar res/boot.jar
42
43# Clear all intermediate files otherwise default-build would either skip
44# compilation or fail rebuilding.
45rm -rf classes*
46
47export USE_HIDDENAPI=false
48custom_build_logic
49./default-build "$@"
50