blob: 53d89ebf719c547d238d02d612e55f7c6533e343 [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 Carlstrom4b620ff2011-09-11 01:11:01 -070019# These can be overridden via the environment or by editing to
20# enable/disable certain build configuration.
21ART_BUILD_TARGET_NDEBUG ?= true
22ART_BUILD_TARGET_DEBUG ?= true
Brian Carlstrom8ce86472011-12-15 13:50:38 -080023ART_BUILD_HOST_NDEBUG ?= true
24ART_BUILD_HOST_DEBUG ?= true
Brian Carlstrom4b620ff2011-09-11 01:11:01 -070025
Carl Shapiro0e6d1972011-07-06 19:17:39 -070026build_path := $(LOCAL_PATH)/build
Brian Carlstromcdc8de42011-07-19 14:23:17 -070027include $(build_path)/Android.common.mk
28
Brian Carlstromb2793372012-03-17 18:27:16 -070029########################################################################
30# product targets
Carl Shapiro0e6d1972011-07-06 19:17:39 -070031include $(build_path)/Android.libart.mk
Elliott Hughesb3bd5f02012-03-08 21:05:27 -080032include $(build_path)/Android.libart-compiler.mk
Shih-wei Liaoc4c98812012-03-10 21:55:51 -080033ifeq ($(ART_USE_LLVM_COMPILER),true)
34include $(build_path)/Android.libart-compiler-llvm.mk
35endif
Brian Carlstrom69b15fb2011-09-03 12:25:21 -070036include $(build_path)/Android.executable.mk
Brian Carlstromb2793372012-03-17 18:27:16 -070037include $(build_path)/Android.oat.mk
Carl Shapiro7b216702011-06-17 15:09:26 -070038
Brian Carlstromb2793372012-03-17 18:27:16 -070039# ART_HOST_DEPENDENCIES depends on Android.executable.mk above for ART_HOST_EXECUTABLES
Brian Carlstrom15803792012-03-13 00:53:08 -070040ART_HOST_DEPENDENCIES := $(ART_HOST_EXECUTABLES) $(HOST_OUT_JAVA_LIBRARIES)/core-hostdex.jar
41ifeq ($(HOST_OS),linux)
42 ART_HOST_DEPENDENCIES += $(HOST_OUT_SHARED_LIBRARIES)/libjavacore.so
43else
44 ART_HOST_DEPENDENCIES += $(HOST_OUT_SHARED_LIBRARIES)/libjavacore.dylib
45endif
46ART_TARGET_DEPENDENCIES := $(ART_TARGET_EXECUTABLES) $(TARGET_OUT_JAVA_LIBRARIES)/core.jar $(TARGET_OUT_SHARED_LIBRARIES)/libjavacore.so
47
Brian Carlstromb2793372012-03-17 18:27:16 -070048########################################################################
49# test targets
Brian Carlstrom15803792012-03-13 00:53:08 -070050
Brian Carlstromb2793372012-03-17 18:27:16 -070051include $(build_path)/Android.oattest.mk
52
53# The ART_*_TEST_DEPENDENCIES definitions:
54# - depend on Android.oattest.mk above for ART_TEST_*_DEX_FILES
55# - are needed by Android.gtest.mk below
56ART_HOST_TEST_DEPENDENCIES := $(ART_HOST_DEPENDENCIES) $(ART_HOST_TEST_EXECUTABLES) $(ART_TEST_HOST_DEX_FILES) $(HOST_CORE_IMG_OUT)
57ART_TARGET_TEST_DEPENDENCIES := $(ART_TARGET_DEPENDENCIES) $(ART_TARGET_TEST_EXECUTABLES) $(ART_TEST_TARGET_DEX_FILES) $(TARGET_CORE_IMG_OUT)
Brian Carlstrom16192862011-09-12 17:50:06 -070058
Brian Carlstrom07d579f2011-07-27 13:31:51 -070059include $(build_path)/Android.libarttest.mk
Brian Carlstrombbf1e412011-09-18 14:14:51 -070060include $(build_path)/Android.gtest.mk
Brian Carlstrom934486c2011-07-12 23:42:50 -070061
62# "m build-art" for quick minimal build
63.PHONY: build-art
64build-art: \
Brian Carlstrom69b15fb2011-09-03 12:25:21 -070065 $(ART_TARGET_EXECUTABLES) \
Brian Carlstrom8ecd08c2011-07-27 17:50:51 -070066 $(ART_TARGET_TEST_EXECUTABLES) \
Brian Carlstrom69b15fb2011-09-03 12:25:21 -070067 $(ART_HOST_EXECUTABLES) \
Carl Shapiro47940d62011-08-13 22:21:30 -070068 $(ART_HOST_TEST_EXECUTABLES)
Brian Carlstrom934486c2011-07-12 23:42:50 -070069
Brian Carlstrom4a96b602011-07-26 16:40:23 -070070# "mm test-art" to build and run all tests on host and device
71.PHONY: test-art
72test-art: test-art-host test-art-target
Brian Carlstrom395520e2011-09-25 19:35:00 -070073 @echo test-art PASSED
Brian Carlstrom4a96b602011-07-26 16:40:23 -070074
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -070075.PHONY: test-art-gtest
Brian Carlstromb2793372012-03-17 18:27:16 -070076test-art-gtest: test-art-host-gtest test-art-target-gtest
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -070077 @echo test-art-gtest PASSED
78
Brian Carlstromb2793372012-03-17 18:27:16 -070079.PHONY: test-art-oat
80test-art-oat: test-art-target-oat # test-art-host-oat
81 @echo test-art-oat PASSED
Elliott Hughes2cae5a22011-08-14 14:27:25 -070082
Brian Carlstrombc2f3e32011-09-22 17:16:54 -070083########################################################################
84# host test targets
85
Brian Carlstrom934486c2011-07-12 23:42:50 -070086# "mm test-art-host" to build and run all host tests
87.PHONY: test-art-host
Brian Carlstromb2793372012-03-17 18:27:16 -070088test-art-host: test-art-host-gtest # test-art-host-oat # test-art-host-run-test
Brian Carlstrom395520e2011-09-25 19:35:00 -070089 @echo test-art-host PASSED
Brian Carlstrom59848da2011-07-23 20:35:19 -070090
Brian Carlstromb2793372012-03-17 18:27:16 -070091.PHONY: test-art-host-gtest
92test-art-host-gtest: $(ART_HOST_TEST_TARGETS)
93 @echo test-art-host-gtest PASSED
Elliott Hughes2cae5a22011-08-14 14:27:25 -070094
Brian Carlstromb2793372012-03-17 18:27:16 -070095define run-host-gtests-with
96 $(foreach file,$(sort $(ART_HOST_TEST_EXECUTABLES)),$(1) $(file) &&) true
97endef
98
99# "mm valgrind-test-art-host-gtest" to build and run the host gtests under valgrind.
100.PHONY: valgrind-test-art-host-gtest
101valgrind-test-art-host-gtest: $(ART_HOST_TEST_DEPENDENCIES)
102 $(call run-host-gtests-with,valgrind --leak-check=full)
103 @echo valgrind-test-art-host-gtest PASSED
104
105# "mm tsan-test-art-host-gtest" to build and run the host gtests under tsan.
106.PHONY: tsan-test-art-host-gtest
107tsan-test-art-host-gtest: $(ART_HOST_TEST_DEPENDENCIES)
108 $(call run-host-gtests-with,"tsan")
109 @echo tsan-test-art-host-gtest PASSED
110
111.PHONY: test-art-host-oat
112test-art-host-oat: $(ART_TEST_HOST_OAT_TARGETS)
113 @echo test-art-host-oat PASSED
Elliott Hughes5511f212011-08-12 18:07:45 -0700114
Brian Carlstrombc2f3e32011-09-22 17:16:54 -0700115########################################################################
116# target test targets
117
118# "mm test-art-target" to build and run all target tests
Brian Carlstrom4a96b602011-07-26 16:40:23 -0700119.PHONY: test-art-target
Brian Carlstrome24fa612011-09-29 00:53:55 -0700120test-art-target: test-art-target-gtest test-art-target-oat test-art-target-run-test
Brian Carlstrom395520e2011-09-25 19:35:00 -0700121 @echo test-art-target PASSED
Brian Carlstrom86927212011-09-15 11:31:11 -0700122
123.PHONY: test-art-target-sync
Brian Carlstromb9cc1ca2012-01-27 00:57:42 -0800124test-art-target-sync: $(ART_TARGET_TEST_DEPENDENCIES) $(ART_TEST_OUT)/libarttest.so
Brian Carlstrom4a96b602011-07-26 16:40:23 -0700125 adb remount
126 adb sync
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -0700127 adb shell mkdir -p $(ART_TEST_DIR)
Brian Carlstrom86927212011-09-15 11:31:11 -0700128
129.PHONY: test-art-target-gtest
Brian Carlstrom47a0d5a2011-10-12 21:20:05 -0700130test-art-target-gtest: $(ART_TARGET_TEST_TARGETS)
Brian Carlstrom86927212011-09-15 11:31:11 -0700131
132.PHONY: test-art-target-oat
Brian Carlstromb2793372012-03-17 18:27:16 -0700133test-art-target-oat: $(ART_TEST_TARGET_OAT_TARGETS)
Brian Carlstrom395520e2011-09-25 19:35:00 -0700134 @echo test-art-target-oat PASSED
Brian Carlstrom4a96b602011-07-26 16:40:23 -0700135
Brian Carlstrom37c44442012-03-06 22:21:18 -0800136define declare-test-art-target-run-test
137.PHONY: test-art-target-run-test-$(1)
138test-art-target-run-test-$(1): test-art-target-sync
139 art/test/run-test $(1)
140 @echo test-art-target-run-test-$(1) PASSED
Brian Carlstrome24fa612011-09-29 00:53:55 -0700141
Brian Carlstrom37c44442012-03-06 22:21:18 -0800142TEST_ART_TARGET_RUN_TEST_TARGETS += test-art-target-run-test-$(1)
143endef
144
145$(foreach test, $(wildcard art/test/0*), $(eval $(call declare-test-art-target-run-test,$(notdir $(test)))))
146
147.PHONY: test-art-target-run-test
148test-art-target-run-test: $(TEST_ART_TARGET_RUN_TEST_TARGETS)
149 @echo test-art-target-run-test PASSED
Brian Carlstrome24fa612011-09-29 00:53:55 -0700150
Brian Carlstrombc2f3e32011-09-22 17:16:54 -0700151########################################################################
Brian Carlstrom04941d92012-02-19 01:47:51 -0800152# oat-target and oat-target-sync targets
Brian Carlstrombc2f3e32011-09-22 17:16:54 -0700153
Brian Carlstrom04941d92012-02-19 01:47:51 -0800154OAT_TARGET_TARGETS :=
155
156# $(1): input jar or apk target location
157define declare-oat-target-target
158.PHONY: oat-target-$(1)
159oat-target-$(1): $(PRODUCT_OUT)/$(1) $(TARGET_BOOT_IMG_OUT) $(DEX2OAT_DEPENDENCY)
Brian Carlstrombf2cb162012-02-27 17:49:19 -0800160 $(DEX2OAT) --runtime-arg -Xms64m --runtime-arg -Xmx64m --boot-image=$(TARGET_BOOT_IMG_OUT) --dex-file=$(PRODUCT_OUT)/$(1) --dex-location=/$(1) --oat-file=$(call art-cache-out,$(1).oat) --host-prefix=$(PRODUCT_OUT)
Brian Carlstrom04941d92012-02-19 01:47:51 -0800161
162OAT_TARGET_TARGETS += oat-target-$(1)
Brian Carlstroma9f19782011-10-13 00:14:47 -0700163endef
164
Brian Carlstrombd411022012-02-07 12:09:09 -0800165$(foreach file,\
166 $(filter-out\
167 $(TARGET_BOOT_DEX),\
168 $(wildcard $(TARGET_OUT_APPS)/*.apk) $(wildcard $(TARGET_OUT_JAVA_LIBRARIES)/*.jar)),\
Brian Carlstrom04941d92012-02-19 01:47:51 -0800169 $(eval $(call declare-oat-target-target,$(subst $(PRODUCT_OUT)/,,$(file)))))
170
171.PHONY: oat-target
172oat-target: $(ART_TARGET_DEPENDENCIES) $(TARGET_BOOT_OAT_OUT) $(OAT_TARGET_TARGETS)
Ian Rogersbeb60e22012-01-31 10:40:40 -0800173
Brian Carlstroma6cc8932012-01-04 14:44:07 -0800174.PHONY: oat-target-sync
Brian Carlstrom04941d92012-02-19 01:47:51 -0800175oat-target-sync: oat-target
Brian Carlstrom0796af02011-10-12 14:31:45 -0700176 adb remount
177 adb sync
178
Brian Carlstrom76aa0c02011-10-11 15:29:43 -0700179########################################################################
Brian Carlstrombc2f3e32011-09-22 17:16:54 -0700180# oatdump targets
Brian Carlstrom27ec9612011-09-19 20:20:38 -0700181
Brian Carlstrom395520e2011-09-25 19:35:00 -0700182.PHONY: dump-oat
Brian Carlstrom03a20ba2011-10-13 10:24:13 -0700183dump-oat: dump-oat-core dump-oat-boot dump-oat-Calculator
Brian Carlstrom395520e2011-09-25 19:35:00 -0700184
Brian Carlstrome10b6972011-09-26 13:49:03 -0700185.PHONY: dump-oat-core
Brian Carlstroma004aa92012-02-08 18:05:09 -0800186dump-oat-core: $(TARGET_CORE_OAT_OUT) $(OATDUMP)
Brian Carlstromfe487d02012-02-29 18:49:16 -0800187 $(OATDUMP) --image=$(TARGET_CORE_IMG_OUT) --output=/tmp/core.oatdump.txt
Brian Carlstrom27ec9612011-09-19 20:20:38 -0700188 @echo Output in /tmp/core.oatdump.txt
189
Brian Carlstrome10b6972011-09-26 13:49:03 -0700190.PHONY: dump-oat-boot
Brian Carlstroma004aa92012-02-08 18:05:09 -0800191dump-oat-boot: $(TARGET_BOOT_OAT_OUT) $(OATDUMP)
Brian Carlstromfe487d02012-02-29 18:49:16 -0800192 $(OATDUMP) --image=$(TARGET_BOOT_IMG_OUT) --output=/tmp/boot.oatdump.txt
Brian Carlstrom27ec9612011-09-19 20:20:38 -0700193 @echo Output in /tmp/boot.oatdump.txt
Brian Carlstrom78128a62011-09-15 17:21:19 -0700194
Brian Carlstrome10b6972011-09-26 13:49:03 -0700195.PHONY: dump-oat-Calculator
Brian Carlstromfe487d02012-02-29 18:49:16 -0800196dump-oat-Calculator: $(call art-cache-out,system/app/Calculator.apk.oat) $(TARGET_BOOT_IMG_OUT) $(OATDUMP)
197 $(OATDUMP) --oat-file=$< --output=/tmp/Calculator.oatdump.txt
Brian Carlstrome10b6972011-09-26 13:49:03 -0700198 @echo Output in /tmp/Calculator.oatdump.txt
199
200
Brian Carlstrombc2f3e32011-09-22 17:16:54 -0700201########################################################################
Brian Carlstromfab62932011-10-27 21:47:49 -0700202# clean-oat target
203#
204
205.PHONY: clean-oat
206clean-oat:
Brian Carlstroma004aa92012-02-08 18:05:09 -0800207 rm -f $(ART_NATIVETEST_OUT)/*.oat
208 rm -f $(ART_NATIVETEST_OUT)/*.art
Brian Carlstromfab62932011-10-27 21:47:49 -0700209 rm -f $(ART_TEST_OUT)/*.oat
Elliott Hughes55124a52011-12-08 15:52:52 -0800210 rm -f $(ART_TEST_OUT)/*.art
Brian Carlstromfab62932011-10-27 21:47:49 -0700211 rm -f $(ART_CACHE_OUT)/*.oat
Elliott Hughes55124a52011-12-08 15:52:52 -0800212 rm -f $(ART_CACHE_OUT)/*.art
Brian Carlstroma004aa92012-02-08 18:05:09 -0800213 rm -f $(HOST_OUT_JAVA_LIBRARIES)/*.oat
214 rm -f $(HOST_OUT_JAVA_LIBRARIES)/*.art
215 rm -f $(TARGET_OUT_JAVA_LIBRARIES)/*.oat
216 rm -f $(TARGET_OUT_JAVA_LIBRARIES)/*.art
217 rm -f $(TARGET_OUT_APPS)/*.oat
218 adb shell rm $(ART_NATIVETEST_DIR)/*.oat
219 adb shell rm $(ART_NATIVETEST_DIR)/*.art
Brian Carlstromfab62932011-10-27 21:47:49 -0700220 adb shell rm $(ART_TEST_DIR)/*.oat
Elliott Hughes55124a52011-12-08 15:52:52 -0800221 adb shell rm $(ART_TEST_DIR)/*.art
Brian Carlstromfab62932011-10-27 21:47:49 -0700222 adb shell rm $(ART_CACHE_DIR)/*.oat
Elliott Hughes55124a52011-12-08 15:52:52 -0800223 adb shell rm $(ART_CACHE_DIR)/*.art
Brian Carlstroma004aa92012-02-08 18:05:09 -0800224 adb shell rm $(DEXPREOPT_BOOT_JAR_DIR)/*.oat
225 adb shell rm $(DEXPREOPT_BOOT_JAR_DIR)/*.art
226 adb shell rm system/app/*.oat
Brian Carlstromf8bbb842012-03-14 03:01:42 -0700227 adb shell rm data/run-test/*.oat
Brian Carlstromfab62932011-10-27 21:47:49 -0700228
229########################################################################
Brian Carlstrombc2f3e32011-09-22 17:16:54 -0700230# cpplint target
231
Brian Carlstrom59848da2011-07-23 20:35:19 -0700232# "mm cpplint-art" to style check art source files
233.PHONY: cpplint-art
234cpplint-art:
Elliott Hughesa51a3dd2011-10-17 15:19:26 -0700235 ./art/tools/cpplint.py \
236 --filter=-whitespace/comments,-whitespace/line_length,-build/include,-build/header_guard,-readability/streams,-readability/todo,-runtime/references \
Elliott Hughes362f9bc2011-10-17 18:56:41 -0700237 $(ANDROID_BUILD_TOP)/art/src/*.h $(ANDROID_BUILD_TOP)/art/src/*.cc
Brian Carlstrom27ec9612011-09-19 20:20:38 -0700238
Brian Carlstrombc2f3e32011-09-22 17:16:54 -0700239########################################################################
240
Brian Carlstrom27ec9612011-09-19 20:20:38 -0700241include $(call all-makefiles-under,$(LOCAL_PATH))