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)
20
21########################################################################
22# clean-oat rules
23#
24
25include $(art_path)/build/Android.common_path.mk
26include $(art_path)/build/Android.oat.mk
27
28.PHONY: clean-oat
29clean-oat: clean-oat-host clean-oat-target
30
31.PHONY: clean-oat-host
32clean-oat-host:
33	find $(OUT_DIR) -name "*.oat" -o -name "*.odex" -o -name "*.art" -o -name '*.vdex' | xargs rm -f
34ifneq ($(TMPDIR),)
35	rm -rf $(TMPDIR)/$(USER)/test-*/dalvik-cache/*
36	rm -rf $(TMPDIR)/android-data/dalvik-cache/*
37else
38	rm -rf /tmp/$(USER)/test-*/dalvik-cache/*
39	rm -rf /tmp/android-data/dalvik-cache/*
40endif
41
42.PHONY: clean-oat-target
43clean-oat-target:
44	adb root
45	adb wait-for-device remount
46	adb shell rm -rf $(ART_TARGET_NATIVETEST_DIR)
47	adb shell rm -rf $(ART_TARGET_TEST_DIR)
48	adb shell rm -rf $(ART_TARGET_DALVIK_CACHE_DIR)/*/*
49	adb shell rm -rf $(DEXPREOPT_BOOT_JAR_DIR)/$(DEX2OAT_TARGET_ARCH)
50	adb shell rm -rf system/app/$(DEX2OAT_TARGET_ARCH)
51ifdef TARGET_2ND_ARCH
52	adb shell rm -rf $(DEXPREOPT_BOOT_JAR_DIR)/$($(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_ARCH)
53	adb shell rm -rf system/app/$($(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_ARCH)
54endif
55	adb shell rm -rf data/run-test/test-*/dalvik-cache/*
56
57########################################################################
58# cpplint rules to style check art source files
59
60include $(art_path)/build/Android.cpplint.mk
61
62########################################################################
63# product rules
64
65include $(art_path)/oatdump/Android.mk
66include $(art_path)/tools/Android.mk
67include $(art_path)/tools/ahat/Android.mk
68include $(art_path)/tools/amm/Android.mk
69include $(art_path)/tools/dexfuzz/Android.mk
70include $(art_path)/tools/veridex/Android.mk
71include $(art_path)/libart_fake/Android.mk
72
73ART_HOST_DEPENDENCIES := \
74  $(ART_HOST_EXECUTABLES) \
75  $(ART_HOST_DEX_DEPENDENCIES) \
76  $(ART_HOST_SHARED_LIBRARY_DEPENDENCIES)
77
78ifeq ($(ART_BUILD_HOST_DEBUG),true)
79ART_HOST_DEPENDENCIES += $(ART_HOST_SHARED_LIBRARY_DEBUG_DEPENDENCIES)
80endif
81
82ART_TARGET_DEPENDENCIES := \
83  $(ART_TARGET_EXECUTABLES) \
84  $(ART_TARGET_DEX_DEPENDENCIES) \
85  $(ART_TARGET_SHARED_LIBRARY_DEPENDENCIES)
86
87ifeq ($(ART_BUILD_TARGET_DEBUG),true)
88ART_TARGET_DEPENDENCIES += $(ART_TARGET_SHARED_LIBRARY_DEBUG_DEPENDENCIES)
89endif
90
91########################################################################
92# test rules
93
94# All the dependencies that must be built ahead of sync-ing them onto the target device.
95TEST_ART_TARGET_SYNC_DEPS :=
96
97include $(art_path)/build/Android.common_test.mk
98include $(art_path)/build/Android.gtest.mk
99include $(art_path)/test/Android.run-test.mk
100
101TEST_ART_ADB_ROOT_AND_REMOUNT := \
102    (adb root && \
103     adb wait-for-device remount && \
104     ((adb shell touch /system/testfile && \
105       (adb shell rm /system/testfile || true)) || \
106      (adb disable-verity && \
107       adb reboot && \
108       adb wait-for-device root && \
109       adb wait-for-device remount)))
110
111# Sync test files to the target, depends upon all things that must be pushed to the target.
112.PHONY: test-art-target-sync
113# Check if we need to sync. In case ART_TEST_ANDROID_ROOT is not empty,
114# the code below uses 'adb push' instead of 'adb sync', which does not
115# check if the files on the device have changed.
116ifneq ($(ART_TEST_NO_SYNC),true)
117ifeq ($(ART_TEST_ANDROID_ROOT),)
118test-art-target-sync: $(TEST_ART_TARGET_SYNC_DEPS)
119	$(TEST_ART_ADB_ROOT_AND_REMOUNT)
120	adb sync system && adb sync data
121else
122test-art-target-sync: $(TEST_ART_TARGET_SYNC_DEPS)
123	$(TEST_ART_ADB_ROOT_AND_REMOUNT)
124	adb wait-for-device push $(PRODUCT_OUT)/system $(ART_TEST_ANDROID_ROOT)
125# Push the contents of the `data` dir into `/data` on the device.  If
126# `/data` already exists on the device, it is not overwritten, but its
127# contents are updated.
128	adb push $(PRODUCT_OUT)/data /
129endif
130endif
131
132# "mm test-art" to build and run all tests on host and device
133.PHONY: test-art
134test-art: test-art-host test-art-target
135	$(hide) $(call ART_TEST_PREREQ_FINISHED,$@)
136
137.PHONY: test-art-gtest
138test-art-gtest: test-art-host-gtest test-art-target-gtest
139	$(hide) $(call ART_TEST_PREREQ_FINISHED,$@)
140
141.PHONY: test-art-run-test
142test-art-run-test: test-art-host-run-test test-art-target-run-test
143	$(hide) $(call ART_TEST_PREREQ_FINISHED,$@)
144
145########################################################################
146# host test rules
147
148VIXL_TEST_DEPENDENCY :=
149# We can only run the vixl tests on 64-bit hosts (vixl testing issue) when its a
150# top-level build (to declare the vixl test rule).
151ifneq ($(HOST_PREFER_32_BIT),true)
152ifeq ($(ONE_SHOT_MAKEFILE),)
153VIXL_TEST_DEPENDENCY := run-vixl-tests
154endif
155endif
156
157.PHONY: test-art-host-vixl
158test-art-host-vixl: $(VIXL_TEST_DEPENDENCY)
159
160# "mm test-art-host" to build and run all host tests.
161.PHONY: test-art-host
162test-art-host: test-art-host-gtest test-art-host-run-test \
163               test-art-host-vixl test-art-host-dexdump
164	$(hide) $(call ART_TEST_PREREQ_FINISHED,$@)
165
166# All host tests that run solely with the default compiler.
167.PHONY: test-art-host-default
168test-art-host-default: test-art-host-run-test-default
169	$(hide) $(call ART_TEST_PREREQ_FINISHED,$@)
170
171# All host tests that run solely with the optimizing compiler.
172.PHONY: test-art-host-optimizing
173test-art-host-optimizing: test-art-host-run-test-optimizing
174	$(hide) $(call ART_TEST_PREREQ_FINISHED,$@)
175
176# All host tests that run solely on the interpreter.
177.PHONY: test-art-host-interpreter
178test-art-host-interpreter: test-art-host-run-test-interpreter
179	$(hide) $(call ART_TEST_PREREQ_FINISHED,$@)
180
181# All host tests that run solely on the jit.
182.PHONY: test-art-host-jit
183test-art-host-jit: test-art-host-run-test-jit
184	$(hide) $(call ART_TEST_PREREQ_FINISHED,$@)
185
186# Primary host architecture variants:
187.PHONY: test-art-host$(ART_PHONY_TEST_HOST_SUFFIX)
188test-art-host$(ART_PHONY_TEST_HOST_SUFFIX): test-art-host-gtest$(ART_PHONY_TEST_HOST_SUFFIX) \
189    test-art-host-run-test$(ART_PHONY_TEST_HOST_SUFFIX)
190	$(hide) $(call ART_TEST_PREREQ_FINISHED,$@)
191
192.PHONY: test-art-host-default$(ART_PHONY_TEST_HOST_SUFFIX)
193test-art-host-default$(ART_PHONY_TEST_HOST_SUFFIX): test-art-host-run-test-default$(ART_PHONY_TEST_HOST_SUFFIX)
194	$(hide) $(call ART_TEST_PREREQ_FINISHED,$@)
195
196.PHONY: test-art-host-optimizing$(ART_PHONY_TEST_HOST_SUFFIX)
197test-art-host-optimizing$(ART_PHONY_TEST_HOST_SUFFIX): test-art-host-run-test-optimizing$(ART_PHONY_TEST_HOST_SUFFIX)
198	$(hide) $(call ART_TEST_PREREQ_FINISHED,$@)
199
200.PHONY: test-art-host-interpreter$(ART_PHONY_TEST_HOST_SUFFIX)
201test-art-host-interpreter$(ART_PHONY_TEST_HOST_SUFFIX): test-art-host-run-test-interpreter$(ART_PHONY_TEST_HOST_SUFFIX)
202	$(hide) $(call ART_TEST_PREREQ_FINISHED,$@)
203
204.PHONY: test-art-host-jit$(ART_PHONY_TEST_HOST_SUFFIX)
205test-art-host-jit$(ART_PHONY_TEST_HOST_SUFFIX): test-art-host-run-test-jit$(ART_PHONY_TEST_HOST_SUFFIX)
206	$(hide) $(call ART_TEST_PREREQ_FINISHED,$@)
207
208# Secondary host architecture variants:
209ifneq ($(HOST_PREFER_32_BIT),true)
210.PHONY: test-art-host$(2ND_ART_PHONY_TEST_HOST_SUFFIX)
211test-art-host$(2ND_ART_PHONY_TEST_HOST_SUFFIX): test-art-host-gtest$(2ND_ART_PHONY_TEST_HOST_SUFFIX) \
212    test-art-host-run-test$(2ND_ART_PHONY_TEST_HOST_SUFFIX)
213	$(hide) $(call ART_TEST_PREREQ_FINISHED,$@)
214
215.PHONY: test-art-host-default$(2ND_ART_PHONY_TEST_HOST_SUFFIX)
216test-art-host-default$(2ND_ART_PHONY_TEST_HOST_SUFFIX): test-art-host-run-test-default$(2ND_ART_PHONY_TEST_HOST_SUFFIX)
217	$(hide) $(call ART_TEST_PREREQ_FINISHED,$@)
218
219.PHONY: test-art-host-optimizing$(2ND_ART_PHONY_TEST_HOST_SUFFIX)
220test-art-host-optimizing$(2ND_ART_PHONY_TEST_HOST_SUFFIX): test-art-host-run-test-optimizing$(2ND_ART_PHONY_TEST_HOST_SUFFIX)
221	$(hide) $(call ART_TEST_PREREQ_FINISHED,$@)
222
223.PHONY: test-art-host-interpreter$(2ND_ART_PHONY_TEST_HOST_SUFFIX)
224test-art-host-interpreter$(2ND_ART_PHONY_TEST_HOST_SUFFIX): test-art-host-run-test-interpreter$(2ND_ART_PHONY_TEST_HOST_SUFFIX)
225	$(hide) $(call ART_TEST_PREREQ_FINISHED,$@)
226
227.PHONY: test-art-host-jit$(2ND_ART_PHONY_TEST_HOST_SUFFIX)
228test-art-host-jit$(2ND_ART_PHONY_TEST_HOST_SUFFIX): test-art-host-run-test-jit$(2ND_ART_PHONY_TEST_HOST_SUFFIX)
229	$(hide) $(call ART_TEST_PREREQ_FINISHED,$@)
230endif
231
232# Dexdump/list regression test.
233.PHONY: test-art-host-dexdump
234test-art-host-dexdump: $(addprefix $(HOST_OUT_EXECUTABLES)/, dexdump2 dexlist)
235	ANDROID_HOST_OUT=$(realpath $(HOST_OUT)) art/test/dexdump/run-all-tests
236
237# Valgrind.
238.PHONY: valgrind-test-art-host
239valgrind-test-art-host: valgrind-test-art-host-gtest
240	$(hide) $(call ART_TEST_PREREQ_FINISHED,$@)
241
242.PHONY: valgrind-test-art-host32
243valgrind-test-art-host32: valgrind-test-art-host-gtest32
244	$(hide) $(call ART_TEST_PREREQ_FINISHED,$@)
245
246.PHONY: valgrind-test-art-host64
247valgrind-test-art-host64: valgrind-test-art-host-gtest64
248	$(hide) $(call ART_TEST_PREREQ_FINISHED,$@)
249
250########################################################################
251# target test rules
252
253# "mm test-art-target" to build and run all target tests.
254.PHONY: test-art-target
255test-art-target: test-art-target-gtest test-art-target-run-test
256	$(hide) $(call ART_TEST_PREREQ_FINISHED,$@)
257
258# All target tests that run solely with the default compiler.
259.PHONY: test-art-target-default
260test-art-target-default: test-art-target-run-test-default
261	$(hide) $(call ART_TEST_PREREQ_FINISHED,$@)
262
263# All target tests that run solely with the optimizing compiler.
264.PHONY: test-art-target-optimizing
265test-art-target-optimizing: test-art-target-run-test-optimizing
266	$(hide) $(call ART_TEST_PREREQ_FINISHED,$@)
267
268# All target tests that run solely on the interpreter.
269.PHONY: test-art-target-interpreter
270test-art-target-interpreter: test-art-target-run-test-interpreter
271	$(hide) $(call ART_TEST_PREREQ_FINISHED,$@)
272
273# All target tests that run solely on the jit.
274.PHONY: test-art-target-jit
275test-art-target-jit: test-art-target-run-test-jit
276	$(hide) $(call ART_TEST_PREREQ_FINISHED,$@)
277
278# Primary target architecture variants:
279.PHONY: test-art-target$(ART_PHONY_TEST_TARGET_SUFFIX)
280test-art-target$(ART_PHONY_TEST_TARGET_SUFFIX): test-art-target-gtest$(ART_PHONY_TEST_TARGET_SUFFIX) \
281    test-art-target-run-test$(ART_PHONY_TEST_TARGET_SUFFIX)
282	$(hide) $(call ART_TEST_PREREQ_FINISHED,$@)
283
284.PHONY: test-art-target-default$(ART_PHONY_TEST_TARGET_SUFFIX)
285test-art-target-default$(ART_PHONY_TEST_TARGET_SUFFIX): test-art-target-run-test-default$(ART_PHONY_TEST_TARGET_SUFFIX)
286	$(hide) $(call ART_TEST_PREREQ_FINISHED,$@)
287
288.PHONY: test-art-target-optimizing$(ART_PHONY_TEST_TARGET_SUFFIX)
289test-art-target-optimizing$(ART_PHONY_TEST_TARGET_SUFFIX): test-art-target-run-test-optimizing$(ART_PHONY_TEST_TARGET_SUFFIX)
290	$(hide) $(call ART_TEST_PREREQ_FINISHED,$@)
291
292.PHONY: test-art-target-interpreter$(ART_PHONY_TEST_TARGET_SUFFIX)
293test-art-target-interpreter$(ART_PHONY_TEST_TARGET_SUFFIX): test-art-target-run-test-interpreter$(ART_PHONY_TEST_TARGET_SUFFIX)
294	$(hide) $(call ART_TEST_PREREQ_FINISHED,$@)
295
296.PHONY: test-art-target-jit$(ART_PHONY_TEST_TARGET_SUFFIX)
297test-art-target-jit$(ART_PHONY_TEST_TARGET_SUFFIX): test-art-target-run-test-jit$(ART_PHONY_TEST_TARGET_SUFFIX)
298	$(hide) $(call ART_TEST_PREREQ_FINISHED,$@)
299
300# Secondary target architecture variants:
301ifdef TARGET_2ND_ARCH
302.PHONY: test-art-target$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)
303test-art-target$(2ND_ART_PHONY_TEST_TARGET_SUFFIX): test-art-target-gtest$(2ND_ART_PHONY_TEST_TARGET_SUFFIX) \
304    test-art-target-run-test$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)
305	$(hide) $(call ART_TEST_PREREQ_FINISHED,$@)
306
307.PHONY: test-art-target-default$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)
308test-art-target-default$(2ND_ART_PHONY_TEST_TARGET_SUFFIX): test-art-target-run-test-default$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)
309	$(hide) $(call ART_TEST_PREREQ_FINISHED,$@)
310
311.PHONY: test-art-target-optimizing$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)
312test-art-target-optimizing$(2ND_ART_PHONY_TEST_TARGET_SUFFIX): test-art-target-run-test-optimizing$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)
313	$(hide) $(call ART_TEST_PREREQ_FINISHED,$@)
314
315.PHONY: test-art-target-interpreter$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)
316test-art-target-interpreter$(2ND_ART_PHONY_TEST_TARGET_SUFFIX): test-art-target-run-test-interpreter$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)
317	$(hide) $(call ART_TEST_PREREQ_FINISHED,$@)
318
319.PHONY: test-art-target-jit$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)
320test-art-target-jit$(2ND_ART_PHONY_TEST_TARGET_SUFFIX): test-art-target-run-test-jit$(2ND_ART_PHONY_TEST_TARGET_SUFFIX)
321	$(hide) $(call ART_TEST_PREREQ_FINISHED,$@)
322endif
323
324# Valgrind.
325.PHONY: valgrind-test-art-target
326valgrind-test-art-target: valgrind-test-art-target-gtest
327	$(hide) $(call ART_TEST_PREREQ_FINISHED,$@)
328
329.PHONY: valgrind-test-art-target32
330valgrind-test-art-target32: valgrind-test-art-target-gtest32
331	$(hide) $(call ART_TEST_PREREQ_FINISHED,$@)
332
333.PHONY: valgrind-test-art-target64
334valgrind-test-art-target64: valgrind-test-art-target-gtest64
335	$(hide) $(call ART_TEST_PREREQ_FINISHED,$@)
336
337
338#######################
339# Fake packages for ART
340
341# The art-runtime package depends on the core ART libraries and binaries. It exists so we can
342# manipulate the set of things shipped, e.g., add debug versions and so on.
343
344include $(CLEAR_VARS)
345LOCAL_MODULE := art-runtime
346
347# Base requirements.
348LOCAL_REQUIRED_MODULES := \
349    dalvikvm \
350    dex2oat \
351    dexoptanalyzer \
352    libart \
353    libart-compiler \
354    libopenjdkjvm \
355    libopenjdkjvmti \
356    patchoat \
357    profman \
358    libadbconnection \
359
360# For nosy apps, we provide a fake library that avoids namespace issues and gives some warnings.
361LOCAL_REQUIRED_MODULES += libart_fake
362
363# Potentially add in debug variants:
364#
365# * We will never add them if PRODUCT_ART_TARGET_INCLUDE_DEBUG_BUILD = false.
366# * We will always add them if PRODUCT_ART_TARGET_INCLUDE_DEBUG_BUILD = true.
367# * Otherwise, we will add them by default to userdebug and eng builds.
368art_target_include_debug_build := $(PRODUCT_ART_TARGET_INCLUDE_DEBUG_BUILD)
369ifneq (false,$(art_target_include_debug_build))
370ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT)))
371  art_target_include_debug_build := true
372endif
373ifeq (true,$(art_target_include_debug_build))
374LOCAL_REQUIRED_MODULES += \
375    dex2oatd \
376    dexoptanalyzerd \
377    libartd \
378    libartd-compiler \
379    libopenjdkd \
380    libopenjdkjvmd \
381    libopenjdkjvmtid \
382    patchoatd \
383    profmand \
384    libadbconnectiond \
385
386endif
387endif
388
389include $(BUILD_PHONY_PACKAGE)
390
391# The art-tools package depends on helpers and tools that are useful for developers and on-device
392# investigations.
393
394include $(CLEAR_VARS)
395LOCAL_MODULE := art-tools
396LOCAL_REQUIRED_MODULES := \
397    ahat \
398    dexdiag \
399    dexdump \
400    dexlist \
401    hprof-conv \
402    oatdump \
403
404include $(BUILD_PHONY_PACKAGE)
405
406####################################################################################################
407# Fake packages to ensure generation of libopenjdkd when one builds with mm/mmm/mmma.
408#
409# The library is required for starting a runtime in debug mode, but libartd does not depend on it
410# (dependency cycle otherwise).
411#
412# Note: * As the package is phony to create a dependency the package name is irrelevant.
413#       * We make MULTILIB explicit to "both," just to state here that we want both libraries on
414#         64-bit systems, even if it is the default.
415
416# ART on the host.
417ifeq ($(ART_BUILD_HOST_DEBUG),true)
418include $(CLEAR_VARS)
419LOCAL_MODULE := art-libartd-libopenjdkd-host-dependency
420LOCAL_MULTILIB := both
421LOCAL_REQUIRED_MODULES := libopenjdkd
422LOCAL_IS_HOST_MODULE := true
423include $(BUILD_PHONY_PACKAGE)
424endif
425
426# ART on the target.
427ifeq ($(ART_BUILD_TARGET_DEBUG),true)
428include $(CLEAR_VARS)
429LOCAL_MODULE := art-libartd-libopenjdkd-target-dependency
430LOCAL_MULTILIB := both
431LOCAL_REQUIRED_MODULES := libopenjdkd
432include $(BUILD_PHONY_PACKAGE)
433endif
434
435# Create dummy hidden API lists which are normally generated by the framework
436# but which we do not have in the master-art manifest.
437# We need to execute this now to ensure Makefile rules depending on these files can
438# be constructed.
439define build-art-hiddenapi
440$(shell if [ ! -d frameworks/base ]; then \
441  mkdir -p ${TARGET_OUT_COMMON_INTERMEDIATES}/PACKAGING; \
442	touch ${TARGET_OUT_COMMON_INTERMEDIATES}/PACKAGING/hiddenapi-{blacklist,dark-greylist,light-greylist}.txt; \
443  fi;)
444endef
445
446$(eval $(call build-art-hiddenapi))
447
448########################################################################
449# "m build-art" for quick minimal build
450.PHONY: build-art
451build-art: build-art-host build-art-target
452
453.PHONY: build-art-host
454build-art-host:   $(HOST_OUT_EXECUTABLES)/art $(ART_HOST_DEPENDENCIES) $(HOST_CORE_IMG_OUTS)
455
456.PHONY: build-art-target
457build-art-target: $(TARGET_OUT_EXECUTABLES)/art $(ART_TARGET_DEPENDENCIES) $(TARGET_CORE_IMG_OUTS)
458
459########################################################################
460# Phony target for only building what go/lem requires for pushing ART on /data.
461
462.PHONY: build-art-target-golem
463# Also include libartbenchmark, we always include it when running golem.
464# libstdc++ is needed when building for ART_TARGET_LINUX.
465ART_TARGET_SHARED_LIBRARY_BENCHMARK := $(TARGET_OUT_SHARED_LIBRARIES)/libartbenchmark.so
466build-art-target-golem: dex2oat dalvikvm patchoat linker libstdc++ \
467                        $(TARGET_OUT_EXECUTABLES)/art \
468                        $(TARGET_OUT)/etc/public.libraries.txt \
469                        $(ART_TARGET_DEX_DEPENDENCIES) \
470                        $(ART_TARGET_SHARED_LIBRARY_DEPENDENCIES) \
471                        $(ART_TARGET_SHARED_LIBRARY_BENCHMARK) \
472                        $(TARGET_CORE_IMG_OUT_BASE).art \
473                        $(TARGET_CORE_IMG_OUT_BASE)-interpreter.art
474	# remove libartd.so and libdexfiled.so from public.libraries.txt because golem builds
475	# won't have it.
476	sed -i '/libartd.so/d' $(TARGET_OUT)/etc/public.libraries.txt
477	sed -i '/libdexfiled.so/d' $(TARGET_OUT)/etc/public.libraries.txt
478
479########################################################################
480# Phony target for building what go/lem requires on host.
481.PHONY: build-art-host-golem
482# Also include libartbenchmark, we always include it when running golem.
483ART_HOST_SHARED_LIBRARY_BENCHMARK := $(ART_HOST_OUT_SHARED_LIBRARIES)/libartbenchmark.so
484build-art-host-golem: build-art-host \
485                      $(ART_HOST_SHARED_LIBRARY_BENCHMARK)
486
487########################################################################
488# Phony target for building what go/lem requires for syncing /system to target.
489.PHONY: build-art-unbundled-golem
490build-art-unbundled-golem: art-runtime linker oatdump $(TARGET_CORE_JARS) crash_dump
491
492########################################################################
493# Rules for building all dependencies for tests.
494
495.PHONY: build-art-host-tests
496build-art-host-tests:   build-art-host $(TEST_ART_RUN_TEST_DEPENDENCIES) $(ART_TEST_HOST_RUN_TEST_DEPENDENCIES) $(ART_TEST_HOST_GTEST_DEPENDENCIES) | $(TEST_ART_RUN_TEST_ORDERONLY_DEPENDENCIES)
497
498.PHONY: build-art-target-tests
499build-art-target-tests:   build-art-target $(TEST_ART_RUN_TEST_DEPENDENCIES) $(TEST_ART_TARGET_SYNC_DEPS) | $(TEST_ART_RUN_TEST_ORDERONLY_DEPENDENCIES)
500
501########################################################################
502# targets to switch back and forth from libdvm to libart
503
504.PHONY: use-art
505use-art:
506	adb root
507	adb wait-for-device shell stop
508	adb shell setprop persist.sys.dalvik.vm.lib.2 libart.so
509	adb shell start
510
511.PHONY: use-artd
512use-artd:
513	adb root
514	adb wait-for-device shell stop
515	adb shell setprop persist.sys.dalvik.vm.lib.2 libartd.so
516	adb shell start
517
518.PHONY: use-dalvik
519use-dalvik:
520	adb root
521	adb wait-for-device shell stop
522	adb shell setprop persist.sys.dalvik.vm.lib.2 libdvm.so
523	adb shell start
524
525.PHONY: use-art-full
526use-art-full:
527	adb root
528	adb wait-for-device shell stop
529	adb shell rm -rf $(ART_TARGET_DALVIK_CACHE_DIR)/*
530	adb shell setprop dalvik.vm.dex2oat-filter \"\"
531	adb shell setprop dalvik.vm.image-dex2oat-filter \"\"
532	adb shell setprop persist.sys.dalvik.vm.lib.2 libart.so
533	adb shell setprop dalvik.vm.usejit false
534	adb shell start
535
536.PHONY: use-artd-full
537use-artd-full:
538	adb root
539	adb wait-for-device shell stop
540	adb shell rm -rf $(ART_TARGET_DALVIK_CACHE_DIR)/*
541	adb shell setprop dalvik.vm.dex2oat-filter \"\"
542	adb shell setprop dalvik.vm.image-dex2oat-filter \"\"
543	adb shell setprop persist.sys.dalvik.vm.lib.2 libartd.so
544	adb shell setprop dalvik.vm.usejit false
545	adb shell start
546
547.PHONY: use-art-jit
548use-art-jit:
549	adb root
550	adb wait-for-device shell stop
551	adb shell rm -rf $(ART_TARGET_DALVIK_CACHE_DIR)/*
552	adb shell setprop dalvik.vm.dex2oat-filter "verify-at-runtime"
553	adb shell setprop dalvik.vm.image-dex2oat-filter "verify-at-runtime"
554	adb shell setprop persist.sys.dalvik.vm.lib.2 libart.so
555	adb shell setprop dalvik.vm.usejit true
556	adb shell start
557
558.PHONY: use-art-interpret-only
559use-art-interpret-only:
560	adb root
561	adb wait-for-device shell stop
562	adb shell rm -rf $(ART_TARGET_DALVIK_CACHE_DIR)/*
563	adb shell setprop dalvik.vm.dex2oat-filter "interpret-only"
564	adb shell setprop dalvik.vm.image-dex2oat-filter "interpret-only"
565	adb shell setprop persist.sys.dalvik.vm.lib.2 libart.so
566	adb shell setprop dalvik.vm.usejit false
567	adb shell start
568
569.PHONY: use-artd-interpret-only
570use-artd-interpret-only:
571	adb root
572	adb wait-for-device shell stop
573	adb shell rm -rf $(ART_TARGET_DALVIK_CACHE_DIR)/*
574	adb shell setprop dalvik.vm.dex2oat-filter "interpret-only"
575	adb shell setprop dalvik.vm.image-dex2oat-filter "interpret-only"
576	adb shell setprop persist.sys.dalvik.vm.lib.2 libartd.so
577	adb shell setprop dalvik.vm.usejit false
578	adb shell start
579
580.PHONY: use-art-verify-none
581use-art-verify-none:
582	adb root
583	adb wait-for-device shell stop
584	adb shell rm -rf $(ART_TARGET_DALVIK_CACHE_DIR)/*
585	adb shell setprop dalvik.vm.dex2oat-filter "verify-none"
586	adb shell setprop dalvik.vm.image-dex2oat-filter "verify-none"
587	adb shell setprop persist.sys.dalvik.vm.lib.2 libart.so
588	adb shell setprop dalvik.vm.usejit false
589	adb shell start
590
591########################################################################
592
593# Clear locally used variables.
594TEST_ART_TARGET_SYNC_DEPS :=
595
596# Helper target that depends on boot image creation.
597#
598# Can be used, for example, to dump initialization failures:
599#   m art-boot-image ART_BOOT_IMAGE_EXTRA_ARGS=--dump-init-failures=fails.txt
600.PHONY: art-boot-image
601art-boot-image: $(DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME)
602
603.PHONY: art-job-images
604art-job-images: \
605  $(DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME) \
606  $(2ND_DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME) \
607  $(HOST_OUT_EXECUTABLES)/dex2oats \
608  $(HOST_OUT_EXECUTABLES)/dex2oatds \
609  $(HOST_OUT_EXECUTABLES)/profman
610