blob: 6139cb9ae22d6e90e45700266f6df1a0a2827856 [file] [log] [blame]
Carl Shapiro7b216702011-06-17 15:09:26 -07001#
2# Copyright (C) 2011 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17LOCAL_PATH := $(call my-dir)
Carl Shapiro7b216702011-06-17 15:09:26 -070018
Brian Carlstrom7940e442013-07-12 13:46:57 -070019art_path := $(LOCAL_PATH)
20art_build_path := $(art_path)/build
Brian Carlstrom1f8730b2013-11-13 17:36:23 -080021include $(art_build_path)/Android.common.mk
Brian Carlstromcdc8de42011-07-19 14:23:17 -070022
Brian Carlstromb2793372012-03-17 18:27:16 -070023########################################################################
Brian Carlstrom62e3ee32012-06-18 14:58:55 -070024# clean-oat targets
25#
26
27# following the example of build's dont_bother for clean targets
28ifneq (,$(filter clean-oat,$(MAKECMDGOALS)))
29art_dont_bother := true
30endif
31ifneq (,$(filter clean-oat-host,$(MAKECMDGOALS)))
32art_dont_bother := true
33endif
34ifneq (,$(filter clean-oat-target,$(MAKECMDGOALS)))
35art_dont_bother := true
36endif
37
38.PHONY: clean-oat
39clean-oat: clean-oat-host clean-oat-target
40
41.PHONY: clean-oat-host
42clean-oat-host:
Brian Carlstrom999cd432013-06-22 23:08:53 -070043 rm -f $(ART_NATIVETEST_OUT)/*.odex
Brian Carlstrom62e3ee32012-06-18 14:58:55 -070044 rm -f $(ART_NATIVETEST_OUT)/*.oat
45 rm -f $(ART_NATIVETEST_OUT)/*.art
Brian Carlstrom999cd432013-06-22 23:08:53 -070046 rm -f $(ART_TEST_OUT)/*.odex
Brian Carlstrom62e3ee32012-06-18 14:58:55 -070047 rm -f $(ART_TEST_OUT)/*.oat
48 rm -f $(ART_TEST_OUT)/*.art
Brian Carlstrom30e2ea42013-06-19 23:25:37 -070049 rm -f $(DALVIK_CACHE_OUT)/*@classes.dex
Brian Carlstrom7675e162013-06-10 16:18:04 -070050 rm -f $(DALVIK_CACHE_OUT)/*.oat
51 rm -f $(DALVIK_CACHE_OUT)/*.art
Brian Carlstrom999cd432013-06-22 23:08:53 -070052 rm -f $(HOST_OUT_JAVA_LIBRARIES)/*.odex
Brian Carlstrom62e3ee32012-06-18 14:58:55 -070053 rm -f $(HOST_OUT_JAVA_LIBRARIES)/*.oat
54 rm -f $(HOST_OUT_JAVA_LIBRARIES)/*.art
Brian Carlstrom999cd432013-06-22 23:08:53 -070055 rm -f $(TARGET_OUT_JAVA_LIBRARIES)/*.odex
Brian Carlstrom62e3ee32012-06-18 14:58:55 -070056 rm -f $(TARGET_OUT_JAVA_LIBRARIES)/*.oat
57 rm -f $(TARGET_OUT_JAVA_LIBRARIES)/*.art
Brian Carlstromb32a3ad2014-01-20 14:48:07 -080058 rm -f $(DEXPREOPT_PRODUCT_DIR_FULL_PATH)/$(DEXPREOPT_BOOT_JAR_DIR)/*.oat
59 rm -f $(DEXPREOPT_PRODUCT_DIR_FULL_PATH)/$(DEXPREOPT_BOOT_JAR_DIR)/*.art
Brian Carlstrom999cd432013-06-22 23:08:53 -070060 rm -f $(TARGET_OUT_UNSTRIPPED)/system/framework/*.odex
Brian Carlstrom1d6848c2013-03-06 15:03:52 -080061 rm -f $(TARGET_OUT_UNSTRIPPED)/system/framework/*.oat
Brian Carlstrom999cd432013-06-22 23:08:53 -070062 rm -f $(TARGET_OUT_APPS)/*.odex
Brian Carlstrom30e2ea42013-06-19 23:25:37 -070063 rm -f $(TARGET_OUT_INTERMEDIATES)/JAVA_LIBRARIES/*_intermediates/javalib.odex
64 rm -f $(TARGET_OUT_INTERMEDIATES)/APPS/*_intermediates/*.odex
Colin Crossdc781a12014-02-04 16:22:03 -080065ifdef TARGET_2ND_ARCH
66 rm -f $(2ND_TARGET_OUT_INTERMEDIATES)/JAVA_LIBRARIES/*_intermediates/javalib.odex
67 rm -f $(2ND_TARGET_OUT_INTERMEDIATES)/APPS/*_intermediates/*.odex
68endif
Brian Carlstrom30e2ea42013-06-19 23:25:37 -070069 rm -rf /tmp/test-*/dalvik-cache/*@classes.dex
Hiroshi Yamauchibe1ca552014-01-15 11:46:48 -080070 rm -rf /tmp/android-data/dalvik-cache/*@classes.dex
Brian Carlstrom62e3ee32012-06-18 14:58:55 -070071
72.PHONY: clean-oat-target
73clean-oat-target:
74 adb remount
Brian Carlstrom30e2ea42013-06-19 23:25:37 -070075 adb shell rm $(ART_NATIVETEST_DIR)/*.odex
Brian Carlstrom62e3ee32012-06-18 14:58:55 -070076 adb shell rm $(ART_NATIVETEST_DIR)/*.oat
77 adb shell rm $(ART_NATIVETEST_DIR)/*.art
Brian Carlstrom30e2ea42013-06-19 23:25:37 -070078 adb shell rm $(ART_TEST_DIR)/*.odex
Brian Carlstrom62e3ee32012-06-18 14:58:55 -070079 adb shell rm $(ART_TEST_DIR)/*.oat
80 adb shell rm $(ART_TEST_DIR)/*.art
Brian Carlstromb32a3ad2014-01-20 14:48:07 -080081 adb shell rm $(ART_DALVIK_CACHE_DIR)/*.dex
82 adb shell rm $(ART_DALVIK_CACHE_DIR)/*.oat
83 adb shell rm $(ART_DALVIK_CACHE_DIR)/*.art
Brian Carlstrom62e3ee32012-06-18 14:58:55 -070084 adb shell rm $(DEXPREOPT_BOOT_JAR_DIR)/*.oat
85 adb shell rm $(DEXPREOPT_BOOT_JAR_DIR)/*.art
Brian Carlstrom30e2ea42013-06-19 23:25:37 -070086 adb shell rm system/app/*.odex
87 adb shell rm data/run-test/test-*/dalvik-cache/*@classes.dex
Brian Carlstrom62e3ee32012-06-18 14:58:55 -070088
89ifneq ($(art_dont_bother),true)
90
91########################################################################
Brian Carlstromb2793372012-03-17 18:27:16 -070092# product targets
Brian Carlstrom7940e442013-07-12 13:46:57 -070093include $(art_path)/runtime/Android.mk
94include $(art_path)/compiler/Android.mk
95include $(art_path)/dex2oat/Android.mk
Ian Rogers02ed4c02013-09-06 13:10:04 -070096include $(art_path)/disassembler/Android.mk
Brian Carlstrom7940e442013-07-12 13:46:57 -070097include $(art_path)/oatdump/Android.mk
Brian Carlstromfa50baa2013-08-02 01:00:27 -070098include $(art_path)/dalvikvm/Android.mk
Nicolas Geoffray9583fbc2014-02-28 15:21:07 +000099include $(art_path)/tools/Android.mk
Brian Carlstrom7940e442013-07-12 13:46:57 -0700100include $(art_build_path)/Android.oat.mk
Carl Shapiro7b216702011-06-17 15:09:26 -0700101
Brian Carlstromb2793372012-03-17 18:27:16 -0700102# ART_HOST_DEPENDENCIES depends on Android.executable.mk above for ART_HOST_EXECUTABLES
Brian Carlstromfd7ad0a2013-12-10 18:20:45 -0800103ART_HOST_DEPENDENCIES := $(ART_HOST_EXECUTABLES) $(HOST_OUT_JAVA_LIBRARIES)/core-libart-hostdex.jar
Elliott Hughesf1eedca2012-04-20 16:00:32 -0700104ART_HOST_DEPENDENCIES += $(HOST_OUT_SHARED_LIBRARIES)/libjavacore$(ART_HOST_SHLIB_EXTENSION)
Brian Carlstromfd7ad0a2013-12-10 18:20:45 -0800105ART_TARGET_DEPENDENCIES := $(ART_TARGET_EXECUTABLES) $(TARGET_OUT_JAVA_LIBRARIES)/core-libart.jar $(TARGET_OUT_SHARED_LIBRARIES)/libjavacore.so
Brian Carlstrom15803792012-03-13 00:53:08 -0700106
Brian Carlstromb2793372012-03-17 18:27:16 -0700107########################################################################
108# test targets
Brian Carlstrom15803792012-03-13 00:53:08 -0700109
Brian Carlstrom7940e442013-07-12 13:46:57 -0700110include $(art_path)/test/Android.mk
111include $(art_build_path)/Android.gtest.mk
Brian Carlstromb2793372012-03-17 18:27:16 -0700112
113# The ART_*_TEST_DEPENDENCIES definitions:
114# - depend on Android.oattest.mk above for ART_TEST_*_DEX_FILES
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800115# - depend on Android.gtest.mk above for ART_*_GTEST_EXECUTABLES
116ART_HOST_TEST_DEPENDENCIES := $(ART_HOST_DEPENDENCIES) $(ART_HOST_GTEST_EXECUTABLES) $(ART_TEST_HOST_DEX_FILES) $(HOST_CORE_IMG_OUT)
117ART_TARGET_TEST_DEPENDENCIES := $(ART_TARGET_DEPENDENCIES) $(ART_TARGET_GTEST_EXECUTABLES) $(ART_TEST_TARGET_DEX_FILES) $(TARGET_CORE_IMG_OUT)
Brian Carlstrom16192862011-09-12 17:50:06 -0700118
Brian Carlstrom7940e442013-07-12 13:46:57 -0700119include $(art_build_path)/Android.libarttest.mk
Brian Carlstrom934486c2011-07-12 23:42:50 -0700120
Brian Carlstrom4a96b602011-07-26 16:40:23 -0700121# "mm test-art" to build and run all tests on host and device
122.PHONY: test-art
123test-art: test-art-host test-art-target
Brian Carlstrom395520e2011-09-25 19:35:00 -0700124 @echo test-art PASSED
Brian Carlstrom4a96b602011-07-26 16:40:23 -0700125
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -0700126.PHONY: test-art-gtest
Brian Carlstromb2793372012-03-17 18:27:16 -0700127test-art-gtest: test-art-host-gtest test-art-target-gtest
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -0700128 @echo test-art-gtest PASSED
129
Brian Carlstromb2793372012-03-17 18:27:16 -0700130.PHONY: test-art-oat
Brian Carlstromdbaa93a2013-07-31 15:13:10 -0700131test-art-oat: test-art-host-oat test-art-target-oat
Brian Carlstromb2793372012-03-17 18:27:16 -0700132 @echo test-art-oat PASSED
Elliott Hughes2cae5a22011-08-14 14:27:25 -0700133
Brian Carlstrom08981ab2012-05-25 18:40:15 -0700134.PHONY: test-art-run-test
Brian Carlstromdbaa93a2013-07-31 15:13:10 -0700135test-art-run-test: test-art-host-run-test test-art-target-run-test
Brian Carlstrom08981ab2012-05-25 18:40:15 -0700136 @echo test-art-run-test PASSED
137
Brian Carlstrombc2f3e32011-09-22 17:16:54 -0700138########################################################################
139# host test targets
140
Brian Carlstrom934486c2011-07-12 23:42:50 -0700141# "mm test-art-host" to build and run all host tests
142.PHONY: test-art-host
Brian Carlstromdbaa93a2013-07-31 15:13:10 -0700143test-art-host: test-art-host-gtest test-art-host-oat test-art-host-run-test
Brian Carlstrom395520e2011-09-25 19:35:00 -0700144 @echo test-art-host PASSED
Brian Carlstrom59848da2011-07-23 20:35:19 -0700145
Ian Rogers85d9ba62013-01-16 22:32:12 -0800146.PHONY: test-art-host-interpreter
Brian Carlstromdbaa93a2013-07-31 15:13:10 -0700147test-art-host-interpreter: test-art-host-oat-interpreter test-art-host-run-test-interpreter
Ian Rogers85d9ba62013-01-16 22:32:12 -0800148 @echo test-art-host-interpreter PASSED
149
Brian Carlstromb0aa9d32012-04-07 23:12:22 -0700150.PHONY: test-art-host-dependencies
Brian Carlstrom43534862014-02-19 01:13:52 -0800151test-art-host-dependencies: $(ART_HOST_TEST_DEPENDENCIES) $(HOST_OUT_SHARED_LIBRARIES)/libarttest$(ART_HOST_SHLIB_EXTENSION) $(HOST_CORE_DEX_LOCATIONS)
Brian Carlstromb0aa9d32012-04-07 23:12:22 -0700152
Brian Carlstromb2793372012-03-17 18:27:16 -0700153.PHONY: test-art-host-gtest
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800154test-art-host-gtest: $(ART_HOST_GTEST_TARGETS)
Brian Carlstromb2793372012-03-17 18:27:16 -0700155 @echo test-art-host-gtest PASSED
Elliott Hughes2cae5a22011-08-14 14:27:25 -0700156
Brian Carlstromb2793372012-03-17 18:27:16 -0700157# "mm valgrind-test-art-host-gtest" to build and run the host gtests under valgrind.
158.PHONY: valgrind-test-art-host-gtest
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800159valgrind-test-art-host-gtest: $(ART_HOST_VALGRIND_GTEST_TARGETS)
Brian Carlstromb2793372012-03-17 18:27:16 -0700160 @echo valgrind-test-art-host-gtest PASSED
161
Brian Carlstromdbaa93a2013-07-31 15:13:10 -0700162.PHONY: test-art-host-oat-default
163test-art-host-oat-default: $(ART_TEST_HOST_OAT_DEFAULT_TARGETS)
164 @echo test-art-host-oat-default PASSED
165
166.PHONY: test-art-host-oat-interpreter
167test-art-host-oat-interpreter: $(ART_TEST_HOST_OAT_INTERPRETER_TARGETS)
168 @echo test-art-host-oat-interpreter PASSED
169
Brian Carlstromb2793372012-03-17 18:27:16 -0700170.PHONY: test-art-host-oat
Brian Carlstromdbaa93a2013-07-31 15:13:10 -0700171test-art-host-oat: test-art-host-oat-default test-art-host-oat-interpreter
Brian Carlstromb2793372012-03-17 18:27:16 -0700172 @echo test-art-host-oat PASSED
Elliott Hughes5511f212011-08-12 18:07:45 -0700173
Brian Carlstrom4855cd52012-04-03 21:38:13 -0700174define declare-test-art-host-run-test
Brian Carlstromdbaa93a2013-07-31 15:13:10 -0700175.PHONY: test-art-host-run-test-default-$(1)
Brian Carlstrom43534862014-02-19 01:13:52 -0800176test-art-host-run-test-default-$(1): test-art-host-dependencies $(DX) $(HOST_OUT_EXECUTABLES)/jasmin
Nicolas Geoffray92cf83e2014-03-18 17:59:20 +0000177 DX=$(abspath $(DX)) JASMIN=$(abspath $(HOST_OUT_EXECUTABLES)/jasmin) art/test/run-test $(DALVIKVM_FLAGS) --host $(1)
Brian Carlstromdbaa93a2013-07-31 15:13:10 -0700178 @echo test-art-host-run-test-default-$(1) PASSED
Brian Carlstrom4855cd52012-04-03 21:38:13 -0700179
Brian Carlstromdbaa93a2013-07-31 15:13:10 -0700180TEST_ART_HOST_RUN_TEST_DEFAULT_TARGETS += test-art-host-run-test-default-$(1)
Ian Rogers27cedf82012-11-21 11:42:43 -0800181
Brian Carlstromdbaa93a2013-07-31 15:13:10 -0700182.PHONY: test-art-host-run-test-interpreter-$(1)
Brian Carlstrom43534862014-02-19 01:13:52 -0800183test-art-host-run-test-interpreter-$(1): test-art-host-dependencies $(DX) $(HOST_OUT_EXECUTABLES)/jasmin
Nicolas Geoffray92cf83e2014-03-18 17:59:20 +0000184 DX=$(abspath $(DX)) JASMIN=$(abspath $(HOST_OUT_EXECUTABLES)/jasmin) art/test/run-test $(DALVIKVM_FLAGS) --host --interpreter $(1)
Brian Carlstromdbaa93a2013-07-31 15:13:10 -0700185 @echo test-art-host-run-test-interpreter-$(1) PASSED
Ian Rogers27cedf82012-11-21 11:42:43 -0800186
Brian Carlstromdbaa93a2013-07-31 15:13:10 -0700187TEST_ART_HOST_RUN_TEST_INTERPRETER_TARGETS += test-art-host-run-test-interpreter-$(1)
Brian Carlstroma404db02013-08-28 09:37:40 -0700188
189.PHONY: test-art-host-run-test-$(1)
190test-art-host-run-test-$(1): test-art-host-run-test-default-$(1) test-art-host-run-test-interpreter-$(1)
191
Brian Carlstrom4855cd52012-04-03 21:38:13 -0700192endef
193
Brian Carlstrom934ce802014-04-01 18:09:33 -0700194$(foreach test, $(TEST_ART_RUN_TESTS), $(eval $(call declare-test-art-host-run-test,$(test))))
Brian Carlstrom4855cd52012-04-03 21:38:13 -0700195
Brian Carlstromdbaa93a2013-07-31 15:13:10 -0700196.PHONY: test-art-host-run-test-default
197test-art-host-run-test-default: $(TEST_ART_HOST_RUN_TEST_DEFAULT_TARGETS)
198 @echo test-art-host-run-test-default PASSED
Brian Carlstrom4855cd52012-04-03 21:38:13 -0700199
Brian Carlstromdbaa93a2013-07-31 15:13:10 -0700200.PHONY: test-art-host-run-test-interpreter
201test-art-host-run-test-interpreter: $(TEST_ART_HOST_RUN_TEST_INTERPRETER_TARGETS)
202 @echo test-art-host-run-test-interpreter PASSED
203
204.PHONY: test-art-host-run-test
205test-art-host-run-test: test-art-host-run-test-default test-art-host-run-test-interpreter
206 @echo test-art-host-run-test PASSED
Ian Rogers27cedf82012-11-21 11:42:43 -0800207
Brian Carlstrombc2f3e32011-09-22 17:16:54 -0700208########################################################################
209# target test targets
210
211# "mm test-art-target" to build and run all target tests
Brian Carlstrom4a96b602011-07-26 16:40:23 -0700212.PHONY: test-art-target
Brian Carlstrome24fa612011-09-29 00:53:55 -0700213test-art-target: test-art-target-gtest test-art-target-oat test-art-target-run-test
Brian Carlstrom395520e2011-09-25 19:35:00 -0700214 @echo test-art-target PASSED
Brian Carlstrom86927212011-09-15 11:31:11 -0700215
Brian Carlstromb0aa9d32012-04-07 23:12:22 -0700216.PHONY: test-art-target-dependencies
Brian Carlstrom43534862014-02-19 01:13:52 -0800217test-art-target-dependencies: $(ART_TARGET_TEST_DEPENDENCIES) $(ART_TEST_OUT)/libarttest.so
Brian Carlstromb0aa9d32012-04-07 23:12:22 -0700218
Brian Carlstrom86927212011-09-15 11:31:11 -0700219.PHONY: test-art-target-sync
Brian Carlstromb0aa9d32012-04-07 23:12:22 -0700220test-art-target-sync: test-art-target-dependencies
Brian Carlstrom4a96b602011-07-26 16:40:23 -0700221 adb remount
222 adb sync
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -0700223 adb shell mkdir -p $(ART_TEST_DIR)
Brian Carlstrom86927212011-09-15 11:31:11 -0700224
225.PHONY: test-art-target-gtest
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800226test-art-target-gtest: $(ART_TARGET_GTEST_TARGETS)
Brian Carlstrom86927212011-09-15 11:31:11 -0700227
228.PHONY: test-art-target-oat
Brian Carlstromb2793372012-03-17 18:27:16 -0700229test-art-target-oat: $(ART_TEST_TARGET_OAT_TARGETS)
Brian Carlstrom395520e2011-09-25 19:35:00 -0700230 @echo test-art-target-oat PASSED
Brian Carlstrom4a96b602011-07-26 16:40:23 -0700231
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700232define declare-test-art-target-run-test-impl
233.PHONY: test-art-target-run-test-$(1)$($(2)ART_PHONY_TEST_TARGET_SUFFIX)
234test-art-target-run-test-$(1)$($(2)ART_PHONY_TEST_TARGET_SUFFIX): test-art-target-sync $(DX) $(HOST_OUT_EXECUTABLES)/jasmin
235 DX=$(abspath $(DX)) JASMIN=$(abspath $(HOST_OUT_EXECUTABLES)/jasmin) art/test/run-test $(DALVIKVM_FLAGS) $(1) $(3)
236 @echo test-art-target-run-test-$(1)$($(2)ART_PHONY_TEST_TARGET_SUFFIX) PASSED
237endef
Brian Carlstrome24fa612011-09-29 00:53:55 -0700238
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700239define declare-test-art-target-run-test
240
241 ifdef TARGET_2ND_ARCH
242 $(call declare-test-art-target-run-test-impl,$(1),2ND_,)
243
244 ifneq ($(ART_PHONY_TEST_TARGET_SUFFIX),)
245 # Link primary to non-suffix
246test-art-target-run-test-$(1): test-art-target-run-test-$(1)$(ART_PHONY_TEST_TARGET_SUFFIX)
247 endif
248 endif
249 $(call declare-test-art-target-run-test-impl,$(1),,--$(ART_TARGET_BINARY_SUFFIX))
250
251 TEST_ART_TARGET_RUN_TEST_TARGETS += test-art-target-run-test-$(1)
Brian Carlstroma404db02013-08-28 09:37:40 -0700252
253test-art-run-test-$(1): test-art-host-run-test-$(1) test-art-target-run-test-$(1)
254
Brian Carlstrom37c44442012-03-06 22:21:18 -0800255endef
256
Brian Carlstrom934ce802014-04-01 18:09:33 -0700257$(foreach test, $(TEST_ART_RUN_TESTS), $(eval $(call declare-test-art-target-run-test,$(test))))
Brian Carlstrom37c44442012-03-06 22:21:18 -0800258
259.PHONY: test-art-target-run-test
260test-art-target-run-test: $(TEST_ART_TARGET_RUN_TEST_TARGETS)
261 @echo test-art-target-run-test PASSED
Brian Carlstrome24fa612011-09-29 00:53:55 -0700262
Brian Carlstrombc2f3e32011-09-22 17:16:54 -0700263########################################################################
Brian Carlstrom04941d92012-02-19 01:47:51 -0800264# oat-target and oat-target-sync targets
Brian Carlstrombc2f3e32011-09-22 17:16:54 -0700265
Brian Carlstrom04941d92012-02-19 01:47:51 -0800266OAT_TARGET_TARGETS :=
267
268# $(1): input jar or apk target location
269define declare-oat-target-target
Brian Carlstrom46b8a622012-06-19 23:13:22 -0700270ifneq (,$(filter $(1),$(addprefix system/app/,$(addsuffix .apk,$(PRODUCT_DEX_PREOPT_PACKAGES_IN_DATA)))))
Brian Carlstrom999cd432013-06-22 23:08:53 -0700271OUT_OAT_FILE := $(call dalvik-cache-out,$(1)/classes.dex)
Brian Carlstrom46b8a622012-06-19 23:13:22 -0700272else
Brian Carlstrom999cd432013-06-22 23:08:53 -0700273OUT_OAT_FILE := $(PRODUCT_OUT)/$(basename $(1)).odex
Brian Carlstrom46b8a622012-06-19 23:13:22 -0700274endif
Shih-wei Liao2e01f242012-05-28 03:11:59 -0700275
276ifeq ($(ONE_SHOT_MAKEFILE),)
Brian Carlstrom90e27412013-03-13 21:51:47 -0700277# ONE_SHOT_MAKEFILE is empty for a top level build and we don't want
278# to define the oat-target-* rules there because they will conflict
279# with the build/core/dex_preopt.mk defined rules.
Brian Carlstrom04941d92012-02-19 01:47:51 -0800280.PHONY: oat-target-$(1)
Brian Carlstrom90e27412013-03-13 21:51:47 -0700281oat-target-$(1):
Shih-wei Liao2e01f242012-05-28 03:11:59 -0700282
283else
284.PHONY: oat-target-$(1)
Shih-wei Liao7eea0e82012-05-28 23:56:21 -0700285oat-target-$(1): $$(OUT_OAT_FILE)
Shih-wei Liao2e01f242012-05-28 03:11:59 -0700286
Nicolas Geoffray1db132d2014-03-26 10:56:24 +0000287$$(OUT_OAT_FILE): $(PRODUCT_OUT)/$(1) $(DEFAULT_DEX_PREOPT_BUILT_IMAGE) $(DEX2OATD_DEPENDENCY)
Brian Carlstrom90e27412013-03-13 21:51:47 -0700288 @mkdir -p $$(dir $$@)
Nicolas Geoffray1db132d2014-03-26 10:56:24 +0000289 $(DEX2OATD) --runtime-arg -Xms64m --runtime-arg -Xmx64m --boot-image=$(DEFAULT_DEX_PREOPT_BUILT_IMAGE) --dex-file=$(PRODUCT_OUT)/$(1) --dex-location=/$(1) --oat-file=$$@ --instruction-set=$(TARGET_ARCH) --instruction-set-features=$(TARGET_INSTRUCTION_SET_FEATURES) --android-root=$(PRODUCT_OUT)/system
Shih-wei Liao2e01f242012-05-28 03:11:59 -0700290
291endif
Brian Carlstrom04941d92012-02-19 01:47:51 -0800292
293OAT_TARGET_TARGETS += oat-target-$(1)
Brian Carlstroma9f19782011-10-13 00:14:47 -0700294endef
295
Brian Carlstrombd411022012-02-07 12:09:09 -0800296$(foreach file,\
297 $(filter-out\
Brian Carlstrom7ab763c2013-12-09 00:38:02 -0800298 $(addprefix $(TARGET_OUT_JAVA_LIBRARIES)/,$(addsuffix .jar,$(LIBART_TARGET_BOOT_JARS))),\
Brian Carlstrombd411022012-02-07 12:09:09 -0800299 $(wildcard $(TARGET_OUT_APPS)/*.apk) $(wildcard $(TARGET_OUT_JAVA_LIBRARIES)/*.jar)),\
Brian Carlstrom04941d92012-02-19 01:47:51 -0800300 $(eval $(call declare-oat-target-target,$(subst $(PRODUCT_OUT)/,,$(file)))))
301
302.PHONY: oat-target
Brian Carlstrom7ab763c2013-12-09 00:38:02 -0800303oat-target: $(ART_TARGET_DEPENDENCIES) $(DEFAULT_DEX_PREOPT_INSTALLED_IMAGE) $(OAT_TARGET_TARGETS)
Ian Rogersbeb60e22012-01-31 10:40:40 -0800304
Brian Carlstroma6cc8932012-01-04 14:44:07 -0800305.PHONY: oat-target-sync
Brian Carlstrom04941d92012-02-19 01:47:51 -0800306oat-target-sync: oat-target
Brian Carlstrom0796af02011-10-12 14:31:45 -0700307 adb remount
308 adb sync
309
Brian Carlstrom76aa0c02011-10-11 15:29:43 -0700310########################################################################
Brian Carlstromfa50baa2013-08-02 01:00:27 -0700311# "m build-art" for quick minimal build
312.PHONY: build-art
313build-art: build-art-host build-art-target
314
315.PHONY: build-art-host
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800316build-art-host: $(ART_HOST_EXECUTABLES) $(ART_HOST_GTEST_EXECUTABLES) $(HOST_CORE_IMG_OUT) $(HOST_OUT)/lib/libjavacore.so
Brian Carlstromfa50baa2013-08-02 01:00:27 -0700317
318.PHONY: build-art-target
Brian Carlstroma1ce1fe2014-02-24 23:23:58 -0800319build-art-target: $(ART_TARGET_EXECUTABLES) $(ART_TARGET_GTEST_EXECUTABLES) $(TARGET_CORE_IMG_OUT) $(TARGET_OUT)/lib/libjavacore.so
Brian Carlstromfa50baa2013-08-02 01:00:27 -0700320
321########################################################################
Nicolas Geoffray9583fbc2014-02-28 15:21:07 +0000322# "m art-host" for just building the files needed to run the art script
323.PHONY: art-host
324art-host: $(HOST_OUT_EXECUTABLES)/art $(HOST_OUT)/bin/dalvikvm $(HOST_OUT)/lib/libart.so $(HOST_OUT)/bin/dex2oat $(HOST_OUT_JAVA_LIBRARIES)/core.art $(HOST_OUT)/lib/libjavacore.so
325
326.PHONY: art-host-debug
327art-host-debug: art-host $(HOST_OUT)/lib/libartd.so $(HOST_OUT)/bin/dex2oatd
328
329########################################################################
Brian Carlstrombc2f3e32011-09-22 17:16:54 -0700330# oatdump targets
Brian Carlstrom27ec9612011-09-19 20:20:38 -0700331
Ian Rogersfa824272013-11-05 16:12:57 -0800332ART_DUMP_OAT_PATH ?= $(OUT_DIR)
333
Brian Carlstrom7ab763c2013-12-09 00:38:02 -0800334OATDUMP := $(HOST_OUT_EXECUTABLES)/oatdump$(HOST_EXECUTABLE_SUFFIX)
335OATDUMPD := $(HOST_OUT_EXECUTABLES)/oatdumpd$(HOST_EXECUTABLE_SUFFIX)
336# TODO: for now, override with debug version for better error reporting
337OATDUMP := $(OATDUMPD)
338
Brian Carlstrom395520e2011-09-25 19:35:00 -0700339.PHONY: dump-oat
Ian Rogers62d6c772013-02-27 08:32:07 -0800340dump-oat: dump-oat-core dump-oat-boot
Brian Carlstrom395520e2011-09-25 19:35:00 -0700341
Brian Carlstrome10b6972011-09-26 13:49:03 -0700342.PHONY: dump-oat-core
Brian Carlstrom13c492b2012-03-22 17:09:17 -0700343dump-oat-core: dump-oat-core-host dump-oat-core-target
344
345.PHONY: dump-oat-core-host
Brian Carlstrom265091e2013-01-30 14:08:26 -0800346ifeq ($(ART_BUILD_HOST),true)
Brian Carlstrom13c492b2012-03-22 17:09:17 -0700347dump-oat-core-host: $(HOST_CORE_IMG_OUT) $(OATDUMP)
Nicolas Geoffray9583fbc2014-02-28 15:21:07 +0000348 $(OATDUMP) --image=$(HOST_CORE_IMG_OUT) --output=$(ART_DUMP_OAT_PATH)/core.host.oatdump.txt
Ian Rogersfa824272013-11-05 16:12:57 -0800349 @echo Output in $(ART_DUMP_OAT_PATH)/core.host.oatdump.txt
Brian Carlstrom265091e2013-01-30 14:08:26 -0800350endif
Brian Carlstrom13c492b2012-03-22 17:09:17 -0700351
352.PHONY: dump-oat-core-target
Brian Carlstrom265091e2013-01-30 14:08:26 -0800353ifeq ($(ART_BUILD_TARGET),true)
Brian Carlstrom13c492b2012-03-22 17:09:17 -0700354dump-oat-core-target: $(TARGET_CORE_IMG_OUT) $(OATDUMP)
Ian Rogersfa824272013-11-05 16:12:57 -0800355 $(OATDUMP) --image=$(TARGET_CORE_IMG_OUT) --output=$(ART_DUMP_OAT_PATH)/core.target.oatdump.txt
356 @echo Output in $(ART_DUMP_OAT_PATH)/core.target.oatdump.txt
Brian Carlstrom265091e2013-01-30 14:08:26 -0800357endif
Brian Carlstrom27ec9612011-09-19 20:20:38 -0700358
Brian Carlstrome10b6972011-09-26 13:49:03 -0700359.PHONY: dump-oat-boot
Brian Carlstrom265091e2013-01-30 14:08:26 -0800360ifeq ($(ART_BUILD_TARGET_NDEBUG),true)
Brian Carlstrom7ab763c2013-12-09 00:38:02 -0800361dump-oat-boot: $(DEFAULT_DEX_PREOPT_BUILT_IMAGE) $(OATDUMP)
Nicolas Geoffray9583fbc2014-02-28 15:21:07 +0000362 $(OATDUMP) --image=$(DEFAULT_DEX_PREOPT_BUILT_IMAGE) --output=$(ART_DUMP_OAT_PATH)/boot.oatdump.txt
Ian Rogersfa824272013-11-05 16:12:57 -0800363 @echo Output in $(ART_DUMP_OAT_PATH)/boot.oatdump.txt
Brian Carlstrom265091e2013-01-30 14:08:26 -0800364endif
Brian Carlstrom78128a62011-09-15 17:21:19 -0700365
Brian Carlstrom2e92fd62012-10-18 00:04:10 -0700366.PHONY: dump-oat-Calculator
Brian Carlstrom265091e2013-01-30 14:08:26 -0800367ifeq ($(ART_BUILD_TARGET_NDEBUG),true)
Brian Carlstrom7ab763c2013-12-09 00:38:02 -0800368dump-oat-Calculator: $(TARGET_OUT_APPS)/Calculator.odex $(DEFAULT_DEX_PREOPT_BUILT_IMAGE) $(OATDUMP)
Ian Rogersfa824272013-11-05 16:12:57 -0800369 $(OATDUMP) --oat-file=$< --output=$(ART_DUMP_OAT_PATH)/Calculator.oatdump.txt
370 @echo Output in $(ART_DUMP_OAT_PATH)/Calculator.oatdump.txt
Brian Carlstrom265091e2013-01-30 14:08:26 -0800371endif
Brian Carlstrom2e92fd62012-10-18 00:04:10 -0700372
Brian Carlstrombc2f3e32011-09-22 17:16:54 -0700373########################################################################
Brian Carlstromfc0e3212013-07-17 14:40:12 -0700374# cpplint targets to style check art source files
Brian Carlstrombc2f3e32011-09-22 17:16:54 -0700375
Brian Carlstrom05eecea2013-07-18 21:59:52 -0700376include $(art_build_path)/Android.cpplint.mk
Brian Carlstrom27ec9612011-09-19 20:20:38 -0700377
Brian Carlstrombc2f3e32011-09-22 17:16:54 -0700378########################################################################
Brian Carlstroma7a60a82013-06-24 17:41:19 -0700379# targets to switch back and forth from libdvm to libart
380
381.PHONY: use-art
382use-art:
383 adb root && sleep 3
Brian Carlstrom1e895cd2014-03-06 23:17:15 -0800384 adb shell stop
Brian Carlstrom2d27d832014-01-30 13:14:00 -0800385 adb shell setprop persist.sys.dalvik.vm.lib.1 libart.so
Brian Carlstrom1e895cd2014-03-06 23:17:15 -0800386 adb shell start
Brian Carlstroma7a60a82013-06-24 17:41:19 -0700387
388.PHONY: use-artd
389use-artd:
390 adb root && sleep 3
Brian Carlstrom1e895cd2014-03-06 23:17:15 -0800391 adb shell stop
Brian Carlstrom2d27d832014-01-30 13:14:00 -0800392 adb shell setprop persist.sys.dalvik.vm.lib.1 libartd.so
Brian Carlstrom1e895cd2014-03-06 23:17:15 -0800393 adb shell start
Brian Carlstroma7a60a82013-06-24 17:41:19 -0700394
395.PHONY: use-dalvik
396use-dalvik:
397 adb root && sleep 3
Brian Carlstrom1e895cd2014-03-06 23:17:15 -0800398 adb shell stop
Brian Carlstrom2d27d832014-01-30 13:14:00 -0800399 adb shell setprop persist.sys.dalvik.vm.lib.1 libdvm.so
Brian Carlstrom1e895cd2014-03-06 23:17:15 -0800400 adb shell start
401
402.PHONY: use-art-full
403use-art-full:
404 adb root && sleep 3
405 adb shell stop
406 adb shell rm $(ART_DALVIK_CACHE_DIR)/*.dex
407 adb shell rm $(ART_DALVIK_CACHE_DIR)/*.oat
408 adb shell rm $(ART_DALVIK_CACHE_DIR)/*.art
409 adb shell setprop dalvik.vm.dex2oat-flags ""
410 adb shell setprop dalvik.vm.image-dex2oat-flags ""
411 adb shell setprop persist.sys.dalvik.vm.lib.1 libart.so
412 adb shell start
413
414.PHONY: use-art-smart
415use-art-smart:
416 adb root && sleep 3
417 adb shell stop
418 adb shell rm $(ART_DALVIK_CACHE_DIR)/*.dex
419 adb shell rm $(ART_DALVIK_CACHE_DIR)/*.oat
420 adb shell rm $(ART_DALVIK_CACHE_DIR)/*.art
421 adb shell setprop dalvik.vm.dex2oat-flags "--compiler-filter=interpret-only"
422 adb shell setprop dalvik.vm.image-dex2oat-flags ""
423 adb shell setprop persist.sys.dalvik.vm.lib.1 libart.so
424 adb shell start
425
426.PHONY: use-art-interpret-only
427use-art-interpret-only:
428 adb root && sleep 3
429 adb shell stop
430 adb shell rm $(ART_DALVIK_CACHE_DIR)/*.dex
431 adb shell rm $(ART_DALVIK_CACHE_DIR)/*.oat
432 adb shell rm $(ART_DALVIK_CACHE_DIR)/*.art
433 adb shell setprop dalvik.vm.dex2oat-flags "--compiler-filter=interpret-only"
434 adb shell setprop dalvik.vm.image-dex2oat-flags "--compiler-filter=interpret-only"
435 adb shell setprop persist.sys.dalvik.vm.lib.1 libart.so
436 adb shell start
Brian Carlstroma7a60a82013-06-24 17:41:19 -0700437
Jeff Hao4a200f52014-04-01 14:58:49 -0700438.PHONY: use-art-verify-none
439use-art-verify-none:
440 adb root && sleep 3
441 adb shell stop
442 adb shell rm $(ART_DALVIK_CACHE_DIR)/*.dex
443 adb shell rm $(ART_DALVIK_CACHE_DIR)/*.oat
444 adb shell rm $(ART_DALVIK_CACHE_DIR)/*.art
445 adb shell setprop dalvik.vm.dex2oat-flags "--compiler-filter=verify-none"
446 adb shell setprop dalvik.vm.image-dex2oat-flags "--compiler-filter=verify-none"
447 adb shell setprop persist.sys.dalvik.vm.lib.1 libart.so
448 adb shell start
449
Brian Carlstroma7a60a82013-06-24 17:41:19 -0700450########################################################################
Brian Carlstrombc2f3e32011-09-22 17:16:54 -0700451
Brian Carlstrom62e3ee32012-06-18 14:58:55 -0700452endif # !art_dont_bother