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_path.mk
25
26# Use dex2oat debug version for better error reporting
27# $(1): 2ND_ or undefined, 2ND_ for 32-bit host builds.
28define create-core-oat-host-rules
29$$($(1)HOST_CORE_IMG_OUT): $$(HOST_CORE_DEX_FILES) $$(DEX2OATD_DEPENDENCY)
30	@echo "host dex2oat: $$@ ($$?)"
31	@mkdir -p $$(dir $$@)
32	$$(hide) $$(DEX2OATD) --runtime-arg -Xms$(DEX2OAT_IMAGE_XMS) --runtime-arg -Xmx$(DEX2OAT_IMAGE_XMX) \
33	  --image-classes=$$(PRELOADED_CLASSES) $$(addprefix --dex-file=,$$(HOST_CORE_DEX_FILES)) \
34	  $$(addprefix --dex-location=,$$(HOST_CORE_DEX_LOCATIONS)) --oat-file=$$($(1)HOST_CORE_OAT_OUT) \
35	  --oat-location=$$($(1)HOST_CORE_OAT) --image=$$($(1)HOST_CORE_IMG_OUT) \
36	  --base=$$(LIBART_IMG_HOST_BASE_ADDRESS) --instruction-set=$$($(1)ART_HOST_ARCH) \
37	  --instruction-set-features=$$($(1)HOST_INSTRUCTION_SET_FEATURES) \
38	  --host --android-root=$$(HOST_OUT) --include-patch-information
39
40# This "renaming" eases declaration in art/Android.mk
41HOST_CORE_IMG_OUT$($(1)ART_PHONY_TEST_HOST_SUFFIX) := $($(1)HOST_CORE_IMG_OUT)
42
43$$($(1)HOST_CORE_OAT_OUT): $$($(1)HOST_CORE_IMG_OUT)
44endef  # create-core-oat-host-rules
45
46$(eval $(call create-core-oat-host-rules,))
47ifneq ($(HOST_PREFER_32_BIT),true)
48$(eval $(call create-core-oat-host-rules,2ND_))
49endif
50
51define create-core-oat-target-rules
52$$($(1)TARGET_CORE_IMG_OUT): $$($(1)TARGET_CORE_DEX_FILES) $$(DEX2OATD_DEPENDENCY)
53	@echo "target dex2oat: $$@ ($$?)"
54	@mkdir -p $$(dir $$@)
55	$$(hide) $$(DEX2OATD) --runtime-arg -Xms$(DEX2OAT_XMS) --runtime-arg -Xmx$(DEX2OAT_XMX) \
56	  --image-classes=$$(PRELOADED_CLASSES) $$(addprefix --dex-file=,$$(TARGET_CORE_DEX_FILES)) \
57	  $$(addprefix --dex-location=,$$(TARGET_CORE_DEX_LOCATIONS)) --oat-file=$$($(1)TARGET_CORE_OAT_OUT) \
58	  --oat-location=$$($(1)TARGET_CORE_OAT) --image=$$($(1)TARGET_CORE_IMG_OUT) \
59	  --base=$$(LIBART_IMG_TARGET_BASE_ADDRESS) --instruction-set=$$($(1)TARGET_ARCH) \
60	  --instruction-set-features=$$($(1)TARGET_INSTRUCTION_SET_FEATURES) \
61	  --android-root=$$(PRODUCT_OUT)/system --include-patch-information
62
63# This "renaming" eases declaration in art/Android.mk
64TARGET_CORE_IMG_OUT$($(1)ART_PHONY_TEST_TARGET_SUFFIX) := $($(1)TARGET_CORE_IMG_OUT)
65
66$$($(1)TARGET_CORE_OAT_OUT): $$($(1)TARGET_CORE_IMG_OUT)
67endef  # create-core-oat-target-rules
68
69ifdef TARGET_2ND_ARCH
70$(eval $(call create-core-oat-target-rules,2ND_))
71endif
72$(eval $(call create-core-oat-target-rules,))
73
74
75ifeq ($(ART_BUILD_HOST),true)
76include $(CLEAR_VARS)
77LOCAL_MODULE := core.art-host
78LOCAL_MODULE_TAGS := optional
79LOCAL_ADDITIONAL_DEPENDENCIES := art/build/Android.common.mk
80LOCAL_ADDITIONAL_DEPENDENCIES += art/build/Android.oat.mk
81LOCAL_ADDITIONAL_DEPENDENCIES += $(HOST_CORE_IMG_OUT)
82include $(BUILD_PHONY_PACKAGE)
83endif # ART_BUILD_HOST
84
85# If we aren't building the host toolchain, skip building the target core.art.
86ifeq ($(ART_BUILD_TARGET),true)
87include $(CLEAR_VARS)
88LOCAL_MODULE := core.art
89LOCAL_MODULE_TAGS := optional
90LOCAL_ADDITIONAL_DEPENDENCIES := art/build/Android.common.mk
91LOCAL_ADDITIONAL_DEPENDENCIES += art/build/Android.oat.mk
92LOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_CORE_IMG_OUT)
93include $(BUILD_PHONY_PACKAGE)
94endif # ART_BUILD_TARGET
95