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# Build the jars twice. First with applying hiddenapi, creating a boot jar, then
20# a second time without to create a normal jar. We need to do this because we
21# want to load the jar once as an app module and once as a member of the boot
22# class path. The DexFileVerifier would fail on the former as it does not allow
23# hidden API access flags in dex files. DexFileVerifier is not invoked on boot
24# class path dex files, so the boot jar loads fine in the latter case.
25
26export USE_HIDDENAPI=true
27./default-build "$@"
28
29# Move the jar file into the resource folder to be bundled with the test.
30mkdir res
31mv ${TEST_NAME}.jar res/boot.jar
32
33# Clear all intermediate files otherwise default-build would either skip
34# compilation or fail rebuilding.
35rm -rf classes*
36
37export USE_HIDDENAPI=false
38./default-build "$@"
39