1 #!/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 26 export ORIGINAL_JAVAC="$JAVAC" 27 28 # Delete CriticalNative.java, FastNative.java annotations after building the .class files. 29 function 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 38 export -f javac_wrapper 39 export JAVAC=javac_wrapper 40 41 ###################################################################### 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 46 export ORIGINAL_DX="$DX" 47 48 # Filter out --debug flag from dx. 49 function 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 64 export -f dx_wrapper 65 export DX=dx_wrapper 66 67 ./default-build "$@" 68