• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Java prebuilt coming from Soong.
2# Extra inputs:
3# LOCAL_SOONG_BUILT_INSTALLED
4# LOCAL_SOONG_CLASSES_JAR
5# LOCAL_SOONG_HEADER_JAR
6# LOCAL_SOONG_DEX_JAR
7# LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR
8# LOCAL_SOONG_DEXPREOPT_CONFIG
9
10ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK))
11  $(call pretty-error,soong_java_prebuilt.mk may only be used from Soong)
12endif
13
14LOCAL_MODULE_SUFFIX := .jar
15LOCAL_BUILT_MODULE_STEM := javalib.jar
16
17intermediates.COMMON := $(call local-intermediates-dir,COMMON)
18
19full_classes_jar := $(intermediates.COMMON)/classes.jar
20full_classes_pre_proguard_jar := $(intermediates.COMMON)/classes-pre-proguard.jar
21full_classes_header_jar := $(intermediates.COMMON)/classes-header.jar
22common_javalib.jar := $(intermediates.COMMON)/javalib.jar
23
24ifdef LOCAL_SOONG_AAR
25  LOCAL_ADDITIONAL_CHECKED_MODULE += $(LOCAL_SOONG_AAR)
26endif
27
28# Use the Soong output as the checkbuild target instead of LOCAL_BUILT_MODULE
29# to avoid checkbuilds making an extra copy of every module.
30LOCAL_CHECKED_MODULE := $(LOCAL_PREBUILT_MODULE_FILE)
31LOCAL_ADDITIONAL_CHECKED_MODULE += $(LOCAL_SOONG_HEADER_JAR)
32LOCAL_ADDITIONAL_CHECKED_MODULE += $(LOCAL_FULL_MANIFEST_FILE)
33LOCAL_ADDITIONAL_CHECKED_MODULE += $(LOCAL_SOONG_DEXPREOPT_CONFIG)
34LOCAL_ADDITIONAL_CHECKED_MODULE += $(LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE)
35LOCAL_ADDITIONAL_CHECKED_MODULE += $(LOCAL_SOONG_DEX_JAR)
36
37#######################################
38include $(BUILD_SYSTEM)/base_rules.mk
39#######################################
40
41ifdef LOCAL_SOONG_CLASSES_JAR
42  $(eval $(call copy-one-file,$(LOCAL_SOONG_CLASSES_JAR),$(full_classes_jar)))
43  $(eval $(call copy-one-file,$(LOCAL_SOONG_CLASSES_JAR),$(full_classes_pre_proguard_jar)))
44  $(eval $(call add-dependency,$(LOCAL_BUILT_MODULE),$(full_classes_jar)))
45
46  ifneq ($(TURBINE_ENABLED),false)
47    ifdef LOCAL_SOONG_HEADER_JAR
48      $(eval $(call copy-one-file,$(LOCAL_SOONG_HEADER_JAR),$(full_classes_header_jar)))
49    else
50      $(eval $(call copy-one-file,$(full_classes_jar),$(full_classes_header_jar)))
51    endif
52  endif # TURBINE_ENABLED != false
53endif
54
55$(eval $(call copy-one-file,$(LOCAL_PREBUILT_MODULE_FILE),$(LOCAL_BUILT_MODULE)))
56
57ifdef LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR
58  $(eval $(call copy-one-file,$(LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR),\
59    $(call local-packaging-dir,jacoco)/jacoco-report-classes.jar))
60  $(call add-dependency,$(common_javalib.jar),\
61    $(call local-packaging-dir,jacoco)/jacoco-report-classes.jar)
62endif
63
64ifdef LOCAL_SOONG_PROGUARD_DICT
65  $(eval $(call copy-r8-dictionary-file-with-mapping,\
66    $(LOCAL_SOONG_PROGUARD_DICT),\
67    $(intermediates.COMMON)/proguard_dictionary,\
68    $(intermediates.COMMON)/proguard_dictionary.textproto))
69
70  ALL_MODULES.$(my_register_name).PROGUARD_DICTIONARY_FILES := \
71    $(intermediates.COMMON)/proguard_dictionary \
72    $(LOCAL_SOONG_CLASSES_JAR)
73  ALL_MODULES.$(my_register_name).PROGUARD_DICTIONARY_SOONG_ZIP_ARGUMENTS := \
74    -e out/target/common/obj/$(LOCAL_MODULE_CLASS)/$(LOCAL_MODULE)_intermediates/proguard_dictionary \
75    -f $(intermediates.COMMON)/proguard_dictionary \
76    -e out/target/common/obj/$(LOCAL_MODULE_CLASS)/$(LOCAL_MODULE)_intermediates/classes.jar \
77    -f $(LOCAL_SOONG_CLASSES_JAR)
78  ALL_MODULES.$(my_register_name).PROGUARD_DICTIONARY_MAPPING := $(intermediates.COMMON)/proguard_dictionary.textproto
79endif
80
81ifdef LOCAL_SOONG_PROGUARD_USAGE_ZIP
82  ALL_MODULES.$(my_register_name).PROGUARD_USAGE_ZIP := $(LOCAL_SOONG_PROGUARD_USAGE_ZIP)
83endif
84
85
86ifdef LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE
87  my_res_package := $(intermediates.COMMON)/package-res.apk
88
89  $(my_res_package): $(LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE)
90	@echo "Copy: $@"
91	$(copy-file-to-target)
92
93  $(call add-dependency,$(LOCAL_BUILT_MODULE),$(my_res_package))
94
95  my_transitive_res_packages := $(intermediates.COMMON)/transitive-res-packages
96  $(eval $(call copy-one-file,$(LOCAL_SOONG_TRANSITIVE_RES_PACKAGES),$(my_transitive_res_packages)))
97  $(call add-dependency,$(my_res_package),$(my_transitive_res_packages))
98
99  my_proguard_flags := $(intermediates.COMMON)/export_proguard_flags
100  $(eval $(call copy-one-file,$(LOCAL_SOONG_EXPORT_PROGUARD_FLAGS),$(my_proguard_flags)))
101  $(call add-dependency,$(LOCAL_BUILT_MODULE),$(my_proguard_flags))
102
103  my_static_library_extra_packages := $(intermediates.COMMON)/extra_packages
104  $(eval $(call copy-one-file,$(LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES),$(my_static_library_extra_packages)))
105  $(call add-dependency,$(LOCAL_BUILT_MODULE),$(my_static_library_extra_packages))
106
107  my_static_library_android_manifest := $(intermediates.COMMON)/manifest/AndroidManifest.xml
108  $(eval $(call copy-one-file,$(LOCAL_FULL_MANIFEST_FILE),$(my_static_library_android_manifest)))
109  $(call add-dependency,$(LOCAL_BUILT_MODULE),$(my_static_library_android_manifest))
110endif # LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE
111
112
113ifdef LOCAL_SOONG_DEX_JAR
114  ifndef LOCAL_IS_HOST_MODULE
115    boot_jars := $(foreach pair,$(PRODUCT_BOOT_JARS), $(call word-colon,2,$(pair)))
116    ifneq ($(filter $(LOCAL_MODULE),$(boot_jars)),) # is_boot_jar
117      ifeq (true,$(WITH_DEXPREOPT))
118        # $(DEFAULT_DEX_PREOPT_INSTALLED_IMAGE_MODULE) contains modules that installs
119        # all of bootjars' dexpreopt files (.art, .oat, .vdex, ...)
120        # Add them to the required list so they are installed alongside this module.
121        ALL_MODULES.$(my_register_name).REQUIRED_FROM_TARGET += \
122          $(DEFAULT_DEX_PREOPT_INSTALLED_IMAGE_MODULE) \
123          $(2ND_DEFAULT_DEX_PREOPT_INSTALLED_IMAGE_MODULE)
124        # Copy $(LOCAL_BUILT_MODULE) and its dependencies when installing boot.art
125        # so that dependencies of $(LOCAL_BUILT_MODULE) (which may include
126        # jacoco-report-classes.jar) are copied for every build.
127        $(foreach m,$(DEFAULT_DEX_PREOPT_INSTALLED_IMAGE_MODULE) $(2ND_DEFAULT_DEX_PREOPT_INSTALLED_IMAGE_MODULE), \
128          $(eval $(call add-dependency,$(firstword $(call module-installed-files,$(m))),$(LOCAL_BUILT_MODULE))) \
129        )
130      endif
131    endif # is_boot_jar
132
133    $(eval $(call copy-one-file,$(LOCAL_SOONG_DEX_JAR),$(common_javalib.jar)))
134    $(eval $(call add-dependency,$(LOCAL_BUILT_MODULE),$(common_javalib.jar)))
135    ifdef LOCAL_SOONG_CLASSES_JAR
136      $(eval $(call add-dependency,$(common_javalib.jar),$(full_classes_jar)))
137      ifneq ($(TURBINE_ENABLED),false)
138        $(eval $(call add-dependency,$(common_javalib.jar),$(full_classes_header_jar)))
139      endif
140    endif
141  endif
142
143  java-dex : $(LOCAL_BUILT_MODULE)
144else  # LOCAL_SOONG_DEX_JAR
145  ifndef LOCAL_UNINSTALLABLE_MODULE
146    ifndef LOCAL_IS_HOST_MODULE
147      $(call pretty-error,Installable device module must have LOCAL_SOONG_DEX_JAR set)
148    endif
149  endif
150endif  # LOCAL_SOONG_DEX_JAR
151
152ALL_MODULES.$(my_register_name).CLASSES_JAR := $(full_classes_jar)
153
154ifdef LOCAL_SOONG_AAR
155  ALL_MODULES.$(my_register_name).AAR := $(LOCAL_SOONG_AAR)
156endif
157
158# Copy dexpreopt.config files from Soong libraries to the location where Make
159# modules can find them.
160ifdef LOCAL_SOONG_DEXPREOPT_CONFIG
161  $(eval $(call copy-one-file,$(LOCAL_SOONG_DEXPREOPT_CONFIG), $(call local-intermediates-dir,)/dexpreopt.config))
162  my_dexpreopt_config := $(PRODUCT_OUT)/dexpreopt_config/$(LOCAL_MODULE)_dexpreopt.config
163  $(eval $(call copy-one-file,$(LOCAL_SOONG_DEXPREOPT_CONFIG), $(my_dexpreopt_config)))
164  $(LOCAL_BUILT_MODULE): $(my_dexpreopt_config)
165endif
166
167ifdef LOCAL_SOONG_CLASSES_JAR
168javac-check : $(full_classes_jar)
169javac-check-$(LOCAL_MODULE) : $(full_classes_jar)
170endif
171.PHONY: javac-check-$(LOCAL_MODULE)
172
173ifndef LOCAL_IS_HOST_MODULE
174ifeq ($(LOCAL_SDK_VERSION),system_current)
175my_link_type := java:system
176else ifneq (,$(call has-system-sdk-version,$(LOCAL_SDK_VERSION)))
177my_link_type := java:system
178else ifeq ($(LOCAL_SDK_VERSION),core_current)
179my_link_type := java:core
180else ifneq ($(LOCAL_SDK_VERSION),)
181my_link_type := java:sdk
182else
183my_link_type := java:platform
184endif
185# warn/allowed types are both empty because Soong modules can't depend on
186# make-defined modules.
187my_warn_types :=
188my_allowed_types :=
189
190my_link_deps :=
191my_2nd_arch_prefix := $(LOCAL_2ND_ARCH_VAR_PREFIX)
192my_common := COMMON
193include $(BUILD_SYSTEM)/link_type.mk
194endif # !LOCAL_IS_HOST_MODULE
195
196# LOCAL_EXPORT_SDK_LIBRARIES set by soong is written to exported-sdk-libs file
197my_exported_sdk_libs_file := $(intermediates.COMMON)/exported-sdk-libs
198$(my_exported_sdk_libs_file): PRIVATE_EXPORTED_SDK_LIBS := $(LOCAL_EXPORT_SDK_LIBRARIES)
199$(my_exported_sdk_libs_file):
200	@echo "Export SDK libs $@"
201	$(hide) mkdir -p $(dir $@) && rm -f $@
202	$(if $(PRIVATE_EXPORTED_SDK_LIBS),\
203		$(hide) echo $(PRIVATE_EXPORTED_SDK_LIBS) | tr ' ' '\n' > $@,\
204		$(hide) touch $@)
205
206SOONG_ALREADY_CONV += $(LOCAL_MODULE)
207