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 26 27.PHONY: clean-oat 28clean-oat: clean-oat-host clean-oat-target 29 30.PHONY: clean-oat-host 31clean-oat-host: 32 find $(OUT_DIR) '(' -name '*.oat' -o -name '*.odex' -o -name '*.art' -o -name '*.vdex' ')' -a -type f | xargs rm -f 33 rm -rf $(TMPDIR)/*/test-*/dalvik-cache/* 34 rm -rf $(TMPDIR)/android-data/dalvik-cache/* 35 36.PHONY: clean-oat-target 37clean-oat-target: 38 $(ADB) root 39 $(ADB) wait-for-device remount 40 $(ADB) shell rm -rf $(ART_TARGET_NATIVETEST_DIR) 41 $(ADB) shell rm -rf $(ART_TARGET_TEST_DIR) 42 $(ADB) shell rm -rf $(ART_TARGET_DALVIK_CACHE_DIR)/*/* 43 $(ADB) shell rm -rf $(ART_DEXPREOPT_BOOT_JAR_DIR)/$(DEX2OAT_TARGET_ARCH) 44 $(ADB) shell rm -rf system/app/$(DEX2OAT_TARGET_ARCH) 45ifdef TARGET_2ND_ARCH 46 $(ADB) shell rm -rf $(ART_DEXPREOPT_BOOT_JAR_DIR)/$($(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_ARCH) 47 $(ADB) shell rm -rf system/app/$($(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_ARCH) 48endif 49 $(ADB) shell rm -rf data/run-test/test-*/dalvik-cache/* 50 51######################################################################## 52# cpplint rules to style check art source files 53 54include $(art_path)/build/Android.cpplint.mk 55 56######################################################################## 57# product rules 58 59include $(art_path)/oatdump/Android.mk 60include $(art_path)/tools/ahat/Android.mk 61include $(art_path)/tools/dexfuzz/Android.mk 62include $(art_path)/tools/veridex/Android.mk 63 64ART_HOST_DEPENDENCIES := \ 65 $(ART_HOST_EXECUTABLES) \ 66 $(ART_HOST_DEX_DEPENDENCIES) \ 67 $(ART_HOST_SHARED_LIBRARY_DEPENDENCIES) 68 69ifeq ($(ART_BUILD_HOST_DEBUG),true) 70ART_HOST_DEPENDENCIES += $(ART_HOST_SHARED_LIBRARY_DEBUG_DEPENDENCIES) 71endif 72 73ART_TARGET_DEPENDENCIES := \ 74 $(ART_TARGET_DEX_DEPENDENCIES) 75 76######################################################################## 77# test rules 78 79# All the dependencies that must be built ahead of sync-ing them onto the target device. 80TEST_ART_TARGET_SYNC_DEPS := $(ADB_EXECUTABLE) 81 82include $(art_path)/build/Android.common_test.mk 83include $(art_path)/build/Android.gtest.mk 84include $(art_path)/test/Android.run-test.mk 85 86TEST_ART_TARGET_SYNC_DEPS += $(ART_TEST_TARGET_GTEST_DEPENDENCIES) $(ART_TEST_TARGET_RUN_TEST_DEPENDENCIES) 87 88# Make sure /system is writable on the device. 89TEST_ART_ADB_ROOT_AND_REMOUNT := \ 90 ($(ADB) root && \ 91 $(ADB) wait-for-device remount && \ 92 (($(ADB) shell touch /system/testfile && \ 93 ($(ADB) shell rm /system/testfile || true)) || \ 94 ($(ADB) disable-verity && \ 95 $(ADB) reboot && \ 96 $(ADB) wait-for-device root && \ 97 $(ADB) wait-for-device remount))) 98 99# "mm test-art" to build and run all tests on host and device 100.PHONY: test-art 101test-art: test-art-host test-art-target 102 $(hide) $(call ART_TEST_PREREQ_FINISHED,$@) 103 104.PHONY: test-art-gtest 105test-art-gtest: test-art-host-gtest test-art-target-gtest 106 $(hide) $(call ART_TEST_PREREQ_FINISHED,$@) 107 108.PHONY: test-art-run-test 109test-art-run-test: test-art-host-run-test test-art-target-run-test 110 $(hide) $(call ART_TEST_PREREQ_FINISHED,$@) 111 112######################################################################## 113# host test rules 114 115VIXL_TEST_DEPENDENCY := 116# We can only run the vixl tests on 64-bit hosts (vixl testing issue) when its a 117# top-level build (to declare the vixl test rule). 118ifneq ($(HOST_PREFER_32_BIT),true) 119ifeq ($(ONE_SHOT_MAKEFILE),) 120VIXL_TEST_DEPENDENCY := run-vixl-tests 121endif 122endif 123 124.PHONY: test-art-host-vixl 125test-art-host-vixl: $(VIXL_TEST_DEPENDENCY) 126 127# "mm test-art-host" to build and run all host tests. 128.PHONY: test-art-host 129test-art-host: test-art-host-gtest test-art-host-run-test \ 130 test-art-host-vixl test-art-host-dexdump 131 $(hide) $(call ART_TEST_PREREQ_FINISHED,$@) 132 133# All host tests that run solely with the default compiler. 134.PHONY: test-art-host-default 135test-art-host-default: test-art-host-run-test-default 136 $(hide) $(call ART_TEST_PREREQ_FINISHED,$@) 137 138# All host tests that run solely with the optimizing compiler. 139.PHONY: test-art-host-optimizing 140test-art-host-optimizing: test-art-host-run-test-optimizing 141 $(hide) $(call ART_TEST_PREREQ_FINISHED,$@) 142 143# All host tests that run solely on the interpreter. 144.PHONY: test-art-host-interpreter 145test-art-host-interpreter: test-art-host-run-test-interpreter 146 $(hide) $(call ART_TEST_PREREQ_FINISHED,$@) 147 148# All host tests that run solely on the jit. 149.PHONY: test-art-host-jit 150test-art-host-jit: test-art-host-run-test-jit 151 $(hide) $(call ART_TEST_PREREQ_FINISHED,$@) 152 153# Primary host architecture variants: 154.PHONY: test-art-host$(ART_PHONY_TEST_HOST_SUFFIX) 155test-art-host$(ART_PHONY_TEST_HOST_SUFFIX): test-art-host-gtest$(ART_PHONY_TEST_HOST_SUFFIX) \ 156 test-art-host-run-test$(ART_PHONY_TEST_HOST_SUFFIX) 157 $(hide) $(call ART_TEST_PREREQ_FINISHED,$@) 158 159.PHONY: test-art-host-default$(ART_PHONY_TEST_HOST_SUFFIX) 160test-art-host-default$(ART_PHONY_TEST_HOST_SUFFIX): test-art-host-run-test-default$(ART_PHONY_TEST_HOST_SUFFIX) 161 $(hide) $(call ART_TEST_PREREQ_FINISHED,$@) 162 163.PHONY: test-art-host-optimizing$(ART_PHONY_TEST_HOST_SUFFIX) 164test-art-host-optimizing$(ART_PHONY_TEST_HOST_SUFFIX): test-art-host-run-test-optimizing$(ART_PHONY_TEST_HOST_SUFFIX) 165 $(hide) $(call ART_TEST_PREREQ_FINISHED,$@) 166 167.PHONY: test-art-host-interpreter$(ART_PHONY_TEST_HOST_SUFFIX) 168test-art-host-interpreter$(ART_PHONY_TEST_HOST_SUFFIX): test-art-host-run-test-interpreter$(ART_PHONY_TEST_HOST_SUFFIX) 169 $(hide) $(call ART_TEST_PREREQ_FINISHED,$@) 170 171.PHONY: test-art-host-jit$(ART_PHONY_TEST_HOST_SUFFIX) 172test-art-host-jit$(ART_PHONY_TEST_HOST_SUFFIX): test-art-host-run-test-jit$(ART_PHONY_TEST_HOST_SUFFIX) 173 $(hide) $(call ART_TEST_PREREQ_FINISHED,$@) 174 175# Secondary host architecture variants: 176ifneq ($(HOST_PREFER_32_BIT),true) 177.PHONY: test-art-host$(2ND_ART_PHONY_TEST_HOST_SUFFIX) 178test-art-host$(2ND_ART_PHONY_TEST_HOST_SUFFIX): test-art-host-gtest$(2ND_ART_PHONY_TEST_HOST_SUFFIX) \ 179 test-art-host-run-test$(2ND_ART_PHONY_TEST_HOST_SUFFIX) 180 $(hide) $(call ART_TEST_PREREQ_FINISHED,$@) 181 182.PHONY: test-art-host-default$(2ND_ART_PHONY_TEST_HOST_SUFFIX) 183test-art-host-default$(2ND_ART_PHONY_TEST_HOST_SUFFIX): test-art-host-run-test-default$(2ND_ART_PHONY_TEST_HOST_SUFFIX) 184 $(hide) $(call ART_TEST_PREREQ_FINISHED,$@) 185 186.PHONY: test-art-host-optimizing$(2ND_ART_PHONY_TEST_HOST_SUFFIX) 187test-art-host-optimizing$(2ND_ART_PHONY_TEST_HOST_SUFFIX): test-art-host-run-test-optimizing$(2ND_ART_PHONY_TEST_HOST_SUFFIX) 188 $(hide) $(call ART_TEST_PREREQ_FINISHED,$@) 189 190.PHONY: test-art-host-interpreter$(2ND_ART_PHONY_TEST_HOST_SUFFIX) 191test-art-host-interpreter$(2ND_ART_PHONY_TEST_HOST_SUFFIX): test-art-host-run-test-interpreter$(2ND_ART_PHONY_TEST_HOST_SUFFIX) 192 $(hide) $(call ART_TEST_PREREQ_FINISHED,$@) 193 194.PHONY: test-art-host-jit$(2ND_ART_PHONY_TEST_HOST_SUFFIX) 195test-art-host-jit$(2ND_ART_PHONY_TEST_HOST_SUFFIX): test-art-host-run-test-jit$(2ND_ART_PHONY_TEST_HOST_SUFFIX) 196 $(hide) $(call ART_TEST_PREREQ_FINISHED,$@) 197endif 198 199# Dexdump/list regression test. 200.PHONY: test-art-host-dexdump 201test-art-host-dexdump: $(addprefix $(HOST_OUT_EXECUTABLES)/, dexdump dexlist) 202 ANDROID_HOST_OUT=$(realpath $(HOST_OUT)) art/test/dexdump/run-all-tests 203 204######################################################################## 205# target test rules 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-run-test 210 $(hide) $(call ART_TEST_PREREQ_FINISHED,$@) 211 212# All target tests that run solely with the default compiler. 213.PHONY: test-art-target-default 214test-art-target-default: test-art-target-run-test-default 215 $(hide) $(call ART_TEST_PREREQ_FINISHED,$@) 216 217# All target tests that run solely with the optimizing compiler. 218.PHONY: test-art-target-optimizing 219test-art-target-optimizing: test-art-target-run-test-optimizing 220 $(hide) $(call ART_TEST_PREREQ_FINISHED,$@) 221 222# All target tests that run solely on the interpreter. 223.PHONY: test-art-target-interpreter 224test-art-target-interpreter: test-art-target-run-test-interpreter 225 $(hide) $(call ART_TEST_PREREQ_FINISHED,$@) 226 227# All target tests that run solely on the jit. 228.PHONY: test-art-target-jit 229test-art-target-jit: test-art-target-run-test-jit 230 $(hide) $(call ART_TEST_PREREQ_FINISHED,$@) 231 232# Primary target architecture variants: 233.PHONY: test-art-target$(ART_PHONY_TEST_TARGET_SUFFIX) 234test-art-target$(ART_PHONY_TEST_TARGET_SUFFIX): test-art-target-gtest$(ART_PHONY_TEST_TARGET_SUFFIX) \ 235 test-art-target-run-test$(ART_PHONY_TEST_TARGET_SUFFIX) 236 $(hide) $(call ART_TEST_PREREQ_FINISHED,$@) 237 238.PHONY: test-art-target-default$(ART_PHONY_TEST_TARGET_SUFFIX) 239test-art-target-default$(ART_PHONY_TEST_TARGET_SUFFIX): test-art-target-run-test-default$(ART_PHONY_TEST_TARGET_SUFFIX) 240 $(hide) $(call ART_TEST_PREREQ_FINISHED,$@) 241 242.PHONY: test-art-target-optimizing$(ART_PHONY_TEST_TARGET_SUFFIX) 243test-art-target-optimizing$(ART_PHONY_TEST_TARGET_SUFFIX): test-art-target-run-test-optimizing$(ART_PHONY_TEST_TARGET_SUFFIX) 244 $(hide) $(call ART_TEST_PREREQ_FINISHED,$@) 245 246.PHONY: test-art-target-interpreter$(ART_PHONY_TEST_TARGET_SUFFIX) 247test-art-target-interpreter$(ART_PHONY_TEST_TARGET_SUFFIX): test-art-target-run-test-interpreter$(ART_PHONY_TEST_TARGET_SUFFIX) 248 $(hide) $(call ART_TEST_PREREQ_FINISHED,$@) 249 250.PHONY: test-art-target-jit$(ART_PHONY_TEST_TARGET_SUFFIX) 251test-art-target-jit$(ART_PHONY_TEST_TARGET_SUFFIX): test-art-target-run-test-jit$(ART_PHONY_TEST_TARGET_SUFFIX) 252 $(hide) $(call ART_TEST_PREREQ_FINISHED,$@) 253 254# Secondary target architecture variants: 255ifdef 2ND_ART_PHONY_TEST_TARGET_SUFFIX 256.PHONY: test-art-target$(2ND_ART_PHONY_TEST_TARGET_SUFFIX) 257test-art-target$(2ND_ART_PHONY_TEST_TARGET_SUFFIX): test-art-target-gtest$(2ND_ART_PHONY_TEST_TARGET_SUFFIX) \ 258 test-art-target-run-test$(2ND_ART_PHONY_TEST_TARGET_SUFFIX) 259 $(hide) $(call ART_TEST_PREREQ_FINISHED,$@) 260 261.PHONY: test-art-target-default$(2ND_ART_PHONY_TEST_TARGET_SUFFIX) 262test-art-target-default$(2ND_ART_PHONY_TEST_TARGET_SUFFIX): test-art-target-run-test-default$(2ND_ART_PHONY_TEST_TARGET_SUFFIX) 263 $(hide) $(call ART_TEST_PREREQ_FINISHED,$@) 264 265.PHONY: test-art-target-optimizing$(2ND_ART_PHONY_TEST_TARGET_SUFFIX) 266test-art-target-optimizing$(2ND_ART_PHONY_TEST_TARGET_SUFFIX): test-art-target-run-test-optimizing$(2ND_ART_PHONY_TEST_TARGET_SUFFIX) 267 $(hide) $(call ART_TEST_PREREQ_FINISHED,$@) 268 269.PHONY: test-art-target-interpreter$(2ND_ART_PHONY_TEST_TARGET_SUFFIX) 270test-art-target-interpreter$(2ND_ART_PHONY_TEST_TARGET_SUFFIX): test-art-target-run-test-interpreter$(2ND_ART_PHONY_TEST_TARGET_SUFFIX) 271 $(hide) $(call ART_TEST_PREREQ_FINISHED,$@) 272 273.PHONY: test-art-target-jit$(2ND_ART_PHONY_TEST_TARGET_SUFFIX) 274test-art-target-jit$(2ND_ART_PHONY_TEST_TARGET_SUFFIX): test-art-target-run-test-jit$(2ND_ART_PHONY_TEST_TARGET_SUFFIX) 275 $(hide) $(call ART_TEST_PREREQ_FINISHED,$@) 276endif 277 278 279####################### 280# ART APEX. 281 282include $(CLEAR_VARS) 283 284# The ART APEX comes in three flavors: 285# - the release module (`com.android.art.release`), containing 286# only "release" artifacts; 287# - the debug module (`com.android.art.debug`), containing both 288# "release" and "debug" artifacts, as well as additional tools; 289# - the testing module (`com.android.art.testing`), containing 290# both "release" and "debug" artifacts, as well as additional tools 291# and ART gtests). 292# 293# The ART APEX module (`com.android.art`) is an "alias" for either the 294# release or the debug module. By default, "user" build variants contain 295# the release module, while "userdebug" and "eng" build variants contain 296# the debug module. However, if `PRODUCT_ART_TARGET_INCLUDE_DEBUG_BUILD` 297# is defined, it overrides the previous logic: 298# - if `PRODUCT_ART_TARGET_INCLUDE_DEBUG_BUILD` is set to `false`, the 299# build will include the release module (whatever the build 300# variant); 301# - if `PRODUCT_ART_TARGET_INCLUDE_DEBUG_BUILD` is set to `true`, the 302# build will include the debug module (whatever the build variant). 303 304art_target_include_debug_build := $(PRODUCT_ART_TARGET_INCLUDE_DEBUG_BUILD) 305ifneq (false,$(art_target_include_debug_build)) 306 ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT))) 307 art_target_include_debug_build := true 308 endif 309endif 310ifeq (true,$(art_target_include_debug_build)) 311 # Module with both release and debug variants, as well as 312 # additional tools. 313 TARGET_ART_APEX := $(DEBUG_ART_APEX) 314 APEX_TEST_MODULE := art-check-debug-apex-gen-fakebin 315else 316 # Release module (without debug variants nor tools). 317 TARGET_ART_APEX := $(RELEASE_ART_APEX) 318 APEX_TEST_MODULE := art-check-release-apex-gen-fakebin 319endif 320 321LOCAL_MODULE := com.android.art 322LOCAL_REQUIRED_MODULES := $(TARGET_ART_APEX) 323 324# Clear locally used variable. 325art_target_include_debug_build := 326 327include $(BUILD_PHONY_PACKAGE) 328 329include $(CLEAR_VARS) 330LOCAL_MODULE := com.android.art 331LOCAL_IS_HOST_MODULE := true 332ifneq ($(HOST_OS),darwin) 333 LOCAL_REQUIRED_MODULES += $(APEX_TEST_MODULE) 334endif 335include $(BUILD_PHONY_PACKAGE) 336 337# Create canonical name -> file name symlink in the symbol directory 338# The symbol files for the debug or release variant are installed to 339# $(TARGET_OUT_UNSTRIPPED)/$(TARGET_ART_APEX) directory. However, 340# since they are available via /apex/com.android.art at runtime 341# regardless of which variant is installed, create a symlink so that 342# $(TARGET_OUT_UNSTRIPPED)/apex/com.android.art is linked to 343# $(TARGET_OUT_UNSTRIPPED)/apex/$(TARGET_ART_APEX). 344# Note that installation of the symlink is triggered by the apex_manifest.pb 345# file which is the file that is guaranteed to be created regardless of the 346# value of TARGET_FLATTEN_APEX. 347ifeq ($(TARGET_FLATTEN_APEX),true) 348art_apex_manifest_file := $(PRODUCT_OUT)/system/apex/$(TARGET_ART_APEX)/apex_manifest.pb 349else 350art_apex_manifest_file := $(PRODUCT_OUT)/apex/$(TARGET_ART_APEX)/apex_manifest.pb 351endif 352 353art_apex_symlink_timestamp := $(call intermediates-dir-for,FAKE,com.android.art)/symlink.timestamp 354$(art_apex_manifest_file): $(art_apex_symlink_timestamp) 355$(art_apex_manifest_file): PRIVATE_LINK_NAME := $(TARGET_OUT_UNSTRIPPED)/apex/com.android.art 356$(art_apex_symlink_timestamp): 357 $(hide) mkdir -p $(dir $(PRIVATE_LINK_NAME)) 358 $(hide) ln -sf $(TARGET_ART_APEX) $(PRIVATE_LINK_NAME) 359 $(hide) touch $@ 360 361art_apex_manifest_file := 362 363####################### 364# Fake packages for ART 365 366# The art-runtime package depends on the core ART libraries and binaries. It exists so we can 367# manipulate the set of things shipped, e.g., add debug versions and so on. 368 369include $(CLEAR_VARS) 370LOCAL_MODULE := art-runtime 371 372# Base requirements. 373LOCAL_REQUIRED_MODULES := \ 374 dalvikvm.com.android.art.release \ 375 dex2oat.com.android.art.release \ 376 dexoptanalyzer.com.android.art.release \ 377 libart.com.android.art.release \ 378 libart-compiler.com.android.art.release \ 379 libopenjdkjvm.com.android.art.release \ 380 libopenjdkjvmti.com.android.art.release \ 381 profman.com.android.art.release \ 382 libadbconnection.com.android.art.release \ 383 libperfetto_hprof.com.android.art.release \ 384 385# Potentially add in debug variants: 386# 387# * We will never add them if PRODUCT_ART_TARGET_INCLUDE_DEBUG_BUILD = false. 388# * We will always add them if PRODUCT_ART_TARGET_INCLUDE_DEBUG_BUILD = true. 389# * Otherwise, we will add them by default to userdebug and eng builds. 390art_target_include_debug_build := $(PRODUCT_ART_TARGET_INCLUDE_DEBUG_BUILD) 391ifneq (false,$(art_target_include_debug_build)) 392ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT))) 393 art_target_include_debug_build := true 394endif 395ifeq (true,$(art_target_include_debug_build)) 396LOCAL_REQUIRED_MODULES += \ 397 dex2oatd.com.android.art.debug \ 398 dexoptanalyzerd.com.android.art.debug \ 399 libartd.com.android.art.debug \ 400 libartd-compiler.com.android.art.debug \ 401 libopenjdkd.com.android.art.debug \ 402 libopenjdkjvmd.com.android.art.debug \ 403 libopenjdkjvmtid.com.android.art.debug \ 404 profmand.com.android.art.debug \ 405 libadbconnectiond.com.android.art.debug \ 406 libperfetto_hprofd.com.android.art.debug \ 407 408endif 409endif 410 411include $(BUILD_PHONY_PACKAGE) 412 413# The art-tools package depends on helpers and tools that are useful for developers. Similar 414# dependencies exist for the APEX builds for these tools (see build/apex/Android.bp). 415 416include $(CLEAR_VARS) 417LOCAL_MODULE := art-tools 418LOCAL_IS_HOST_MODULE := true 419LOCAL_REQUIRED_MODULES := \ 420 ahat \ 421 dexdump \ 422 hprof-conv \ 423 424# A subset of the tools are disabled when HOST_PREFER_32_BIT is defined as make reports that 425# they are not supported on host (b/129323791). This is likely due to art_apex disabling host 426# APEX builds when HOST_PREFER_32_BIT is set (b/120617876). 427ifneq ($(HOST_PREFER_32_BIT),true) 428LOCAL_REQUIRED_MODULES += \ 429 dexdiag \ 430 dexlist \ 431 oatdump \ 432 433endif 434 435include $(BUILD_PHONY_PACKAGE) 436 437#################################################################################################### 438# Fake packages to ensure generation of libopenjdkd when one builds with mm/mmm/mmma. 439# 440# The library is required for starting a runtime in debug mode, but libartd does not depend on it 441# (dependency cycle otherwise). 442# 443# Note: * As the package is phony to create a dependency the package name is irrelevant. 444# * We make MULTILIB explicit to "both," just to state here that we want both libraries on 445# 64-bit systems, even if it is the default. 446 447# ART on the host. 448ifeq ($(ART_BUILD_HOST_DEBUG),true) 449include $(CLEAR_VARS) 450LOCAL_MODULE := art-libartd-libopenjdkd-host-dependency 451LOCAL_MULTILIB := both 452LOCAL_REQUIRED_MODULES := libopenjdkd 453LOCAL_IS_HOST_MODULE := true 454include $(BUILD_PHONY_PACKAGE) 455endif 456 457# ART on the target. 458ifeq ($(ART_BUILD_TARGET_DEBUG),true) 459include $(CLEAR_VARS) 460LOCAL_MODULE := art-libartd-libopenjdkd-target-dependency 461LOCAL_MULTILIB := both 462LOCAL_REQUIRED_MODULES := libopenjdkd 463include $(BUILD_PHONY_PACKAGE) 464endif 465 466######################################################################## 467# "m build-art" for quick minimal build 468.PHONY: build-art 469build-art: build-art-host build-art-target 470 471# For host, we extract the ICU data from the apex and install it to HOST_OUT/I18N_APEX. 472$(HOST_I18N_DATA): $(TARGET_OUT)/apex/$(I18N_APEX).apex $(HOST_OUT)/bin/deapexer 473 $(call extract-from-apex,$(I18N_APEX)) 474 rm -rf $(HOST_OUT)/$(I18N_APEX) 475 mkdir -p $(HOST_OUT)/$(I18N_APEX)/ 476 cp -R $(TARGET_OUT)/apex/$(I18N_APEX)/etc/ $(HOST_OUT)/$(I18N_APEX)/ 477 touch $@ 478 479.PHONY: build-art-host 480build-art-host: $(HOST_OUT_EXECUTABLES)/art $(ART_HOST_DEPENDENCIES) $(HOST_CORE_IMG_OUTS) $(HOST_I18N_DATA) 481 482.PHONY: build-art-target 483build-art-target: $(TARGET_OUT_EXECUTABLES)/art $(ART_TARGET_DEPENDENCIES) $(TARGET_CORE_IMG_OUTS) 484 485PRIVATE_ART_APEX_DEPENDENCY_FILES := \ 486 bin/dalvikvm32 \ 487 bin/dalvikvm64 \ 488 bin/dalvikvm \ 489 bin/dex2oat32 \ 490 bin/dex2oat64 \ 491 bin/dexdump \ 492 493PRIVATE_ART_APEX_DEPENDENCY_LIBS := \ 494 lib/libadbconnection.so \ 495 lib/libandroidio.so \ 496 lib/libartbase.so \ 497 lib/libart-compiler.so \ 498 lib/libart-dexlayout.so \ 499 lib/libart-disassembler.so \ 500 lib/libartpalette.so \ 501 lib/libart.so \ 502 lib/libbacktrace.so \ 503 lib/libdexfile_external.so \ 504 lib/libdexfile_support.so \ 505 lib/libdexfile.so \ 506 lib/libdt_fd_forward.so \ 507 lib/libdt_socket.so \ 508 lib/libexpat.so \ 509 lib/libjavacore.so \ 510 lib/libjdwp.so \ 511 lib/liblzma.so \ 512 lib/libmeminfo.so \ 513 lib/libnativebridge.so \ 514 lib/libnativehelper.so \ 515 lib/libnativeloader.so \ 516 lib/libnpt.so \ 517 lib/libopenjdkjvm.so \ 518 lib/libopenjdkjvmti.so \ 519 lib/libopenjdk.so \ 520 lib/libpac.so \ 521 lib/libprocinfo.so \ 522 lib/libprofile.so \ 523 lib/libsigchain.so \ 524 lib/libunwindstack.so \ 525 lib/libvixl.so \ 526 lib/libziparchive.so \ 527 lib64/libadbconnection.so \ 528 lib64/libandroidio.so \ 529 lib64/libartbase.so \ 530 lib64/libart-compiler.so \ 531 lib64/libart-dexlayout.so \ 532 lib64/libart-disassembler.so \ 533 lib64/libartpalette.so \ 534 lib64/libart.so \ 535 lib64/libbacktrace.so \ 536 lib64/libdexfile_external.so \ 537 lib64/libdexfile_support.so \ 538 lib64/libdexfile.so \ 539 lib64/libdt_fd_forward.so \ 540 lib64/libdt_socket.so \ 541 lib64/libexpat.so \ 542 lib64/libjavacore.so \ 543 lib64/libjdwp.so \ 544 lib64/liblzma.so \ 545 lib64/libmeminfo.so \ 546 lib64/libnativebridge.so \ 547 lib64/libnativehelper.so \ 548 lib64/libnativeloader.so \ 549 lib64/libnpt.so \ 550 lib64/libopenjdkjvm.so \ 551 lib64/libopenjdkjvmti.so \ 552 lib64/libopenjdk.so \ 553 lib64/libpac.so \ 554 lib64/libprocinfo.so \ 555 lib64/libprofile.so \ 556 lib64/libsigchain.so \ 557 lib64/libunwindstack.so \ 558 lib64/libvixl.so \ 559 lib64/libziparchive.so \ 560 561PRIVATE_RUNTIME_APEX_DEPENDENCY_FILES := \ 562 bin/linker \ 563 bin/linker64 \ 564 lib/bionic/libc.so \ 565 lib/bionic/libdl.so \ 566 lib/bionic/libdl_android.so \ 567 lib/bionic/libm.so \ 568 lib64/bionic/libc.so \ 569 lib64/bionic/libdl.so \ 570 lib64/bionic/libdl_android.so \ 571 lib64/bionic/libm.so \ 572 573PRIVATE_CONSCRYPT_APEX_DEPENDENCY_LIBS := \ 574 lib/libcrypto.so \ 575 lib/libjavacrypto.so \ 576 lib/libssl.so \ 577 lib64/libcrypto.so \ 578 lib64/libjavacrypto.so \ 579 lib64/libssl.so \ 580 581PRIVATE_I18N_APEX_DEPENDENCY_LIBS := \ 582 lib/libandroidicu.so \ 583 lib/libicui18n.so \ 584 lib/libicu_jni.so \ 585 lib/libicuuc.so \ 586 lib64/libandroidicu.so \ 587 lib64/libicui18n.so \ 588 lib64/libicu_jni.so \ 589 lib64/libicuuc.so \ 590 591# Extracts files from an APEX into a location. The APEX can be either a .apex 592# file in $(TARGET_OUT)/apex, or a directory in the same location. Files are 593# extracted to $(TARGET_OUT) with the same relative paths as under the APEX 594# root. 595# $(1): APEX base name 596# $(2): List of files to extract, with paths relative to the APEX root 597# 598# "cp -d" below doesn't work on Darwin, but this is only used for Golem builds 599# and won't run on mac anyway. 600define extract-from-apex 601 apex_root=$(TARGET_OUT)/apex && \ 602 apex_file=$$apex_root/$(1).apex && \ 603 apex_dir=$$apex_root/$(1) && \ 604 if [ -f $$apex_file ]; then \ 605 rm -rf $$apex_dir && \ 606 mkdir -p $$apex_dir && \ 607 debugfs=$(HOST_OUT)/bin/debugfs_static && \ 608 $(HOST_OUT)/bin/deapexer --debugfs_path $$debugfs extract $$apex_file $$apex_dir; \ 609 fi && \ 610 for f in $(2); do \ 611 sf=$$apex_dir/$$f && \ 612 df=$(TARGET_OUT)/$$f && \ 613 if [ -f $$sf -o -h $$sf ]; then \ 614 mkdir -p $$(dirname $$df) && \ 615 cp -fd $$sf $$df; \ 616 fi || exit 1; \ 617 done 618endef 619 620# Copy or extract some required files from APEXes to the `system` (TARGET_OUT) 621# directory. This is dangerous as these files could inadvertently stay in this 622# directory and be included in a system image. 623# 624# This target is only used by Golem now. 625# 626# NB Android build does not use cp from: 627# $ANDROID_BUILD_TOP/prebuilts/build-tools/path/{linux-x86,darwin-x86} 628# which has a non-standard set of command-line flags. 629# 630# TODO(b/129332183): Remove this when Golem has full support for the 631# ART APEX. 632.PHONY: standalone-apex-files 633standalone-apex-files: deapexer \ 634 $(RELEASE_ART_APEX) \ 635 $(RUNTIME_APEX) \ 636 $(CONSCRYPT_APEX) \ 637 $(I18N_APEX) 638 $(call extract-from-apex,$(RELEASE_ART_APEX),\ 639 $(PRIVATE_ART_APEX_DEPENDENCY_LIBS) $(PRIVATE_ART_APEX_DEPENDENCY_FILES)) 640 # The Runtime APEX has the Bionic libs in ${LIB}/bionic subdirectories, 641 # so we need to move them up a level after extraction. 642 $(call extract-from-apex,$(RUNTIME_APEX),\ 643 $(PRIVATE_RUNTIME_APEX_DEPENDENCY_FILES)) && \ 644 for libdir in $(TARGET_OUT)/lib $(TARGET_OUT)/lib64; do \ 645 if [ -d $$libdir/bionic ]; then \ 646 mv -f $$libdir/bionic/*.so $$libdir; \ 647 fi || exit 1; \ 648 done 649 $(call extract-from-apex,$(CONSCRYPT_APEX),\ 650 $(PRIVATE_CONSCRYPT_APEX_DEPENDENCY_LIBS)) 651 $(call extract-from-apex,$(I18N_APEX),\ 652 $(PRIVATE_I18N_APEX_DEPENDENCY_LIBS)) 653 654######################################################################## 655# Phony target for only building what go/lem requires for pushing ART on /data. 656 657.PHONY: build-art-target-golem 658# Also include libartbenchmark, we always include it when running golem. 659# libstdc++ is needed when building for ART_TARGET_LINUX. 660 661# Also include the Bionic libraries (libc, libdl, libdl_android, libm) and 662# linker. 663# 664# TODO(b/129332183): Remove this when Golem has full support for the 665# ART APEX. 666 667# Also include: 668# - a copy of the time zone data prebuilt files in 669# /system/etc/tzdata_module/etc/tz and /system/etc/tzdata_module/etc/icu 670# on target, (see modules `tzdata-art-test-tzdata`, 671# `tzlookup.xml-art-test-tzdata`, and `tz_version-art-test-tzdata`, and 672# `icu_overlay-art-test-tzdata`) 673# so that they can be found even if the Time Zone Data APEX is not available, 674# by setting the environment variable `ART_TEST_ANDROID_TZDATA_ROOT` 675# to "/system/etc/tzdata_module" on device. This is a temporary change needed 676# until Golem fully supports the Time Zone Data APEX. 677# 678# TODO(b/129332183): Remove this when Golem has full support for the 679# ART APEX (and TZ Data APEX). 680 681ART_TARGET_SHARED_LIBRARY_BENCHMARK := $(TARGET_OUT_SHARED_LIBRARIES)/libartbenchmark.so 682build-art-target-golem: $(RELEASE_ART_APEX) com.android.runtime $(CONSCRYPT_APEX) \ 683 $(TARGET_OUT_EXECUTABLES)/art \ 684 $(TARGET_OUT_EXECUTABLES)/dex2oat_wrapper \ 685 $(TARGET_OUT)/etc/public.libraries.txt \ 686 $(ART_TARGET_SHARED_LIBRARY_BENCHMARK) \ 687 $(TARGET_OUT_SHARED_LIBRARIES)/libz.so \ 688 libartpalette-system \ 689 tzdata-art-test-tzdata tzlookup.xml-art-test-tzdata \ 690 tz_version-art-test-tzdata icu_overlay-art-test-tzdata \ 691 standalone-apex-files 692 # remove debug libraries from public.libraries.txt because golem builds 693 # won't have it. 694 sed -i '/libartd.so/d' $(TARGET_OUT)/etc/public.libraries.txt 695 sed -i '/libdexfiled.so/d' $(TARGET_OUT)/etc/public.libraries.txt 696 sed -i '/libprofiled.so/d' $(TARGET_OUT)/etc/public.libraries.txt 697 sed -i '/libartbased.so/d' $(TARGET_OUT)/etc/public.libraries.txt 698 # The 'art' script will look for a 'com.android.art' directory. 699 ln -sf com.android.art.release $(TARGET_OUT)/apex/com.android.art 700 701######################################################################## 702# Phony target for building what go/lem requires on host. 703.PHONY: build-art-host-golem 704# Also include libartbenchmark, we always include it when running golem. 705ART_HOST_SHARED_LIBRARY_BENCHMARK := $(ART_HOST_OUT_SHARED_LIBRARIES)/libartbenchmark.so 706build-art-host-golem: build-art-host \ 707 $(ART_HOST_SHARED_LIBRARY_BENCHMARK) \ 708 $(HOST_OUT_EXECUTABLES)/dex2oat_wrapper 709 710######################################################################## 711# Phony target for building what go/lem requires for syncing /system to target. 712.PHONY: build-art-unbundled-golem 713art_apex_jars := $(foreach pair,$(ART_APEX_JARS), $(call word-colon,2,$(pair))) 714build-art-unbundled-golem: art-runtime linker oatdump $(art_apex_jars) conscrypt crash_dump 715 716######################################################################## 717# Rules for building all dependencies for tests. 718 719.PHONY: build-art-host-tests 720build-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) 721 722.PHONY: build-art-target-tests 723build-art-target-tests: build-art-target $(TEST_ART_RUN_TEST_DEPENDENCIES) $(ART_TEST_TARGET_RUN_TEST_DEPENDENCIES) $(ART_TEST_TARGET_GTEST_DEPENDENCIES) | $(TEST_ART_RUN_TEST_ORDERONLY_DEPENDENCIES) 724 725######################################################################## 726# targets to switch back and forth from libdvm to libart 727 728.PHONY: use-art 729use-art: 730 $(ADB) root 731 $(ADB) wait-for-device shell stop 732 $(ADB) shell setprop persist.sys.dalvik.vm.lib.2 libart.so 733 $(ADB) shell start 734 735.PHONY: use-artd 736use-artd: 737 $(ADB) root 738 $(ADB) wait-for-device shell stop 739 $(ADB) shell setprop persist.sys.dalvik.vm.lib.2 libartd.so 740 $(ADB) shell start 741 742.PHONY: use-dalvik 743use-dalvik: 744 $(ADB) root 745 $(ADB) wait-for-device shell stop 746 $(ADB) shell setprop persist.sys.dalvik.vm.lib.2 libdvm.so 747 $(ADB) shell start 748 749.PHONY: use-art-full 750use-art-full: 751 $(ADB) root 752 $(ADB) wait-for-device shell stop 753 $(ADB) shell rm -rf $(ART_TARGET_DALVIK_CACHE_DIR)/* 754 $(ADB) shell setprop dalvik.vm.dex2oat-filter \"\" 755 $(ADB) shell setprop dalvik.vm.image-dex2oat-filter \"\" 756 $(ADB) shell setprop persist.sys.dalvik.vm.lib.2 libart.so 757 $(ADB) shell setprop dalvik.vm.usejit false 758 $(ADB) shell start 759 760.PHONY: use-artd-full 761use-artd-full: 762 $(ADB) root 763 $(ADB) wait-for-device shell stop 764 $(ADB) shell rm -rf $(ART_TARGET_DALVIK_CACHE_DIR)/* 765 $(ADB) shell setprop dalvik.vm.dex2oat-filter \"\" 766 $(ADB) shell setprop dalvik.vm.image-dex2oat-filter \"\" 767 $(ADB) shell setprop persist.sys.dalvik.vm.lib.2 libartd.so 768 $(ADB) shell setprop dalvik.vm.usejit false 769 $(ADB) shell start 770 771.PHONY: use-art-jit 772use-art-jit: 773 $(ADB) root 774 $(ADB) wait-for-device shell stop 775 $(ADB) shell rm -rf $(ART_TARGET_DALVIK_CACHE_DIR)/* 776 $(ADB) shell setprop dalvik.vm.dex2oat-filter "verify-at-runtime" 777 $(ADB) shell setprop dalvik.vm.image-dex2oat-filter "verify-at-runtime" 778 $(ADB) shell setprop persist.sys.dalvik.vm.lib.2 libart.so 779 $(ADB) shell setprop dalvik.vm.usejit true 780 $(ADB) shell start 781 782.PHONY: use-art-interpret-only 783use-art-interpret-only: 784 $(ADB) root 785 $(ADB) wait-for-device shell stop 786 $(ADB) shell rm -rf $(ART_TARGET_DALVIK_CACHE_DIR)/* 787 $(ADB) shell setprop dalvik.vm.dex2oat-filter "interpret-only" 788 $(ADB) shell setprop dalvik.vm.image-dex2oat-filter "interpret-only" 789 $(ADB) shell setprop persist.sys.dalvik.vm.lib.2 libart.so 790 $(ADB) shell setprop dalvik.vm.usejit false 791 $(ADB) shell start 792 793.PHONY: use-artd-interpret-only 794use-artd-interpret-only: 795 $(ADB) root 796 $(ADB) wait-for-device shell stop 797 $(ADB) shell rm -rf $(ART_TARGET_DALVIK_CACHE_DIR)/* 798 $(ADB) shell setprop dalvik.vm.dex2oat-filter "interpret-only" 799 $(ADB) shell setprop dalvik.vm.image-dex2oat-filter "interpret-only" 800 $(ADB) shell setprop persist.sys.dalvik.vm.lib.2 libartd.so 801 $(ADB) shell setprop dalvik.vm.usejit false 802 $(ADB) shell start 803 804.PHONY: use-art-verify-none 805use-art-verify-none: 806 $(ADB) root 807 $(ADB) wait-for-device shell stop 808 $(ADB) shell rm -rf $(ART_TARGET_DALVIK_CACHE_DIR)/* 809 $(ADB) shell setprop dalvik.vm.dex2oat-filter "verify-none" 810 $(ADB) shell setprop dalvik.vm.image-dex2oat-filter "verify-none" 811 $(ADB) shell setprop persist.sys.dalvik.vm.lib.2 libart.so 812 $(ADB) shell setprop dalvik.vm.usejit false 813 $(ADB) shell start 814 815######################################################################## 816 817# Clear locally used variables. 818TEST_ART_TARGET_SYNC_DEPS := 819 820# Helper target that depends on boot image creation. 821# 822# Can be used, for example, to dump initialization failures: 823# m art-boot-image ART_BOOT_IMAGE_EXTRA_ARGS=--dump-init-failures=fails.txt 824.PHONY: art-boot-image 825art-boot-image: $(DEXPREOPT_IMAGE_boot_$(TARGET_ARCH)) 826 827.PHONY: art-job-images 828art-job-images: \ 829 art-boot-image \ 830 $(2ND_DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME) \ 831 $(HOST_OUT_EXECUTABLES)/dex2oats \ 832 $(HOST_OUT_EXECUTABLES)/dex2oatds \ 833 $(HOST_OUT_EXECUTABLES)/profman 834