• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#
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)
18
19art_path := $(LOCAL_PATH)
20art_build_path := $(art_path)/build
21
22########################################################################
23# clean-oat targets
24#
25
26# following the example of build's dont_bother for clean targets
27ifneq (,$(filter clean-oat,$(MAKECMDGOALS)))
28art_dont_bother := true
29endif
30ifneq (,$(filter clean-oat-host,$(MAKECMDGOALS)))
31art_dont_bother := true
32endif
33ifneq (,$(filter clean-oat-target,$(MAKECMDGOALS)))
34art_dont_bother := true
35endif
36
37.PHONY: clean-oat
38clean-oat: clean-oat-host clean-oat-target
39
40.PHONY: clean-oat-host
41clean-oat-host:
42	rm -f $(ART_NATIVETEST_OUT)/*.odex
43	rm -f $(ART_NATIVETEST_OUT)/*.oat
44	rm -f $(ART_NATIVETEST_OUT)/*.art
45	rm -f $(ART_TEST_OUT)/*.odex
46	rm -f $(ART_TEST_OUT)/*.oat
47	rm -f $(ART_TEST_OUT)/*.art
48	rm -f $(DALVIK_CACHE_OUT)/*@classes.dex
49	rm -f $(DALVIK_CACHE_OUT)/*.oat
50	rm -f $(DALVIK_CACHE_OUT)/*.art
51	rm -f $(HOST_OUT_JAVA_LIBRARIES)/*.odex
52	rm -f $(HOST_OUT_JAVA_LIBRARIES)/*.oat
53	rm -f $(HOST_OUT_JAVA_LIBRARIES)/*.art
54	rm -f $(TARGET_OUT_JAVA_LIBRARIES)/*.odex
55	rm -f $(TARGET_OUT_JAVA_LIBRARIES)/*.oat
56	rm -f $(TARGET_OUT_JAVA_LIBRARIES)/*.art
57	rm -f $(TARGET_OUT_UNSTRIPPED)/system/framework/*.odex
58	rm -f $(TARGET_OUT_UNSTRIPPED)/system/framework/*.oat
59	rm -f $(TARGET_OUT_APPS)/*.odex
60	rm -f $(TARGET_OUT_INTERMEDIATES)/JAVA_LIBRARIES/*_intermediates/javalib.odex
61	rm -f $(TARGET_OUT_INTERMEDIATES)/APPS/*_intermediates/*.odex
62	rm -rf /tmp/test-*/dalvik-cache/*@classes.dex
63
64.PHONY: clean-oat-target
65clean-oat-target:
66	adb remount
67	adb shell rm $(ART_NATIVETEST_DIR)/*.odex
68	adb shell rm $(ART_NATIVETEST_DIR)/*.oat
69	adb shell rm $(ART_NATIVETEST_DIR)/*.art
70	adb shell rm $(ART_TEST_DIR)/*.odex
71	adb shell rm $(ART_TEST_DIR)/*.oat
72	adb shell rm $(ART_TEST_DIR)/*.art
73	adb shell rm $(DALVIK_CACHE_DIR)/*.dex
74	adb shell rm $(DALVIK_CACHE_DIR)/*.oat
75	adb shell rm $(DALVIK_CACHE_DIR)/*.art
76	adb shell rm $(DEXPREOPT_BOOT_JAR_DIR)/*.oat
77	adb shell rm $(DEXPREOPT_BOOT_JAR_DIR)/*.art
78	adb shell rm system/app/*.odex
79	adb shell rm data/run-test/test-*/dalvik-cache/*@classes.dex
80
81ifneq ($(art_dont_bother),true)
82
83########################################################################
84# product targets
85include $(art_path)/runtime/Android.mk
86include $(art_path)/compiler/Android.mk
87include $(art_path)/dex2oat/Android.mk
88include $(art_path)/oatdump/Android.mk
89include $(art_path)/dalvikvm/Android.mk
90include $(art_path)/jdwpspy/Android.mk
91include $(art_build_path)/Android.oat.mk
92
93# ART_HOST_DEPENDENCIES depends on Android.executable.mk above for ART_HOST_EXECUTABLES
94ART_HOST_DEPENDENCIES := $(ART_HOST_EXECUTABLES) $(HOST_OUT_JAVA_LIBRARIES)/core-hostdex.jar
95ART_HOST_DEPENDENCIES += $(HOST_OUT_SHARED_LIBRARIES)/libjavacore$(ART_HOST_SHLIB_EXTENSION)
96ART_TARGET_DEPENDENCIES := $(ART_TARGET_EXECUTABLES) $(TARGET_OUT_JAVA_LIBRARIES)/core.jar $(TARGET_OUT_SHARED_LIBRARIES)/libjavacore.so
97
98########################################################################
99# test targets
100
101include $(art_path)/test/Android.mk
102include $(art_build_path)/Android.gtest.mk
103
104# The ART_*_TEST_DEPENDENCIES definitions:
105# - depend on Android.oattest.mk above for ART_TEST_*_DEX_FILES
106# - depend on Android.gtest.mk above for ART_*_TEST_EXECUTABLES
107ART_HOST_TEST_DEPENDENCIES   := $(ART_HOST_DEPENDENCIES)   $(ART_HOST_TEST_EXECUTABLES)   $(ART_TEST_HOST_DEX_FILES)   $(HOST_CORE_IMG_OUT)
108ART_TARGET_TEST_DEPENDENCIES := $(ART_TARGET_DEPENDENCIES) $(ART_TARGET_TEST_EXECUTABLES) $(ART_TEST_TARGET_DEX_FILES) $(TARGET_CORE_IMG_OUT)
109
110include $(art_build_path)/Android.libarttest.mk
111
112# "mm test-art" to build and run all tests on host and device
113.PHONY: test-art
114test-art: test-art-host test-art-target
115	@echo test-art PASSED
116
117.PHONY: test-art-gtest
118test-art-gtest: test-art-host-gtest test-art-target-gtest
119	@echo test-art-gtest PASSED
120
121.PHONY: test-art-oat
122test-art-oat: test-art-host-oat test-art-target-oat
123	@echo test-art-oat PASSED
124
125.PHONY: test-art-run-test
126test-art-run-test: test-art-host-run-test test-art-target-run-test
127	@echo test-art-run-test PASSED
128
129########################################################################
130# host test targets
131
132# "mm test-art-host" to build and run all host tests
133.PHONY: test-art-host
134test-art-host: test-art-host-gtest test-art-host-oat test-art-host-run-test
135	@echo test-art-host PASSED
136
137.PHONY: test-art-host-interpreter
138test-art-host-interpreter: test-art-host-oat-interpreter test-art-host-run-test-interpreter
139	@echo test-art-host-interpreter PASSED
140
141.PHONY: test-art-host-dependencies
142test-art-host-dependencies: $(ART_HOST_TEST_DEPENDENCIES) $(HOST_OUT_SHARED_LIBRARIES)/libarttest$(ART_HOST_SHLIB_EXTENSION) $(HOST_CORE_DEX_LOCATIONS)
143
144.PHONY: test-art-host-gtest
145test-art-host-gtest: $(ART_HOST_TEST_TARGETS)
146	@echo test-art-host-gtest PASSED
147
148define run-host-gtests-with
149  $(foreach file,$(sort $(ART_HOST_TEST_EXECUTABLES)),$(1) $(file) &&) true
150endef
151
152# "mm valgrind-test-art-host-gtest" to build and run the host gtests under valgrind.
153.PHONY: valgrind-test-art-host-gtest
154valgrind-test-art-host-gtest: test-art-host-dependencies
155	$(call run-host-gtests-with,valgrind --leak-check=full)
156	@echo valgrind-test-art-host-gtest PASSED
157
158.PHONY: test-art-host-oat-default
159test-art-host-oat-default: $(ART_TEST_HOST_OAT_DEFAULT_TARGETS)
160	@echo test-art-host-oat-default PASSED
161
162.PHONY: test-art-host-oat-interpreter
163test-art-host-oat-interpreter: $(ART_TEST_HOST_OAT_INTERPRETER_TARGETS)
164	@echo test-art-host-oat-interpreter PASSED
165
166.PHONY: test-art-host-oat
167test-art-host-oat: test-art-host-oat-default test-art-host-oat-interpreter
168	@echo test-art-host-oat PASSED
169
170define declare-test-art-host-run-test
171.PHONY: test-art-host-run-test-default-$(1)
172test-art-host-run-test-default-$(1): test-art-host-dependencies
173	art/test/run-test --host $(1)
174	@echo test-art-host-run-test-default-$(1) PASSED
175
176TEST_ART_HOST_RUN_TEST_DEFAULT_TARGETS += test-art-host-run-test-default-$(1)
177
178.PHONY: test-art-host-run-test-interpreter-$(1)
179test-art-host-run-test-interpreter-$(1): test-art-host-dependencies
180	art/test/run-test --host --interpreter $(1)
181	@echo test-art-host-run-test-interpreter-$(1) PASSED
182
183TEST_ART_HOST_RUN_TEST_INTERPRETER_TARGETS += test-art-host-run-test-interpreter-$(1)
184
185.PHONY: test-art-host-run-test-$(1)
186test-art-host-run-test-$(1): test-art-host-run-test-default-$(1) test-art-host-run-test-interpreter-$(1)
187
188endef
189
190$(foreach test, $(wildcard art/test/[0-9]*), $(eval $(call declare-test-art-host-run-test,$(notdir $(test)))))
191
192.PHONY: test-art-host-run-test-default
193test-art-host-run-test-default: $(TEST_ART_HOST_RUN_TEST_DEFAULT_TARGETS)
194	@echo test-art-host-run-test-default PASSED
195
196.PHONY: test-art-host-run-test-interpreter
197test-art-host-run-test-interpreter: $(TEST_ART_HOST_RUN_TEST_INTERPRETER_TARGETS)
198	@echo test-art-host-run-test-interpreter PASSED
199
200.PHONY: test-art-host-run-test
201test-art-host-run-test: test-art-host-run-test-default test-art-host-run-test-interpreter
202	@echo test-art-host-run-test PASSED
203
204########################################################################
205# target test targets
206
207# "mm test-art-target" to build and run all target tests
208.PHONY: test-art-target
209test-art-target: test-art-target-gtest test-art-target-oat test-art-target-run-test
210	@echo test-art-target PASSED
211
212.PHONY: test-art-target-dependencies
213test-art-target-dependencies: $(ART_TARGET_TEST_DEPENDENCIES) $(ART_TEST_OUT)/libarttest.so
214
215.PHONY: test-art-target-sync
216test-art-target-sync: test-art-target-dependencies
217	adb remount
218	adb sync
219	adb shell mkdir -p $(ART_TEST_DIR)
220
221.PHONY: test-art-target-gtest
222test-art-target-gtest: $(ART_TARGET_TEST_TARGETS)
223
224.PHONY: test-art-target-oat
225test-art-target-oat: $(ART_TEST_TARGET_OAT_TARGETS)
226	@echo test-art-target-oat PASSED
227
228define declare-test-art-target-run-test
229.PHONY: test-art-target-run-test-$(1)
230test-art-target-run-test-$(1): test-art-target-sync
231	art/test/run-test $(1)
232	@echo test-art-target-run-test-$(1) PASSED
233
234TEST_ART_TARGET_RUN_TEST_TARGETS += test-art-target-run-test-$(1)
235
236test-art-run-test-$(1): test-art-host-run-test-$(1) test-art-target-run-test-$(1)
237
238endef
239
240$(foreach test, $(wildcard art/test/[0-9]*), $(eval $(call declare-test-art-target-run-test,$(notdir $(test)))))
241
242.PHONY: test-art-target-run-test
243test-art-target-run-test: $(TEST_ART_TARGET_RUN_TEST_TARGETS)
244	@echo test-art-target-run-test PASSED
245
246########################################################################
247# oat-target and oat-target-sync targets
248
249OAT_TARGET_TARGETS :=
250
251# $(1): input jar or apk target location
252define declare-oat-target-target
253ifneq (,$(filter $(1),$(addprefix system/app/,$(addsuffix .apk,$(PRODUCT_DEX_PREOPT_PACKAGES_IN_DATA)))))
254OUT_OAT_FILE := $(call dalvik-cache-out,$(1)/classes.dex)
255else
256OUT_OAT_FILE := $(PRODUCT_OUT)/$(basename $(1)).odex
257endif
258
259ifeq ($(ONE_SHOT_MAKEFILE),)
260# ONE_SHOT_MAKEFILE is empty for a top level build and we don't want
261# to define the oat-target-* rules there because they will conflict
262# with the build/core/dex_preopt.mk defined rules.
263.PHONY: oat-target-$(1)
264oat-target-$(1):
265
266else
267.PHONY: oat-target-$(1)
268oat-target-$(1): $$(OUT_OAT_FILE)
269
270$$(OUT_OAT_FILE): $(PRODUCT_OUT)/$(1) $(TARGET_BOOT_IMG_OUT) $(DEX2OAT_DEPENDENCY)
271	@mkdir -p $$(dir $$@)
272	$(DEX2OAT) $(PARALLEL_ART_COMPILE_JOBS) --runtime-arg -Xms64m --runtime-arg -Xmx64m --boot-image=$(TARGET_BOOT_IMG_OUT) --dex-file=$(PRODUCT_OUT)/$(1) --dex-location=/$(1) --oat-file=$$@ --host-prefix=$(PRODUCT_OUT) --instruction-set=$(TARGET_ARCH) --android-root=$(PRODUCT_OUT)/system
273
274endif
275
276OAT_TARGET_TARGETS += oat-target-$(1)
277endef
278
279$(foreach file,\
280  $(filter-out\
281    $(addprefix $(TARGET_OUT_JAVA_LIBRARIES)/,$(addsuffix .jar,$(TARGET_BOOT_JARS))),\
282    $(wildcard $(TARGET_OUT_APPS)/*.apk) $(wildcard $(TARGET_OUT_JAVA_LIBRARIES)/*.jar)),\
283  $(eval $(call declare-oat-target-target,$(subst $(PRODUCT_OUT)/,,$(file)))))
284
285.PHONY: oat-target
286oat-target: $(ART_TARGET_DEPENDENCIES) $(TARGET_BOOT_OAT_OUT) $(OAT_TARGET_TARGETS)
287
288.PHONY: oat-target-sync
289oat-target-sync: oat-target
290	adb remount
291	adb sync
292
293########################################################################
294# "m build-art" for quick minimal build
295.PHONY: build-art
296build-art: build-art-host build-art-target
297
298.PHONY: build-art-host
299build-art-host:   $(ART_HOST_EXECUTABLES)   $(ART_HOST_TEST_EXECUTABLES)   $(HOST_CORE_IMG_OUT)   $(HOST_OUT)/lib/libjavacore.so
300
301.PHONY: build-art-target
302build-art-target: $(ART_TARGET_EXECUTABLES) $(ART_TARGET_TEST_EXECUTABLES) $(TARGET_CORE_IMG_OUT) $(TARGET_OUT)/lib/libjavacore.so
303
304########################################################################
305# oatdump targets
306
307.PHONY: dump-oat
308dump-oat: dump-oat-core dump-oat-boot
309
310.PHONY: dump-oat-core
311dump-oat-core: dump-oat-core-host dump-oat-core-target
312
313.PHONY: dump-oat-core-host
314ifeq ($(ART_BUILD_HOST),true)
315dump-oat-core-host: $(HOST_CORE_IMG_OUT) $(OATDUMP)
316	$(OATDUMP) --image=$(HOST_CORE_IMG_OUT) --output=/tmp/core.host.oatdump.txt --host-prefix=""
317	@echo Output in /tmp/core.host.oatdump.txt
318endif
319
320.PHONY: dump-oat-core-target
321ifeq ($(ART_BUILD_TARGET),true)
322dump-oat-core-target: $(TARGET_CORE_IMG_OUT) $(OATDUMP)
323	$(OATDUMP) --image=$(TARGET_CORE_IMG_OUT) --output=/tmp/core.target.oatdump.txt
324	@echo Output in /tmp/core.target.oatdump.txt
325endif
326
327.PHONY: dump-oat-boot
328ifeq ($(ART_BUILD_TARGET_NDEBUG),true)
329dump-oat-boot: $(TARGET_BOOT_IMG_OUT) $(OATDUMP)
330	$(OATDUMP) --image=$(TARGET_BOOT_IMG_OUT) --output=/tmp/boot.oatdump.txt
331	@echo Output in /tmp/boot.oatdump.txt
332endif
333
334.PHONY: dump-oat-Calculator
335ifeq ($(ART_BUILD_TARGET_NDEBUG),true)
336dump-oat-Calculator: $(TARGET_OUT_APPS)/Calculator.odex $(TARGET_BOOT_IMG_OUT) $(OATDUMP)
337	$(OATDUMP) --oat-file=$< --output=/tmp/Calculator.oatdump.txt
338	@echo Output in /tmp/Calculator.oatdump.txt
339endif
340
341########################################################################
342# cpplint targets to style check art source files
343
344include $(art_build_path)/Android.cpplint.mk
345
346########################################################################
347# targets to switch back and forth from libdvm to libart
348
349.PHONY: use-art
350use-art:
351	adb root && sleep 3
352	adb shell setprop persist.sys.dalvik.vm.lib libart.so
353	adb reboot
354
355.PHONY: use-artd
356use-artd:
357	adb root && sleep 3
358	adb shell setprop persist.sys.dalvik.vm.lib libartd.so
359	adb reboot
360
361.PHONY: use-dalvik
362use-dalvik:
363	adb root && sleep 3
364	adb shell setprop persist.sys.dalvik.vm.lib libdvm.so
365	adb reboot
366
367########################################################################
368
369endif # !art_dont_bother
370