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