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