blob: e563d734c26b5672533dbc0c67fb048dd9c518ba [file] [log] [blame]
Igor Murashkin4db66ab2017-06-19 11:45:40 -07001#!/bin/bash
2#
3# Copyright 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# Perform a mostly normal build.
19# Since this test imports 'dalvik.annotation.optimization.FastNative' (and CriticalNative),
20# we do a bit of trickery to allow the annotations to be used at javac-compile time,
21# but remove them afterwards so it doesn't end up in the dex file.
22#
23# This enables the test to compile with vanilla RI javac and work on either ART or RI.
24#
25
26export ORIGINAL_JAVAC="$JAVAC"
27
28# Delete CriticalNative.java, FastNative.java annotations after building the .class files.
29function javac_wrapper {
30 $ORIGINAL_JAVAC "$@"
31 local stat=$?
32
33 [[ -d classes ]] && (find classes/dalvik -name '*.class' | xargs rm -rf)
34
35 return $stat
36}
37
38export -f javac_wrapper
39export JAVAC=javac_wrapper
40
Igor Murashkin35f1d082017-08-29 13:50:13 -070041######################################################################
42
43# Use the original dx with no extra magic or pessimizing flags.
44# This ensures that any default optimizations that dx do would not break JNI.
45
46export ORIGINAL_DX="$DX"
47
48# Filter out --debug flag from dx.
49function dx_wrapper {
50 local args=("$@")
51 local args_filtered=()
52 for i in "${args[@]}"; do
53 case "$i" in
54 --debug)
55 ;;
56 *)
57 args_filtered+=("$i")
58 ;;
59 esac
60 done
61 "$ORIGINAL_DX" "${args_filtered[@]}"
62}
63
64export -f dx_wrapper
65export DX=dx_wrapper
66
Igor Murashkin4db66ab2017-06-19 11:45:40 -070067./default-build "$@"