blob: 1dced32e96d1c6639a8cd5fd2c361c961f3e4af8 [file] [log] [blame]
Nicolas Geoffrayfbeca752015-05-29 10:54:12 +01001#!/bin/bash
2#
3# Copyright (C) 2015 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
17if [ ! -d art ]; then
18 echo "Script needs to be run at the root of the android tree"
19 exit 1
20fi
21
Nicolas Geoffray1f8dbf82015-06-13 13:19:16 +000022common_targets="vogar vogar.jar core-tests apache-harmony-jdwp-tests-hostdex out/host/linux-x86/bin/adb jsr166-tests"
Nicolas Geoffrayfbeca752015-05-29 10:54:12 +010023android_root="/data/local/tmp/system"
24linker="linker"
25mode="target"
26j_arg="-j$(nproc)"
Roland Levillainb8b93562015-08-20 17:49:56 +010027showcommands=
Nicolas Geoffrayfbeca752015-05-29 10:54:12 +010028make_command=
29
30if [[ "$TARGET_PRODUCT" == "armv8" ]]; then
31 linker="linker64"
32fi
33
34if [[ "$ART_TEST_ANDROID_ROOT" != "" ]]; then
35 android_root="$ART_TEST_ANDROID_ROOT"
36fi
37
38while true; do
39 if [[ "$1" == "--host" ]]; then
40 mode="host"
41 shift
42 elif [[ "$1" == "--target" ]]; then
43 mode="target"
44 shift
45 elif [[ "$1" == "--32" ]]; then
46 linker="linker"
47 shift
48 elif [[ "$1" == "--64" ]]; then
49 linker="linker64"
50 shift
51 elif [[ "$1" == "--android-root" ]]; then
52 shift
53 android_root=$1
54 shift
55 elif [[ "$1" == -j* ]]; then
Nicolas Geoffray667b99e2015-05-29 12:17:06 +010056 j_arg=$1
Nicolas Geoffrayfbeca752015-05-29 10:54:12 +010057 shift
Roland Levillainb8b93562015-08-20 17:49:56 +010058 elif [[ "$1" == "--showcommands" ]]; then
59 showcommands="showcommands"
60 shift
Nicolas Geoffrayfbeca752015-05-29 10:54:12 +010061 elif [[ "$1" == "" ]]; then
62 break
63 fi
64done
65
66if [[ $mode == "host" ]]; then
Nicolas Geoffray547fa112015-06-12 12:41:42 +010067 make_command="make $j_arg build-art-host-tests $common_targets out/host/linux-x86/lib/libjavacoretests.so out/host/linux-x86/lib64/libjavacoretests.so"
Nicolas Geoffrayfbeca752015-05-29 10:54:12 +010068 echo "Executing $make_command"
69 $make_command
70elif [[ $mode == "target" ]]; then
71 # We need to provide our own linker in case the linker on the device
72 # is out of date.
73 env="TARGET_GLOBAL_LDFLAGS=-Wl,-dynamic-linker=$android_root/bin/$linker"
74 # Use '-e' to force the override of TARGET_GLOBAL_LDFLAGS.
75 # Also, we build extra tools that will be used by tests, so that
76 # they are compiled with our own linker.
Roland Levillainb8b93562015-08-20 17:49:56 +010077 make_command="make -e $j_arg $showcommands build-art-target-tests $common_targets libjavacrypto libjavacoretests linker toybox toolbox sh"
Nicolas Geoffrayfbeca752015-05-29 10:54:12 +010078 echo "Executing env $env $make_command"
79 env $env $make_command
80fi
81