• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#
2# Copyright (C) 2019 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# Internal build rules for JAVA_LIBRARIES prebuilt modules
19############################################################
20
21ifneq (JAVA_LIBRARIES,$(LOCAL_MODULE_CLASS))
22$(call pretty-error,java_prebuilt_internal.mk is for JAVA_LIBRARIES modules only)
23endif
24
25include $(BUILD_SYSTEM)/base_rules.mk
26built_module := $(LOCAL_BUILT_MODULE)
27
28ifeq (,$(LOCAL_IS_HOST_MODULE)$(filter true,$(LOCAL_UNINSTALLABLE_MODULE)))
29  prebuilt_module_is_dex_javalib := true
30else
31  prebuilt_module_is_dex_javalib :=
32endif
33
34ifeq ($(prebuilt_module_is_dex_javalib),true)
35my_dex_jar := $(my_prebuilt_src_file)
36# This is a target shared library, i.e. a jar with classes.dex.
37
38$(foreach pair,$(PRODUCT_BOOT_JARS), \
39  $(if $(filter $(LOCAL_MODULE),$(call word-colon,2,$(pair))), \
40    $(call pretty-error,Modules in PRODUCT_BOOT_JARS must be defined in Android.bp files)))
41
42ALL_MODULES.$(my_register_name).CLASSES_JAR := $(common_classes_jar)
43
44#######################################
45# defines built_odex along with rule to install odex
46my_manifest_or_apk := $(my_prebuilt_src_file)
47include $(BUILD_SYSTEM)/dex_preopt_odex_install.mk
48my_manifest_or_apk :=
49#######################################
50$(built_module) : $(my_prebuilt_src_file)
51	$(call copy-file-to-target)
52
53else  # ! prebuilt_module_is_dex_javalib
54$(built_module) : $(my_prebuilt_src_file)
55	$(transform-prebuilt-to-target)
56endif # ! prebuilt_module_is_dex_javalib
57
58my_src_jar := $(my_prebuilt_src_file)
59
60ifdef LOCAL_IS_HOST_MODULE
61# for host java libraries deps should be in the common dir, so we make a copy in
62# the common dir.
63common_classes_jar := $(intermediates.COMMON)/classes.jar
64common_header_jar := $(intermediates.COMMON)/classes-header.jar
65
66$(common_classes_jar): PRIVATE_MODULE := $(LOCAL_MODULE)
67$(common_classes_jar): PRIVATE_PREFIX := $(my_prefix)
68
69$(common_classes_jar) : $(my_src_jar)
70	$(transform-prebuilt-to-target)
71
72ifneq ($(TURBINE_ENABLED),false)
73$(common_header_jar) : $(my_src_jar)
74	$(transform-prebuilt-to-target)
75endif
76
77else # !LOCAL_IS_HOST_MODULE
78# for target java libraries, the LOCAL_BUILT_MODULE is in a product-specific dir,
79# while the deps should be in the common dir, so we make a copy in the common dir.
80common_classes_jar := $(intermediates.COMMON)/classes.jar
81common_header_jar := $(intermediates.COMMON)/classes-header.jar
82common_classes_pre_proguard_jar := $(intermediates.COMMON)/classes-pre-proguard.jar
83common_javalib_jar := $(intermediates.COMMON)/javalib.jar
84
85$(common_classes_jar) $(common_classes_pre_proguard_jar) $(common_javalib_jar): PRIVATE_MODULE := $(LOCAL_MODULE)
86$(common_classes_jar) $(common_classes_pre_proguard_jar) $(common_javalib_jar): PRIVATE_PREFIX := $(my_prefix)
87
88ifeq ($(LOCAL_SDK_VERSION),system_current)
89my_link_type := java:system
90else ifneq (,$(call has-system-sdk-version,$(LOCAL_SDK_VERSION)))
91my_link_type := java:system
92else ifeq ($(LOCAL_SDK_VERSION),core_current)
93my_link_type := java:core
94else ifneq ($(LOCAL_SDK_VERSION),)
95my_link_type := java:sdk
96else
97my_link_type := java:platform
98endif
99
100# TODO: check dependencies of prebuilt files
101my_link_deps :=
102
103my_2nd_arch_prefix := $(LOCAL_2ND_ARCH_VAR_PREFIX)
104my_common := COMMON
105include $(BUILD_SYSTEM)/link_type.mk
106
107ifeq ($(prebuilt_module_is_dex_javalib),true)
108# For prebuilt shared Java library we don't have classes.jar.
109$(common_javalib_jar) : $(my_src_jar)
110	$(transform-prebuilt-to-target)
111
112else  # ! prebuilt_module_is_dex_javalib
113
114my_src_aar := $(filter %.aar, $(my_prebuilt_src_file))
115ifneq ($(my_src_aar),)
116# This is .aar file, archive of classes.jar and Android resources.
117
118my_src_jar := $(intermediates.COMMON)/aar/classes.jar
119my_src_proguard_options := $(intermediates.COMMON)/aar/proguard.txt
120my_src_android_manifest := $(intermediates.COMMON)/aar/AndroidManifest.xml
121
122$(my_src_jar) : .KATI_IMPLICIT_OUTPUTS := $(my_src_proguard_options)
123$(my_src_jar) : .KATI_IMPLICIT_OUTPUTS += $(my_src_android_manifest)
124$(my_src_jar) : $(my_src_aar)
125	$(hide) rm -rf $(dir $@) && mkdir -p $(dir $@) $(dir $@)/res
126	$(hide) unzip -qoDD -d $(dir $@) $<
127	# Make sure the proguard and AndroidManifest.xml files exist
128	$(hide) touch $(dir $@)/proguard.txt
129	$(hide) touch $(dir $@)/AndroidManifest.xml
130
131my_prebuilt_android_manifest := $(intermediates.COMMON)/manifest/AndroidManifest.xml
132$(eval $(call copy-one-file,$(my_src_android_manifest),$(my_prebuilt_android_manifest)))
133$(call add-dependency,$(LOCAL_BUILT_MODULE),$(my_prebuilt_android_manifest))
134
135endif
136
137$(common_classes_jar) : $(my_src_jar)
138	$(transform-prebuilt-to-target)
139
140ifneq ($(TURBINE_ENABLED),false)
141$(common_header_jar) : $(my_src_jar)
142	$(transform-prebuilt-to-target)
143endif
144
145$(common_classes_pre_proguard_jar) : $(my_src_jar)
146	$(transform-prebuilt-to-target)
147
148$(common_javalib_jar) : $(common_classes_jar)
149	$(transform-prebuilt-to-target)
150
151include $(BUILD_SYSTEM)/force_aapt2.mk
152
153ifneq ($(my_src_aar),)
154
155$(intermediates.COMMON)/export_proguard_flags : $(my_src_proguard_options)
156	$(transform-prebuilt-to-target)
157
158LOCAL_SDK_RES_VERSION:=$(strip $(LOCAL_SDK_RES_VERSION))
159ifeq ($(LOCAL_SDK_RES_VERSION),)
160  LOCAL_SDK_RES_VERSION:=$(LOCAL_SDK_VERSION)
161endif
162
163framework_res_package_export :=
164# Please refer to package.mk
165ifneq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
166ifneq ($(filter-out current system_current test_current,$(LOCAL_SDK_RES_VERSION))$(if $(TARGET_BUILD_USE_PREBUILT_SDKS),$(filter current system_current test_current,$(LOCAL_SDK_RES_VERSION))),)
167framework_res_package_export := \
168    $(call resolve-prebuilt-sdk-jar-path,$(LOCAL_SDK_RES_VERSION))
169else
170framework_res_package_export := \
171    $(call intermediates-dir-for,APPS,framework-res,,COMMON)/package-export.apk
172endif
173endif
174
175my_res_package := $(intermediates.COMMON)/package-res.apk
176
177# We needed only very few PRIVATE variables and aapt2.mk input variables. Reset the unnecessary ones.
178$(my_res_package): PRIVATE_AAPT2_CFLAGS :=
179$(my_res_package): PRIVATE_AAPT_FLAGS := --static-lib --no-static-lib-packages --auto-add-overlay
180$(my_res_package): PRIVATE_ANDROID_MANIFEST := $(my_src_android_manifest)
181$(my_res_package): PRIVATE_AAPT_INCLUDES := $(framework_res_package_export)
182$(my_res_package): PRIVATE_SOURCE_INTERMEDIATES_DIR :=
183$(my_res_package): PRIVATE_PROGUARD_OPTIONS_FILE :=
184$(my_res_package): PRIVATE_DEFAULT_APP_TARGET_SDK :=
185$(my_res_package): PRIVATE_DEFAULT_APP_TARGET_SDK :=
186$(my_res_package): PRIVATE_PRODUCT_AAPT_CONFIG :=
187$(my_res_package): PRIVATE_PRODUCT_AAPT_PREF_CONFIG :=
188$(my_res_package): PRIVATE_TARGET_AAPT_CHARACTERISTICS :=
189$(my_res_package) : $(framework_res_package_export)
190$(my_res_package) : $(my_src_android_manifest)
191
192full_android_manifest :=
193my_res_resources :=
194my_overlay_resources :=
195my_compiled_res_base_dir := $(intermediates.COMMON)/flat-res
196R_file_stamp :=
197proguard_options_file :=
198my_generated_res_dirs := $(intermediates.COMMON)/aar/res
199my_generated_res_dirs_deps := $(my_src_jar)
200include $(BUILD_SYSTEM)/aapt2.mk
201
202# Make sure my_res_package is created when you run mm/mmm.
203$(built_module) : $(my_res_package)
204endif  # $(my_src_aar)
205
206# make sure the classes.jar and javalib.jar are built before $(LOCAL_BUILT_MODULE)
207$(built_module) : $(common_javalib_jar)
208
209my_exported_sdk_libs_file := $(intermediates.COMMON)/exported-sdk-libs
210$(my_exported_sdk_libs_file): PRIVATE_EXPORTED_SDK_LIBS := $(LOCAL_EXPORT_SDK_LIBRARIES)
211$(my_exported_sdk_libs_file):
212	@echo "Export SDK libs $@"
213	$(hide) mkdir -p $(dir $@) && rm -f $@
214	$(if $(PRIVATE_EXPORTED_SDK_LIBS),\
215		$(hide) echo $(PRIVATE_EXPORTED_SDK_LIBS) | tr ' ' '\n' > $@,\
216		$(hide) touch $@)
217
218endif # ! prebuilt_module_is_dex_javalib
219endif # LOCAL_IS_HOST_MODULE is not set
220