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 17######################################################################## 18# Rules to build a smaller "core" image to support core libraries 19# (that is, non-Android frameworks) testing on the host and target 20# 21# The main rules to build the default "boot" image are in 22# build/core/dex_preopt_libart.mk 23 24include art/build/Android.common_build.mk 25 26LOCAL_DEX2OAT_HOST_INSTRUCTION_SET_FEATURES_OPTION := 27ifeq ($(DEX2OAT_HOST_INSTRUCTION_SET_FEATURES),) 28 LOCAL_DEX2OAT_HOST_INSTRUCTION_SET_FEATURES_OPTION := --instruction-set-features=default 29else 30 LOCAL_DEX2OAT_HOST_INSTRUCTION_SET_FEATURES_OPTION := --instruction-set-features=$(DEX2OAT_HOST_INSTRUCTION_SET_FEATURES) 31endif 32LOCAL_$(HOST_2ND_ARCH_VAR_PREFIX)DEX2OAT_HOST_INSTRUCTION_SET_FEATURES_OPTION := 33ifeq ($($(HOST_2ND_ARCH_VAR_PREFIX)DEX2OAT_HOST_INSTRUCTION_SET_FEATURES),) 34 LOCAL_$(HOST_2ND_ARCH_VAR_PREFIX)DEX2OAT_HOST_INSTRUCTION_SET_FEATURES_OPTION := --instruction-set-features=default 35else 36 LOCAL_$(HOST_2ND_ARCH_VAR_PREFIX)DEX2OAT_HOST_INSTRUCTION_SET_FEATURES_OPTION := --instruction-set-features=$($(HOST_2ND_ARCH_VAR_PREFIX)DEX2OAT_HOST_INSTRUCTION_SET_FEATURES) 37endif 38 39# Use dex2oat debug version for better error reporting 40# $(1): compiler - optimizing, interpreter or interp-ac (interpreter-access-checks). 41# $(2): 2ND_ or undefined, 2ND_ for 32-bit host builds. 42define create-core-oat-host-rules 43 core_compile_options := 44 core_image_name := 45 core_oat_name := 46 core_infix := 47 core_dex2oat_dependency := $(DEX2OAT) 48 49 ifeq ($(1),optimizing) 50 core_compile_options += --compiler-backend=Optimizing 51 endif 52 ifeq ($(1),interpreter) 53 core_compile_options += --compiler-filter=quicken 54 core_infix := -interpreter 55 endif 56 ifeq ($(1),interp-ac) 57 core_compile_options += --compiler-filter=extract --runtime-arg -Xverify:softfail 58 core_infix := -interp-ac 59 endif 60 ifneq ($(filter-out interpreter interp-ac optimizing,$(1)),) 61 #Technically this test is not precise, but hopefully good enough. 62 $$(error found $(1) expected interpreter, interp-ac, or optimizing) 63 endif 64 65 core_image_location := $(HOST_OUT_JAVA_LIBRARIES)/core$$(core_infix)$(CORE_IMG_SUFFIX) 66 core_image_name := $($(2)HOST_CORE_IMG_OUT_BASE)$$(core_infix)$(CORE_IMG_SUFFIX) 67 core_oat_name := $($(2)HOST_CORE_OAT_OUT_BASE)$$(core_infix)$(CORE_OAT_SUFFIX) 68 69 # Using the bitness suffix makes it easier to add as a dependency for the run-test mk. 70 ifeq ($(2),) 71 HOST_CORE_IMAGE_$(1)_64 := $$(core_image_name) 72 else 73 HOST_CORE_IMAGE_$(1)_32 := $$(core_image_name) 74 endif 75 HOST_CORE_IMG_OUTS += $$(core_image_name) 76 HOST_CORE_OAT_OUTS += $$(core_oat_name) 77 78$$(core_image_name): PRIVATE_CORE_COMPILE_OPTIONS := $$(core_compile_options) 79$$(core_image_name): PRIVATE_CORE_IMAGE_LOCATION := $$(core_image_location) 80$$(core_image_name): PRIVATE_CORE_IMG_NAME := $$(core_image_name) 81$$(core_image_name): PRIVATE_CORE_OAT_NAME := $$(core_oat_name) 82# In addition to the primary core image containing HOST_CORE_IMG_DEX_FILES, 83# also build a boot image extension for the remaining HOST_CORE_DEX_FILES. 84$$(core_image_name): $$(HOST_CORE_DEX_LOCATIONS) $$(core_dex2oat_dependency) 85 @echo "host dex2oat: $$@" 86 @mkdir -p $$(dir $$@) 87 $$(hide) ANDROID_LOG_TAGS="*:e" $$(DEX2OAT) \ 88 --runtime-arg -Xms$(DEX2OAT_IMAGE_XMS) \ 89 --runtime-arg -Xmx$(DEX2OAT_IMAGE_XMX) \ 90 $$(addprefix --dex-file=,$$(HOST_CORE_IMG_DEX_FILES)) \ 91 $$(addprefix --dex-location=,$$(HOST_CORE_IMG_DEX_LOCATIONS)) \ 92 --oat-file=$$(PRIVATE_CORE_OAT_NAME) \ 93 --oat-location=$$(PRIVATE_CORE_OAT_NAME) \ 94 --image=$$(PRIVATE_CORE_IMG_NAME) \ 95 --base=$$(LIBART_IMG_HOST_BASE_ADDRESS) \ 96 --instruction-set=$$($(2)ART_HOST_ARCH) \ 97 $$(LOCAL_$(2)DEX2OAT_HOST_INSTRUCTION_SET_FEATURES_OPTION) \ 98 --host --android-root=$$(HOST_OUT) \ 99 --generate-debug-info --generate-build-id \ 100 --runtime-arg -XX:SlowDebug=true \ 101 --no-inline-from=core-oj-hostdex.jar \ 102 $$(PRIVATE_CORE_COMPILE_OPTIONS) && \ 103 ANDROID_LOG_TAGS="*:e" $$(DEX2OAT) \ 104 --runtime-arg -Xms$(DEX2OAT_IMAGE_XMS) \ 105 --runtime-arg -Xmx$(DEX2OAT_IMAGE_XMX) \ 106 --runtime-arg -Xbootclasspath:$$(subst $$(space),:,$$(strip \ 107 $$(HOST_CORE_DEX_FILES))) \ 108 --runtime-arg -Xbootclasspath-locations:$$(subst $$(space),:,$$(strip \ 109 $$(HOST_CORE_DEX_LOCATIONS))) \ 110 $$(addprefix --dex-file=, \ 111 $$(filter-out $$(HOST_CORE_IMG_DEX_FILES),$$(HOST_CORE_DEX_FILES))) \ 112 $$(addprefix --dex-location=, \ 113 $$(filter-out $$(HOST_CORE_IMG_DEX_LOCATIONS),$$(HOST_CORE_DEX_LOCATIONS))) \ 114 --oat-file=$$(PRIVATE_CORE_OAT_NAME) \ 115 --oat-location=$$(PRIVATE_CORE_OAT_NAME) \ 116 --boot-image=$$(PRIVATE_CORE_IMAGE_LOCATION) \ 117 --image=$$(PRIVATE_CORE_IMG_NAME) \ 118 --instruction-set=$$($(2)ART_HOST_ARCH) \ 119 $$(LOCAL_$(2)DEX2OAT_HOST_INSTRUCTION_SET_FEATURES_OPTION) \ 120 --host --android-root=$$(HOST_OUT) \ 121 --generate-debug-info --generate-build-id \ 122 --runtime-arg -XX:SlowDebug=true \ 123 --no-inline-from=core-oj-hostdex.jar \ 124 $$(PRIVATE_CORE_COMPILE_OPTIONS) 125 126$$(core_oat_name): $$(core_image_name) 127 128 # Clean up locally used variables. 129 core_dex2oat_dependency := 130 core_compile_options := 131 core_image_name := 132 core_oat_name := 133 core_infix := 134endef # create-core-oat-host-rules 135 136# $(1): compiler - optimizing, interpreter or interp-ac (interpreter-access-checks). 137define create-core-oat-host-rule-combination 138 $(call create-core-oat-host-rules,$(1),) 139 140 ifneq ($(HOST_PREFER_32_BIT),true) 141 $(call create-core-oat-host-rules,$(1),2ND_) 142 endif 143endef 144 145$(eval $(call create-core-oat-host-rule-combination,optimizing)) 146$(eval $(call create-core-oat-host-rule-combination,interpreter)) 147$(eval $(call create-core-oat-host-rule-combination,interp-ac)) 148 149.PHONY: test-art-host-dex2oat-host 150test-art-host-dex2oat-host: $(HOST_CORE_IMG_OUTS) 151 152# $(1): compiler - optimizing, interpreter or interp-ac (interpreter-access-checks). 153# $(2): 2ND_ or undefined 154define create-core-oat-target-rules 155 core_compile_options := 156 core_image_name := 157 core_oat_name := 158 core_infix := 159 core_dex2oat_dependency := $(DEX2OAT) 160 161 ifeq ($(1),optimizing) 162 core_compile_options += --compiler-backend=Optimizing 163 endif 164 ifeq ($(1),interpreter) 165 core_compile_options += --compiler-filter=quicken 166 core_infix := -interpreter 167 endif 168 ifeq ($(1),interp-ac) 169 core_compile_options += --compiler-filter=extract --runtime-arg -Xverify:softfail 170 core_infix := -interp-ac 171 endif 172 ifneq ($(filter-out interpreter interp-ac optimizing,$(1)),) 173 # Technically this test is not precise, but hopefully good enough. 174 $$(error found $(1) expected interpreter, interp-ac, or optimizing) 175 endif 176 177 core_image_location := $(ART_TARGET_TEST_OUT)/core$$(core_infix)$(CORE_IMG_SUFFIX) 178 core_image_name := $($(2)TARGET_CORE_IMG_OUT_BASE)$$(core_infix)$(CORE_IMG_SUFFIX) 179 core_oat_name := $($(2)TARGET_CORE_OAT_OUT_BASE)$$(core_infix)$(CORE_OAT_SUFFIX) 180 181 # Using the bitness suffix makes it easier to add as a dependency for the run-test mk. 182 ifeq ($(2),) 183 ifdef TARGET_2ND_ARCH 184 TARGET_CORE_IMAGE_$(1)_64 := $$(core_image_name) 185 else 186 TARGET_CORE_IMAGE_$(1)_32 := $$(core_image_name) 187 endif 188 else 189 TARGET_CORE_IMAGE_$(1)_32 := $$(core_image_name) 190 endif 191 TARGET_CORE_IMG_OUTS += $$(core_image_name) 192 TARGET_CORE_OAT_OUTS += $$(core_oat_name) 193 194$$(core_image_name): PRIVATE_CORE_COMPILE_OPTIONS := $$(core_compile_options) 195$$(core_image_name): PRIVATE_CORE_IMAGE_LOCATION := $$(core_image_location) 196$$(core_image_name): PRIVATE_CORE_IMG_NAME := $$(core_image_name) 197$$(core_image_name): PRIVATE_CORE_OAT_NAME := $$(core_oat_name) 198# In addition to the primary core image containing TARGET_CORE_IMG_DEX_FILES, 199# also build a boot image extension for the remaining TARGET_CORE_DEX_FILES. 200$$(core_image_name): $$(TARGET_CORE_DEX_FILES) $$(core_dex2oat_dependency) 201 @echo "target dex2oat: $$@" 202 @mkdir -p $$(dir $$@) 203 $$(hide) $$(DEX2OAT) \ 204 --runtime-arg -Xms$(DEX2OAT_IMAGE_XMS) \ 205 --runtime-arg -Xmx$(DEX2OAT_IMAGE_XMX) \ 206 $$(addprefix --dex-file=,$$(TARGET_CORE_IMG_DEX_FILES)) \ 207 $$(addprefix --dex-location=,$$(TARGET_CORE_IMG_DEX_LOCATIONS)) \ 208 --oat-file=$$(PRIVATE_CORE_OAT_NAME) \ 209 --oat-location=$$(PRIVATE_CORE_OAT_NAME) \ 210 --image=$$(PRIVATE_CORE_IMG_NAME) \ 211 --base=$$(LIBART_IMG_TARGET_BASE_ADDRESS) \ 212 --instruction-set=$$($(2)TARGET_ARCH) \ 213 --instruction-set-variant=$$($(2)DEX2OAT_TARGET_CPU_VARIANT) \ 214 --instruction-set-features=$$($(2)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES) \ 215 --android-root=$$(PRODUCT_OUT)/system \ 216 --generate-debug-info --generate-build-id \ 217 --runtime-arg -XX:SlowDebug=true \ 218 $$(PRIVATE_CORE_COMPILE_OPTIONS) && \ 219 $$(DEX2OAT) \ 220 --runtime-arg -Xms$(DEX2OAT_IMAGE_XMS) \ 221 --runtime-arg -Xmx$(DEX2OAT_IMAGE_XMX) \ 222 --runtime-arg -Xbootclasspath:$$(subst $$(space),:,$$(strip \ 223 $$(TARGET_CORE_DEX_FILES))) \ 224 --runtime-arg -Xbootclasspath-locations:$$(subst $$(space),:,$$(strip \ 225 $$(TARGET_CORE_DEX_LOCATIONS))) \ 226 $$(addprefix --dex-file=, \ 227 $$(filter-out $$(TARGET_CORE_IMG_DEX_FILES),$$(TARGET_CORE_DEX_FILES))) \ 228 $$(addprefix --dex-location=, \ 229 $$(filter-out $$(TARGET_CORE_IMG_DEX_LOCATIONS),$$(TARGET_CORE_DEX_LOCATIONS))) \ 230 --oat-file=$$(PRIVATE_CORE_OAT_NAME) \ 231 --oat-location=$$(PRIVATE_CORE_OAT_NAME) \ 232 --boot-image=$$(PRIVATE_CORE_IMAGE_LOCATION) \ 233 --image=$$(PRIVATE_CORE_IMG_NAME) \ 234 --instruction-set=$$($(2)TARGET_ARCH) \ 235 --instruction-set-variant=$$($(2)DEX2OAT_TARGET_CPU_VARIANT) \ 236 --instruction-set-features=$$($(2)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES) \ 237 --android-root=$$(PRODUCT_OUT)/system \ 238 --generate-debug-info --generate-build-id \ 239 --runtime-arg -XX:SlowDebug=true \ 240 $$(PRIVATE_CORE_COMPILE_OPTIONS) || \ 241 (rm $$(PRIVATE_CORE_OAT_NAME); exit 1) 242 243$$(core_oat_name): $$(core_image_name) 244 245 # Clean up locally used variables. 246 core_dex2oat_dependency := 247 core_compile_options := 248 core_image_name := 249 core_oat_name := 250 core_infix := 251endef # create-core-oat-target-rules 252 253# $(1): compiler - optimizing, interpreter or interp-ac (interpreter-access-checks). 254define create-core-oat-target-rule-combination 255 $(call create-core-oat-target-rules,$(1),) 256 257 ifdef TARGET_2ND_ARCH 258 $(call create-core-oat-target-rules,$(1),2ND_) 259 endif 260endef 261 262$(eval $(call create-core-oat-target-rule-combination,optimizing)) 263$(eval $(call create-core-oat-target-rule-combination,interpreter)) 264$(eval $(call create-core-oat-target-rule-combination,interp-ac)) 265 266# Define a default core image that can be used for things like gtests that 267# need some image to run, but don't otherwise care which image is used. 268HOST_CORE_IMAGE_DEFAULT_32 := $(HOST_CORE_IMAGE_optimizing_32) 269HOST_CORE_IMAGE_DEFAULT_64 := $(HOST_CORE_IMAGE_optimizing_64) 270TARGET_CORE_IMAGE_DEFAULT_32 := $(TARGET_CORE_IMAGE_optimizing_32) 271TARGET_CORE_IMAGE_DEFAULT_64 := $(TARGET_CORE_IMAGE_optimizing_64) 272