blob: 80a000bf15e640eea73c67f0f1769c5567119052 [file] [log] [blame]
Brian Carlstrom16192862011-09-12 17:50:06 -07001#
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
Brian Carlstrom27ec9612011-09-19 20:20:38 -070017########################################################################
Brian Carlstrom7ab763c2013-12-09 00:38:02 -080018# 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
Brian Carlstrom16192862011-09-12 17:50:06 -070023
Nicolas Geoffray611e1db2014-10-09 17:34:45 +010024include art/build/Android.common_build.mk
Dave Allison70202782013-10-22 17:52:19 -070025
Nicolas Geoffray1db132d2014-03-26 10:56:24 +000026# Use dex2oat debug version for better error reporting
Andreas Gampec23c9c92014-10-28 14:47:25 -070027# $(1): compiler - default, optimizing or interpreter.
28# $(2): pic/no-pic
29# $(3): 2ND_ or undefined, 2ND_ for 32-bit host builds.
Alex Light1ef4ce82014-08-27 11:13:47 -070030# NB depending on HOST_CORE_DEX_LOCATIONS so we are sure to have the dex files in frameworks for
31# run-test --no-image
Ian Rogersafd9acc2014-06-17 08:21:54 -070032define create-core-oat-host-rules
Andreas Gampe63fc30e2014-10-24 21:58:16 -070033 core_compile_options :=
34 core_image_name :=
35 core_oat_name :=
36 core_infix :=
Andreas Gampec23c9c92014-10-28 14:47:25 -070037 core_pic_infix :=
Andreas Gampe63fc30e2014-10-24 21:58:16 -070038
39 ifeq ($(1),optimizing)
40 core_compile_options += --compiler-backend=optimizing
41 core_infix := -optimizing
42 endif
43 ifeq ($(1),interpreter)
44 core_compile_options += --compiler-filter=interpret-only
45 core_infix := -interpreter
46 endif
47 ifeq ($(1),default)
48 # Default has no infix, no compile options.
49 endif
50 ifneq ($(filter-out default interpreter optimizing,$(1)),)
51 #Technically this test is not precise, but hopefully good enough.
52 $$(error found $(1) expected default, interpreter or optimizing)
53 endif
Andreas Gampec23c9c92014-10-28 14:47:25 -070054
55 ifeq ($(2),pic)
56 core_compile_options += --compile-pic
57 core_pic_infix := -pic
58 endif
59 ifeq ($(2),no-pic)
60 # No change for non-pic
61 endif
62 ifneq ($(filter-out pic no-pic,$(2)),)
63 # Technically this test is not precise, but hopefully good enough.
64 $$(error found $(2) expected pic or no-pic)
65 endif
66
67 core_image_name := $($(3)HOST_CORE_IMG_OUT_BASE)$$(core_infix)$$(core_pic_infix)$(CORE_IMG_SUFFIX)
68 core_oat_name := $($(3)HOST_CORE_OAT_OUT_BASE)$$(core_infix)$$(core_pic_infix)$(CORE_OAT_SUFFIX)
Andreas Gampe63fc30e2014-10-24 21:58:16 -070069
70 # Using the bitness suffix makes it easier to add as a dependency for the run-test mk.
Andreas Gampec23c9c92014-10-28 14:47:25 -070071 ifeq ($(3),)
72 HOST_CORE_IMAGE_$(1)_$(2)_64 := $$(core_image_name)
Andreas Gampe63fc30e2014-10-24 21:58:16 -070073 else
Andreas Gampec23c9c92014-10-28 14:47:25 -070074 HOST_CORE_IMAGE_$(1)_$(2)_32 := $$(core_image_name)
Andreas Gampe63fc30e2014-10-24 21:58:16 -070075 endif
76 HOST_CORE_IMG_OUTS += $$(core_image_name)
77 HOST_CORE_OAT_OUTS += $$(core_oat_name)
78
79$$(core_image_name): PRIVATE_CORE_COMPILE_OPTIONS := $$(core_compile_options)
80$$(core_image_name): PRIVATE_CORE_IMG_NAME := $$(core_image_name)
81$$(core_image_name): PRIVATE_CORE_OAT_NAME := $$(core_oat_name)
82$$(core_image_name): $$(HOST_CORE_DEX_LOCATIONS) $$(DEX2OAT_DEPENDENCY)
Ian Rogersafd9acc2014-06-17 08:21:54 -070083 @echo "host dex2oat: $$@ ($$?)"
84 @mkdir -p $$(dir $$@)
Andreas Gampe63fc30e2014-10-24 21:58:16 -070085 $$(hide) $$(DEX2OAT) --runtime-arg -Xms$(DEX2OAT_IMAGE_XMS) --runtime-arg -Xmx$(DEX2OAT_IMAGE_XMX) \
Ian Rogersafd9acc2014-06-17 08:21:54 -070086 --image-classes=$$(PRELOADED_CLASSES) $$(addprefix --dex-file=,$$(HOST_CORE_DEX_FILES)) \
Andreas Gampe63fc30e2014-10-24 21:58:16 -070087 $$(addprefix --dex-location=,$$(HOST_CORE_DEX_LOCATIONS)) --oat-file=$$(PRIVATE_CORE_OAT_NAME) \
88 --oat-location=$$(PRIVATE_CORE_OAT_NAME) --image=$$(PRIVATE_CORE_IMG_NAME) \
Andreas Gampec23c9c92014-10-28 14:47:25 -070089 --base=$$(LIBART_IMG_HOST_BASE_ADDRESS) --instruction-set=$$($(3)ART_HOST_ARCH) \
90 --instruction-set-features=$$($(3)HOST_INSTRUCTION_SET_FEATURES) \
Andreas Gampe63fc30e2014-10-24 21:58:16 -070091 --host --android-root=$$(HOST_OUT) --include-patch-information \
92 $$(PRIVATE_CORE_COMPILE_OPTIONS)
Brian Carlstrom27ec9612011-09-19 20:20:38 -070093
Andreas Gampe63fc30e2014-10-24 21:58:16 -070094$$(core_oat_name): $$(core_image_name)
Ian Rogersafd9acc2014-06-17 08:21:54 -070095
Andreas Gampe63fc30e2014-10-24 21:58:16 -070096 # Clean up locally used variables.
97 core_compile_options :=
98 core_image_name :=
99 core_oat_name :=
100 core_infix :=
Andreas Gampec23c9c92014-10-28 14:47:25 -0700101 core_pic_infix :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700102endef # create-core-oat-host-rules
103
Andreas Gampec23c9c92014-10-28 14:47:25 -0700104# $(1): compiler - default, optimizing or interpreter.
105define create-core-oat-host-rule-combination
106 $(call create-core-oat-host-rules,$(1),no-pic,)
107 $(call create-core-oat-host-rules,$(1),pic,)
108
109 ifneq ($(HOST_PREFER_32_BIT),true)
110 $(call create-core-oat-host-rules,$(1),no-pic,2ND_)
111 $(call create-core-oat-host-rules,$(1),pic,2ND_)
112 endif
113endef
114
115$(eval $(call create-core-oat-host-rule-combination,default))
116$(eval $(call create-core-oat-host-rule-combination,optimizing))
117$(eval $(call create-core-oat-host-rule-combination,interpreter))
118
Brian Carlstrom2b7cdf42011-10-13 11:18:28 -0700119
Ian Rogersafd9acc2014-06-17 08:21:54 -0700120define create-core-oat-target-rules
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700121 core_compile_options :=
122 core_image_name :=
123 core_oat_name :=
124 core_infix :=
Andreas Gampec23c9c92014-10-28 14:47:25 -0700125 core_pic_infix :=
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700126
127 ifeq ($(1),optimizing)
128 core_compile_options += --compiler-backend=optimizing
129 core_infix := -optimizing
130 endif
131 ifeq ($(1),interpreter)
132 core_compile_options += --compiler-filter=interpret-only
133 core_infix := -interpreter
134 endif
135 ifeq ($(1),default)
136 # Default has no infix, no compile options.
137 endif
138 ifneq ($(filter-out default interpreter optimizing,$(1)),)
Andreas Gampec23c9c92014-10-28 14:47:25 -0700139 # Technically this test is not precise, but hopefully good enough.
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700140 $$(error found $(1) expected default, interpreter or optimizing)
141 endif
Andreas Gampec23c9c92014-10-28 14:47:25 -0700142
143 ifeq ($(2),pic)
144 core_compile_options += --compile-pic
145 core_pic_infix := -pic
146 endif
147 ifeq ($(2),no-pic)
148 # No change for non-pic
149 endif
150 ifneq ($(filter-out pic no-pic,$(2)),)
151 #Technically this test is not precise, but hopefully good enough.
152 $$(error found $(2) expected pic or no-pic)
153 endif
154
155 core_image_name := $($(3)TARGET_CORE_IMG_OUT_BASE)$$(core_infix)$$(core_pic_infix)$(CORE_IMG_SUFFIX)
156 core_oat_name := $($(3)TARGET_CORE_OAT_OUT_BASE)$$(core_infix)$$(core_pic_infix)$(CORE_OAT_SUFFIX)
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700157
158 # Using the bitness suffix makes it easier to add as a dependency for the run-test mk.
Andreas Gampec23c9c92014-10-28 14:47:25 -0700159 ifeq ($(3),)
160 ifdef TARGET_2ND_ARCH
161 TARGET_CORE_IMAGE_$(1)_$(2)_64 := $$(core_image_name)
162 else
163 TARGET_CORE_IMAGE_$(1)_$(2)_32 := $$(core_image_name)
164 endif
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700165 else
Andreas Gampec23c9c92014-10-28 14:47:25 -0700166 TARGET_CORE_IMAGE_$(1)_$(2)_32 := $$(core_image_name)
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700167 endif
168 TARGET_CORE_IMG_OUTS += $$(core_image_name)
169 TARGET_CORE_OAT_OUTS += $$(core_oat_name)
170
171$$(core_image_name): PRIVATE_CORE_COMPILE_OPTIONS := $$(core_compile_options)
172$$(core_image_name): PRIVATE_CORE_IMG_NAME := $$(core_image_name)
173$$(core_image_name): PRIVATE_CORE_OAT_NAME := $$(core_oat_name)
174$$(core_image_name): $$(TARGET_CORE_DEX_FILES) $$(DEX2OAT_DEPENDENCY)
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700175 @echo "target dex2oat: $$@ ($$?)"
176 @mkdir -p $$(dir $$@)
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700177 $$(hide) $$(DEX2OAT) --runtime-arg -Xms$(DEX2OAT_XMS) --runtime-arg -Xmx$(DEX2OAT_XMX) \
Ian Rogersafd9acc2014-06-17 08:21:54 -0700178 --image-classes=$$(PRELOADED_CLASSES) $$(addprefix --dex-file=,$$(TARGET_CORE_DEX_FILES)) \
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700179 $$(addprefix --dex-location=,$$(TARGET_CORE_DEX_LOCATIONS)) --oat-file=$$(PRIVATE_CORE_OAT_NAME) \
180 --oat-location=$$(PRIVATE_CORE_OAT_NAME) --image=$$(PRIVATE_CORE_IMG_NAME) \
Andreas Gampec23c9c92014-10-28 14:47:25 -0700181 --base=$$(LIBART_IMG_TARGET_BASE_ADDRESS) --instruction-set=$$($(3)TARGET_ARCH) \
182 --instruction-set-features=$$($(3)TARGET_INSTRUCTION_SET_FEATURES) \
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700183 --android-root=$$(PRODUCT_OUT)/system --include-patch-information \
184 $$(PRIVATE_CORE_COMPILE_OPTIONS)
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700185
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700186$$(core_oat_name): $$(core_image_name)
Andreas Gampe2fe07922014-04-21 07:50:39 -0700187
Andreas Gampe63fc30e2014-10-24 21:58:16 -0700188 # Clean up locally used variables.
189 core_compile_options :=
190 core_image_name :=
191 core_oat_name :=
192 core_infix :=
Andreas Gampec23c9c92014-10-28 14:47:25 -0700193 core_pic_infix :=
Ian Rogersafd9acc2014-06-17 08:21:54 -0700194endef # create-core-oat-target-rules
Andreas Gampeafbaa1a2014-03-25 18:09:32 -0700195
Andreas Gampec23c9c92014-10-28 14:47:25 -0700196# $(1): compiler - default, optimizing or interpreter.
197define create-core-oat-target-rule-combination
198 $(call create-core-oat-target-rules,$(1),no-pic,)
199 $(call create-core-oat-target-rules,$(1),pic,)
200
201 ifdef TARGET_2ND_ARCH
202 $(call create-core-oat-target-rules,$(1),no-pic,2ND_)
203 $(call create-core-oat-target-rules,$(1),pic,2ND_)
204 endif
205endef
206
207$(eval $(call create-core-oat-target-rule-combination,default))
208$(eval $(call create-core-oat-target-rule-combination,optimizing))
209$(eval $(call create-core-oat-target-rule-combination,interpreter))