Colin Cross | b8901d7 | 2018-12-14 11:49:49 -0800 | [diff] [blame^] | 1 | # |
| 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 | |
| 21 | my_built_odex := $(call get-odex-file-path,$($(my_2nd_arch_prefix)DEX2OAT_TARGET_ARCH),$(LOCAL_BUILT_MODULE)) |
| 22 | ifdef LOCAL_DEX_PREOPT_IMAGE_LOCATION |
| 23 | my_dex_preopt_image_location := $(LOCAL_DEX_PREOPT_IMAGE_LOCATION) |
| 24 | else |
| 25 | my_dex_preopt_image_location := $($(my_2nd_arch_prefix)DEFAULT_DEX_PREOPT_BUILT_IMAGE_LOCATION) |
| 26 | endif |
| 27 | my_dex_preopt_image_filename := $(call get-image-file-path,$($(my_2nd_arch_prefix)DEX2OAT_TARGET_ARCH),$(my_dex_preopt_image_location)) |
| 28 | |
| 29 | # If LOCAL_ENFORCE_USES_LIBRARIES is not set, default to true if either of LOCAL_USES_LIBRARIES or |
| 30 | # LOCAL_OPTIONAL_USES_LIBRARIES are specified. |
| 31 | ifeq (,$(LOCAL_ENFORCE_USES_LIBRARIES)) |
| 32 | # Will change the default to true unconditionally in the future. |
| 33 | ifneq (,$(LOCAL_OPTIONAL_USES_LIBRARIES)) |
| 34 | LOCAL_ENFORCE_USES_LIBRARIES := true |
| 35 | endif |
| 36 | ifneq (,$(LOCAL_USES_LIBRARIES)) |
| 37 | LOCAL_ENFORCE_USES_LIBRARIES := true |
| 38 | endif |
| 39 | endif |
| 40 | |
| 41 | my_uses_libraries := $(LOCAL_USES_LIBRARIES) |
| 42 | my_optional_uses_libraries := $(LOCAL_OPTIONAL_USES_LIBRARIES) |
| 43 | my_missing_uses_libraries := $(INTERNAL_PLATFORM_MISSING_USES_LIBRARIES) |
| 44 | |
| 45 | # If we have either optional or required uses-libraries, set up the class loader context |
| 46 | # accordingly. |
| 47 | my_lib_names := |
| 48 | my_optional_lib_names := |
| 49 | my_filtered_optional_uses_libraries := |
| 50 | my_system_dependencies := |
| 51 | my_stored_preopt_class_loader_context_libs := |
| 52 | my_conditional_uses_libraries_host := |
| 53 | my_conditional_uses_libraries_target := |
| 54 | |
| 55 | ifneq (true,$(LOCAL_ENFORCE_USES_LIBRARIES)) |
| 56 | # Pass special class loader context to skip the classpath and collision check. |
| 57 | # This will get removed once LOCAL_USES_LIBRARIES is enforced. |
| 58 | # Right now LOCAL_USES_LIBRARIES is opt in, for the case where it's not specified we still default |
| 59 | # to the &. |
| 60 | my_dex_preopt_class_loader_context := \& |
| 61 | else |
| 62 | # Compute the filtered optional uses libraries by removing ones that are not supposed to exist. |
| 63 | my_filtered_optional_uses_libraries := \ |
| 64 | $(filter-out $(my_missing_uses_libraries), $(my_optional_uses_libraries)) |
| 65 | my_filtered_uses_libraries := $(my_uses_libraries) $(my_filtered_optional_uses_libraries) |
| 66 | |
| 67 | # These are the ones we are verifying in the make rule, use the unfiltered libraries. |
| 68 | my_lib_names := $(my_uses_libraries) |
| 69 | my_optional_lib_names := $(my_optional_uses_libraries) |
| 70 | |
| 71 | # Calculate system build dependencies based on the filtered libraries. |
| 72 | my_intermediate_libs := $(foreach lib_name, $(my_lib_names) $(my_filtered_optional_uses_libraries), \ |
| 73 | $(call intermediates-dir-for,JAVA_LIBRARIES,$(lib_name),,COMMON)/javalib.jar) |
| 74 | my_dex_preopt_system_dependencies := $(my_intermediate_libs) |
| 75 | my_dex_preopt_class_loader_context := $(call normalize-path-list,$(my_intermediate_libs)) |
| 76 | |
| 77 | # The class loader context checksums are filled in by dex2oat. |
| 78 | my_stored_preopt_class_loader_context_libs := $(call normalize-path-list, \ |
| 79 | $(foreach lib_name,$(my_filtered_uses_libraries),/system/framework/$(lib_name).jar)) |
| 80 | |
| 81 | # Fix up org.apache.http.legacy.impl since it should be org.apache.http.legacy in the manifest. |
| 82 | my_lib_names := $(patsubst org.apache.http.legacy.impl,org.apache.http.legacy,$(my_lib_names)) |
| 83 | my_optional_lib_names := $(patsubst org.apache.http.legacy.impl,org.apache.http.legacy,$(my_optional_lib_names)) |
| 84 | ifeq (,$(filter org.apache.http.legacy,$(my_lib_names) $(my_optional_lib_names))) |
| 85 | my_conditional_uses_libraries_host := $(call intermediates-dir-for,JAVA_LIBRARIES,org.apache.http.legacy.impl,,COMMON)/javalib.jar |
| 86 | my_conditional_uses_libraries_target := /system/framework/org.apache.http.legacy.impl.jar |
| 87 | endif |
| 88 | endif |
| 89 | |
| 90 | $(my_built_odex): $(AAPT) |
| 91 | $(my_built_odex): $(my_conditional_uses_libraries_host) |
| 92 | $(my_built_odex): $(my_dex_preopt_system_dependencies) |
| 93 | $(my_built_odex): PRIVATE_ENFORCE_USES_LIBRARIES := $(LOCAL_ENFORCE_USES_LIBRARIES) |
| 94 | $(my_built_odex): PRIVATE_CONDITIONAL_USES_LIBRARIES_HOST := $(my_conditional_uses_libraries_host) |
| 95 | $(my_built_odex): PRIVATE_CONDITIONAL_USES_LIBRARIES_TARGET := $(my_conditional_uses_libraries_target) |
| 96 | $(my_built_odex): PRIVATE_USES_LIBRARY_NAMES := $(my_lib_names) |
| 97 | $(my_built_odex): PRIVATE_OPTIONAL_USES_LIBRARY_NAMES := $(my_optional_lib_names) |
| 98 | $(my_built_odex): PRIVATE_2ND_ARCH_VAR_PREFIX := $(my_2nd_arch_prefix) |
| 99 | $(my_built_odex): PRIVATE_DEX_LOCATION := $(patsubst $(PRODUCT_OUT)%,%,$(LOCAL_INSTALLED_MODULE)) |
| 100 | $(my_built_odex): PRIVATE_DEX_PREOPT_IMAGE_LOCATION := $(my_dex_preopt_image_location) |
| 101 | $(my_built_odex): PRIVATE_DEX2OAT_CLASS_LOADER_CONTEXT := $(my_dex_preopt_class_loader_context) |
| 102 | $(my_built_odex): PRIVATE_DEX2OAT_STORED_CLASS_LOADER_CONTEXT_LIBS := $(my_stored_preopt_class_loader_context_libs) |
| 103 | $(my_built_odex) : $($(my_2nd_arch_prefix)DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT) \ |
| 104 | $(DEXPREOPT_ONE_FILE_DEPENDENCY_TOOLS) \ |
| 105 | $(my_dex_preopt_image_filename) |
| 106 | |
| 107 | my_installed_odex := $(call get-odex-installed-file-path,$($(my_2nd_arch_prefix)DEX2OAT_TARGET_ARCH),$(LOCAL_INSTALLED_MODULE)) |
| 108 | |
| 109 | my_built_vdex := $(patsubst %.odex,%.vdex,$(my_built_odex)) |
| 110 | my_installed_vdex := $(patsubst %.odex,%.vdex,$(my_installed_odex)) |
| 111 | my_installed_art := $(patsubst %.odex,%.art,$(my_installed_odex)) |
| 112 | |
| 113 | ifndef LOCAL_DEX_PREOPT_APP_IMAGE |
| 114 | # Local override not defined, use the global one. |
| 115 | ifeq (true,$(WITH_DEX_PREOPT_APP_IMAGE)) |
| 116 | LOCAL_DEX_PREOPT_APP_IMAGE := true |
| 117 | endif |
| 118 | endif |
| 119 | |
| 120 | ifeq (true,$(LOCAL_DEX_PREOPT_APP_IMAGE)) |
| 121 | my_built_art := $(patsubst %.odex,%.art,$(my_built_odex)) |
| 122 | $(my_built_odex): PRIVATE_ART_FILE_PREOPT_FLAGS := --app-image-file=$(my_built_art) \ |
| 123 | --image-format=lz4 |
| 124 | $(eval $(call copy-one-file,$(my_built_art),$(my_installed_art))) |
| 125 | built_art += $(my_built_art) |
| 126 | installed_art += $(my_installed_art) |
| 127 | built_installed_art += $(my_built_art):$(my_installed_art) |
| 128 | endif |
| 129 | |
| 130 | $(eval $(call copy-one-file,$(my_built_odex),$(my_installed_odex))) |
| 131 | $(eval $(call copy-one-file,$(my_built_vdex),$(my_installed_vdex))) |
| 132 | |
| 133 | built_odex += $(my_built_odex) |
| 134 | built_vdex += $(my_built_vdex) |
| 135 | |
| 136 | installed_odex += $(my_installed_odex) |
| 137 | installed_vdex += $(my_installed_vdex) |
| 138 | |
| 139 | built_installed_odex += $(my_built_odex):$(my_installed_odex) |
| 140 | built_installed_vdex += $(my_built_vdex):$(my_installed_vdex) |