blob: 608ad11ad0d8174b019630b2d0a58f29e80de79c [file] [log] [blame]
Ying Wangdb48da72014-09-13 11:26:39 -07001#
2# Copyright (C) 2014 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# Set up variables and dependency for one odex file
18# Input variables: my_2nd_arch_prefix
19# Output(modified) variables: built_odex, installed_odex, built_installed_odex
20
21my_built_odex := $(call get-odex-file-path,$($(my_2nd_arch_prefix)DEX2OAT_TARGET_ARCH),$(LOCAL_BUILT_MODULE))
22ifdef LOCAL_DEX_PREOPT_IMAGE_LOCATION
23my_dex_preopt_image_location := $(LOCAL_DEX_PREOPT_IMAGE_LOCATION)
24else
25my_dex_preopt_image_location := $($(my_2nd_arch_prefix)DEFAULT_DEX_PREOPT_BUILT_IMAGE_LOCATION)
26endif
27my_dex_preopt_image_filename := $(call get-image-file-path,$($(my_2nd_arch_prefix)DEX2OAT_TARGET_ARCH),$(my_dex_preopt_image_location))
28$(my_built_odex): PRIVATE_2ND_ARCH_VAR_PREFIX := $(my_2nd_arch_prefix)
29$(my_built_odex): PRIVATE_DEX_LOCATION := $(patsubst $(PRODUCT_OUT)%,%,$(LOCAL_INSTALLED_MODULE))
30$(my_built_odex): PRIVATE_DEX_PREOPT_IMAGE_LOCATION := $(my_dex_preopt_image_location)
31$(my_built_odex) : $($(my_2nd_arch_prefix)DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT) \
32 $(DEXPREOPT_ONE_FILE_DEPENDENCY_TOOLS) \
33 $(my_dex_preopt_image_filename)
34
Alex Light4e358ab2016-06-16 14:47:10 -070035my_installed_odex := $(call get-odex-installed-file-path,$($(my_2nd_arch_prefix)DEX2OAT_TARGET_ARCH),$(LOCAL_INSTALLED_MODULE))
36
David Brazdil29441f92016-09-12 16:43:28 +010037my_built_vdex := $(patsubst %.odex,%.vdex,$(my_built_odex))
38my_installed_vdex := $(patsubst %.odex,%.vdex,$(my_installed_odex))
Mathieu Chartier192b91c2017-02-08 18:30:31 -080039my_installed_art := $(patsubst %.odex,%.art,$(my_installed_odex))
40
Mathieu Chartiera4b993b2017-02-28 11:17:32 -080041ifndef LOCAL_DEX_PREOPT_APP_IMAGE
42# Local override not defined, use the global one.
43ifeq (true,$(WITH_DEX_PREOPT_APP_IMAGE))
44 LOCAL_DEX_PREOPT_APP_IMAGE := true
45endif
46endif
47
48ifeq (true,$(LOCAL_DEX_PREOPT_APP_IMAGE))
Mathieu Chartier192b91c2017-02-08 18:30:31 -080049my_built_art := $(patsubst %.odex,%.art,$(my_built_odex))
50$(my_built_odex): PRIVATE_ART_FILE_PREOPT_FLAGS := --app-image-file=$(my_built_art) \
51 --image-format=lz4
52$(eval $(call copy-one-file,$(my_built_art),$(my_installed_art)))
53built_art += $(my_built_art)
54installed_art += $(my_installed_art)
55built_installed_art += $(my_built_art):$(my_installed_art)
56endif
David Brazdil29441f92016-09-12 16:43:28 +010057
Mathieu Chartiera4b993b2017-02-28 11:17:32 -080058ifndef LOCAL_DEX_PREOPT_GENERATE_PROFILE
59ifeq (true,$(WITH_DEX_PREOPT_GENERATE_PROFILE))
60 LOCAL_DEX_PREOPT_GENERATE_PROFILE := true
61endif
62endif
63
64ifeq (true,$(LOCAL_DEX_PREOPT_GENERATE_PROFILE))
65ifndef LOCAL_DEX_PREOPT_PROFILE_CLASS_LISTING
66$(call pretty-error,Must have specified class listing (LOCAL_DEX_PREOPT_PROFILE_CLASS_LISTING))
67endif
68my_built_profile := $(dir $(my_built_odex))../../$($(my_2nd_arch_prefix)DEX2OAT_TARGET_ARCH).prof
69my_profile_classes := $(patsubst %.prof,%.classes,$(my_built_profile))
70my_dex_location := $(patsubst $(PRODUCT_OUT)%,%,$(LOCAL_INSTALLED_MODULE))
71$(my_built_odex): $(my_built_profile)
72$(my_built_odex): PRIVATE_PROFILE_PREOPT_FLAGS := --profile-file=$(my_built_profile)
73$(my_built_profile): PRIVATE_INSTALLED_MODULE := $(LOCAL_INSTALLED_MODULE)
74$(my_built_profile): PRIVATE_DEX_LOCATION := $(my_dex_location)
75$(my_built_profile): PRIVATE_PROFILE_CLASSES := $(my_profile_classes)
76$(my_built_profile): PRIVATE_SOURCE_CLASSES := $(LOCAL_DEX_PREOPT_PROFILE_CLASS_LISTING)
77$(my_built_profile): $(LOCAL_DEX_PREOPT_PROFILE_CLASS_LISTING)
78$(my_built_profile): $(PROFMAN)
79$(my_built_profile): $(PRIVATE_INSTALLED_MODULE)
80$(my_built_profile):
81 cp $(PRIVATE_SOURCE_CLASSES) $(PRIVATE_PROFILE_CLASSES)
82 $(PROFMAN) --create-profile-from=$(PRIVATE_PROFILE_CLASSES) --apk=$(PRIVATE_INSTALLED_MODULE) --dex-location=$(PRIVATE_DEX_LOCATION) --reference-profile-file=$@
83endif
84
Alex Light4e358ab2016-06-16 14:47:10 -070085$(eval $(call copy-one-file,$(my_built_odex),$(my_installed_odex)))
David Brazdil29441f92016-09-12 16:43:28 +010086$(eval $(call copy-one-file,$(my_built_vdex),$(my_installed_vdex)))
Ying Wangdb48da72014-09-13 11:26:39 -070087
88built_odex += $(my_built_odex)
David Brazdil29441f92016-09-12 16:43:28 +010089built_vdex += $(my_built_vdex)
David Brazdil70470162016-08-25 13:50:15 +010090
Ying Wangdb48da72014-09-13 11:26:39 -070091installed_odex += $(my_installed_odex)
David Brazdil29441f92016-09-12 16:43:28 +010092installed_vdex += $(my_installed_vdex)
David Brazdil70470162016-08-25 13:50:15 +010093
Ying Wangdb48da72014-09-13 11:26:39 -070094built_installed_odex += $(my_built_odex):$(my_installed_odex)
David Brazdil70470162016-08-25 13:50:15 +010095built_installed_vdex += $(my_built_vdex):$(my_installed_vdex)