Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 1 | # Target Java. |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 2 | # Requires: |
| 3 | # LOCAL_MODULE_SUFFIX |
| 4 | # LOCAL_MODULE_CLASS |
| 5 | # all_res_assets |
| 6 | |
Keun young Park | ebb351e | 2012-04-19 15:36:18 -0700 | [diff] [blame] | 7 | ifeq ($(TARGET_BUILD_PDK),true) |
Keun young Park | efe02ce | 2012-06-06 17:19:29 -0700 | [diff] [blame] | 8 | ifeq ($(TARGET_BUILD_PDK_JAVA_PLATFORM),) |
Keun young Park | ebb351e | 2012-04-19 15:36:18 -0700 | [diff] [blame] | 9 | # LOCAL_SDK not defined or set to current |
| 10 | ifeq ($(filter-out current,$(LOCAL_SDK_VERSION)),) |
Ying Wang | 2fee3a8 | 2014-10-17 18:26:39 -0700 | [diff] [blame] | 11 | ifneq ($(LOCAL_NO_STANDARD_LIBRARIES),true) |
Keun young Park | ebb351e | 2012-04-19 15:36:18 -0700 | [diff] [blame] | 12 | LOCAL_SDK_VERSION := $(PDK_BUILD_SDK_VERSION) |
Ying Wang | 2fee3a8 | 2014-10-17 18:26:39 -0700 | [diff] [blame] | 13 | endif #!LOCAL_NO_STANDARD_LIBRARIES |
Keun young Park | ebb351e | 2012-04-19 15:36:18 -0700 | [diff] [blame] | 14 | endif |
Keun young Park | 816b9fd | 2012-05-16 10:32:41 -0700 | [diff] [blame] | 15 | endif # !PDK_JAVA |
Keun young Park | ebb351e | 2012-04-19 15:36:18 -0700 | [diff] [blame] | 16 | endif #PDK |
| 17 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 18 | LOCAL_NO_STANDARD_LIBRARIES:=$(strip $(LOCAL_NO_STANDARD_LIBRARIES)) |
| 19 | LOCAL_SDK_VERSION:=$(strip $(LOCAL_SDK_VERSION)) |
| 20 | |
Ying Wang | a5fc87a | 2010-11-02 18:43:16 -0700 | [diff] [blame] | 21 | proto_sources := $(filter %.proto,$(LOCAL_SRC_FILES)) |
| 22 | ifneq ($(proto_sources),) |
| 23 | ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),micro) |
Jeff Davidson | b8ddd55 | 2014-09-15 17:51:11 -0700 | [diff] [blame] | 24 | LOCAL_STATIC_JAVA_LIBRARIES += libprotobuf-java-micro |
Ying Wang | a5fc87a | 2010-11-02 18:43:16 -0700 | [diff] [blame] | 25 | else |
Ulas Kirazci | bde274e | 2013-03-28 14:02:14 -0700 | [diff] [blame] | 26 | ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nano) |
Jeff Davidson | b8ddd55 | 2014-09-15 17:51:11 -0700 | [diff] [blame] | 27 | LOCAL_STATIC_JAVA_LIBRARIES += libprotobuf-java-nano |
Ulas Kirazci | bde274e | 2013-03-28 14:02:14 -0700 | [diff] [blame] | 28 | else |
Joe Onorato | c05a8ee | 2016-10-05 18:01:10 -0700 | [diff] [blame] | 29 | ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),stream) |
| 30 | # No library for stream protobufs |
| 31 | else |
| 32 | LOCAL_STATIC_JAVA_LIBRARIES += libprotobuf-java-lite |
| 33 | endif |
Ulas Kirazci | bde274e | 2013-03-28 14:02:14 -0700 | [diff] [blame] | 34 | endif |
Ying Wang | a5fc87a | 2010-11-02 18:43:16 -0700 | [diff] [blame] | 35 | endif |
| 36 | endif |
| 37 | |
Ying Wang | e295c3d | 2016-02-24 14:11:55 -0800 | [diff] [blame] | 38 | # LOCAL_STATIC_JAVA_AAR_LIBRARIES and LOCAL_STATIC_ANDROID_LIBRARIES are also LOCAL_STATIC_JAVA_LIBRARIES. |
| 39 | LOCAL_STATIC_JAVA_LIBRARIES := $(strip $(LOCAL_STATIC_JAVA_LIBRARIES) \ |
| 40 | $(LOCAL_STATIC_JAVA_AAR_LIBRARIES) \ |
| 41 | $(LOCAL_STATIC_ANDROID_LIBRARIES)) |
| 42 | # LOCAL_SHARED_ANDROID_LIBRARIES are also LOCAL_JAVA_LIBRARIES. |
| 43 | LOCAL_JAVA_LIBRARIES := $(sort $(LOCAL_JAVA_LIBRARIES) $(LOCAL_SHARED_ANDROID_LIBRARIES)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 44 | |
| 45 | LOCAL_BUILT_MODULE_STEM := $(strip $(LOCAL_BUILT_MODULE_STEM)) |
| 46 | ifeq ($(LOCAL_BUILT_MODULE_STEM),) |
| 47 | $(error $(LOCAL_PATH): Target java template must define LOCAL_BUILT_MODULE_STEM) |
| 48 | endif |
| 49 | ifneq ($(filter classes-compiled.jar classes.jar,$(LOCAL_BUILT_MODULE_STEM)),) |
| 50 | $(error LOCAL_BUILT_MODULE_STEM may not be "$(LOCAL_BUILT_MODULE_STEM)") |
| 51 | endif |
| 52 | |
Joe Onorato | e334d25 | 2009-07-17 15:33:40 -0400 | [diff] [blame] | 53 | |
| 54 | ############################################################################## |
| 55 | # Define the intermediate targets before including base_rules so they get |
| 56 | # the correct environment. |
| 57 | ############################################################################## |
| 58 | |
| 59 | intermediates := $(call local-intermediates-dir) |
| 60 | intermediates.COMMON := $(call local-intermediates-dir,COMMON) |
| 61 | |
Ying Wang | 957fea5 | 2010-09-23 11:48:38 -0700 | [diff] [blame] | 62 | ifeq ($(LOCAL_PROGUARD_ENABLED),disabled) |
| 63 | LOCAL_PROGUARD_ENABLED := |
| 64 | endif |
| 65 | |
Nan Zhang | b3ec534 | 2017-08-31 21:43:04 +0000 | [diff] [blame] | 66 | full_classes_turbine_jar := $(intermediates.COMMON)/classes-turbine.jar |
| 67 | full_classes_header_jarjar := $(intermediates.COMMON)/classes-header-jarjar.jar |
| 68 | full_classes_header_jar := $(intermediates.COMMON)/classes-header.jar |
Colin Cross | a6e8782 | 2017-12-20 17:33:01 -0800 | [diff] [blame] | 69 | full_classes_compiled_jar := $(intermediates.COMMON)/classes-full-debug.jar |
Colin Cross | f8a49c5 | 2017-05-22 16:21:49 -0700 | [diff] [blame] | 70 | full_classes_processed_jar := $(intermediates.COMMON)/classes-processed.jar |
Colin Cross | a6e8782 | 2017-12-20 17:33:01 -0800 | [diff] [blame] | 71 | full_classes_jarjar_jar := $(intermediates.COMMON)/classes-jarjar.jar |
Nan Zhang | 9bd5405 | 2017-09-13 13:13:53 -0700 | [diff] [blame] | 72 | full_classes_combined_jar := $(intermediates.COMMON)/classes-combined.jar |
Colin Cross | a6e8782 | 2017-12-20 17:33:01 -0800 | [diff] [blame] | 73 | built_dex_intermediate := $(intermediates.COMMON)/dex/classes.dex |
David Brazdil | b8fa6dd | 2018-01-29 14:43:14 +0000 | [diff] [blame] | 74 | built_dex_hiddenapi := $(intermediates.COMMON)/dex-hiddenapi/classes.dex |
Ying Wang | 957fea5 | 2010-09-23 11:48:38 -0700 | [diff] [blame] | 75 | full_classes_stubs_jar := $(intermediates.COMMON)/stubs.jar |
Colin Cross | dfc45ec | 2017-05-26 15:22:02 -0700 | [diff] [blame] | 76 | java_source_list_file := $(intermediates.COMMON)/java-source-list |
David Brazdil | b67402e | 2018-08-22 17:38:02 +0100 | [diff] [blame] | 77 | hiddenapi_whitelist_txt := $(intermediates.COMMON)/hiddenapi/whitelist.txt |
| 78 | hiddenapi_greylist_txt := $(intermediates.COMMON)/hiddenapi/greylist.txt |
Mathew Inwood | edb1c84 | 2018-09-07 14:14:36 +0100 | [diff] [blame] | 79 | hiddenapi_darkgreylist_txt := $(intermediates.COMMON)/hiddenapi/darkgreylist.txt |
Ying Wang | 957fea5 | 2010-09-23 11:48:38 -0700 | [diff] [blame] | 80 | |
Ying Wang | 37b82aa | 2013-08-28 17:28:36 -0700 | [diff] [blame] | 81 | ifeq ($(LOCAL_MODULE_CLASS)$(LOCAL_SRC_FILES)$(LOCAL_STATIC_JAVA_LIBRARIES)$(LOCAL_SOURCE_FILES_ALL_GENERATED),APPS) |
| 82 | # If this is an apk without any Java code (e.g. framework-res), we should skip compiling Java. |
Ying Wang | 990cf5e | 2013-08-28 13:04:46 -0700 | [diff] [blame] | 83 | full_classes_jar := |
| 84 | built_dex := |
| 85 | else |
Ying Wang | 957fea5 | 2010-09-23 11:48:38 -0700 | [diff] [blame] | 86 | full_classes_jar := $(intermediates.COMMON)/classes.jar |
Ying Wang | 7b7929a | 2013-09-12 17:35:21 -0700 | [diff] [blame] | 87 | built_dex := $(intermediates.COMMON)/classes.dex |
Ying Wang | 990cf5e | 2013-08-28 13:04:46 -0700 | [diff] [blame] | 88 | endif |
Joe Onorato | e334d25 | 2009-07-17 15:33:40 -0400 | [diff] [blame] | 89 | |
| 90 | LOCAL_INTERMEDIATE_TARGETS += \ |
Nan Zhang | b3ec534 | 2017-08-31 21:43:04 +0000 | [diff] [blame] | 91 | $(full_classes_turbine_jar) \ |
Joe Onorato | e334d25 | 2009-07-17 15:33:40 -0400 | [diff] [blame] | 92 | $(full_classes_compiled_jar) \ |
Ying Wang | 957fea5 | 2010-09-23 11:48:38 -0700 | [diff] [blame] | 93 | $(full_classes_jarjar_jar) \ |
Ying Wang | 957fea5 | 2010-09-23 11:48:38 -0700 | [diff] [blame] | 94 | $(full_classes_jar) \ |
Nan Zhang | 9bd5405 | 2017-09-13 13:13:53 -0700 | [diff] [blame] | 95 | $(full_classes_combined_jar) \ |
Ying Wang | 957fea5 | 2010-09-23 11:48:38 -0700 | [diff] [blame] | 96 | $(built_dex_intermediate) \ |
Guang Zhu | 155afe3 | 2010-03-10 15:48:03 -0800 | [diff] [blame] | 97 | $(built_dex) \ |
Colin Cross | dfc45ec | 2017-05-26 15:22:02 -0700 | [diff] [blame] | 98 | $(full_classes_stubs_jar) \ |
| 99 | $(java_source_list_file) |
Ying Wang | 957fea5 | 2010-09-23 11:48:38 -0700 | [diff] [blame] | 100 | |
Joe Onorato | 77dc0a5 | 2010-05-17 18:16:11 -0700 | [diff] [blame] | 101 | LOCAL_INTERMEDIATE_SOURCE_DIR := $(intermediates.COMMON)/src |
Joe Onorato | e334d25 | 2009-07-17 15:33:40 -0400 | [diff] [blame] | 102 | |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 103 | ########################################################### |
| 104 | ## AIDL: Compile .aidl files to .java |
| 105 | ########################################################### |
| 106 | aidl_sources := $(filter %.aidl,$(LOCAL_SRC_FILES)) |
Christopher Wiley | d9205ba | 2016-06-23 16:44:47 -0700 | [diff] [blame] | 107 | aidl_java_sources := |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 108 | |
| 109 | ifneq ($(strip $(aidl_sources)),) |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 110 | |
| 111 | aidl_preprocess_import := |
| 112 | ifdef LOCAL_SDK_VERSION |
Jiyong Park | 5ebca30 | 2018-01-31 00:14:55 +0900 | [diff] [blame] | 113 | ifneq ($(filter current system_current test_current core_current, $(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS)),) |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 114 | # LOCAL_SDK_VERSION is current and no TARGET_BUILD_APPS |
| 115 | aidl_preprocess_import := $(TARGET_OUT_COMMON_INTERMEDIATES)/framework.aidl |
| 116 | else |
Anton Hansson | 66d47b8 | 2018-04-27 14:11:17 +0100 | [diff] [blame] | 117 | aidl_preprocess_import := $(call resolve-prebuilt-sdk-aidl-path,$(LOCAL_SDK_VERSION)) |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 118 | endif # not current or system_current |
| 119 | else |
| 120 | # build against the platform. |
| 121 | LOCAL_AIDL_INCLUDES += $(FRAMEWORKS_BASE_JAVA_SRC_DIRS) |
| 122 | endif # LOCAL_SDK_VERSION |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 123 | |
Christopher Wiley | d9205ba | 2016-06-23 16:44:47 -0700 | [diff] [blame] | 124 | $(foreach s,$(aidl_sources),\ |
Dan Willemsen | 4d99527 | 2017-09-29 17:37:31 -0700 | [diff] [blame] | 125 | $(eval $(call define-aidl-java-rule,$(s),$(intermediates.COMMON)/aidl,aidl_java_sources))) |
Shinichiro Hamaji | 2a0d1fe | 2016-01-28 16:10:00 +0900 | [diff] [blame] | 126 | $(foreach java,$(aidl_java_sources), \ |
| 127 | $(call include-depfile,$(java:%.java=%.P),$(java))) |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 128 | |
Christopher Wiley | d9205ba | 2016-06-23 16:44:47 -0700 | [diff] [blame] | 129 | $(aidl_java_sources) : $(LOCAL_ADDITIONAL_DEPENDENCIES) $(aidl_preprocess_import) |
| 130 | |
| 131 | $(aidl_java_sources): PRIVATE_AIDL_FLAGS := -b $(addprefix -p,$(aidl_preprocess_import)) -I$(LOCAL_PATH) -I$(LOCAL_PATH)/src $(addprefix -I,$(LOCAL_AIDL_INCLUDES)) |
Christopher Wiley | dc9e267 | 2016-06-24 13:13:52 -0700 | [diff] [blame] | 132 | $(aidl_java_sources): PRIVATE_MODULE := $(LOCAL_MODULE) |
Christopher Wiley | d9205ba | 2016-06-23 16:44:47 -0700 | [diff] [blame] | 133 | |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 134 | endif |
| 135 | |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 136 | ########################################## |
| 137 | |
Ying Wang | 1d977e3 | 2013-01-30 11:22:06 -0800 | [diff] [blame] | 138 | # All of the rules after full_classes_compiled_jar are very unlikely |
| 139 | # to fail except for bugs in their respective tools. If you would |
| 140 | # like to run these rules, add the "all" modifier goal to the make |
| 141 | # command line. |
Ying Wang | 447d696 | 2015-09-01 19:12:05 -0700 | [diff] [blame] | 142 | ifndef LOCAL_CHECKED_MODULE |
Jean-Philippe Lesot | 0fbc9ff | 2015-01-20 14:18:48 +0000 | [diff] [blame] | 143 | ifdef full_classes_jar |
Colin Cross | b17f285 | 2017-04-27 13:34:02 -0700 | [diff] [blame] | 144 | LOCAL_CHECKED_MODULE := $(full_classes_compiled_jar) |
Ying Wang | 990cf5e | 2013-08-28 13:04:46 -0700 | [diff] [blame] | 145 | endif |
Yohann Roussel | ee57268 | 2015-08-18 19:18:18 +0200 | [diff] [blame] | 146 | endif |
Ying Wang | 1d977e3 | 2013-01-30 11:22:06 -0800 | [diff] [blame] | 147 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 148 | ####################################### |
| 149 | include $(BUILD_SYSTEM)/base_rules.mk |
| 150 | ####################################### |
| 151 | |
Yasuhiro Matsuda | ff82e82 | 2015-09-04 16:23:49 +0900 | [diff] [blame] | 152 | ########################################################### |
| 153 | ## logtags: emit java source |
| 154 | ########################################################### |
| 155 | ifneq ($(strip $(logtags_sources)),) |
| 156 | |
Dan Willemsen | 4d99527 | 2017-09-29 17:37:31 -0700 | [diff] [blame] | 157 | logtags_java_sources := $(patsubst %.logtags,%.java,$(addprefix $(intermediates.COMMON)/logtags/, $(logtags_sources))) |
Yasuhiro Matsuda | ff82e82 | 2015-09-04 16:23:49 +0900 | [diff] [blame] | 158 | logtags_sources := $(addprefix $(LOCAL_PATH)/, $(logtags_sources)) |
| 159 | |
Shinichiro Hamaji | d3ce14c | 2016-03-29 03:29:21 +0900 | [diff] [blame] | 160 | $(logtags_java_sources): PRIVATE_MERGED_TAG := $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt |
Colin Cross | fdea893 | 2017-12-06 14:38:40 -0800 | [diff] [blame] | 161 | $(logtags_java_sources): $(intermediates.COMMON)/logtags/%.java: $(LOCAL_PATH)/%.logtags $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt $(JAVATAGS) build/make/tools/event_log_tags.py |
Yasuhiro Matsuda | ff82e82 | 2015-09-04 16:23:49 +0900 | [diff] [blame] | 162 | $(transform-logtags-to-java) |
| 163 | |
| 164 | else |
| 165 | logtags_java_sources := |
| 166 | endif |
| 167 | |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 168 | ########################################## |
| 169 | java_sources := $(addprefix $(LOCAL_PATH)/, $(filter %.java,$(LOCAL_SRC_FILES))) $(aidl_java_sources) $(logtags_java_sources) \ |
| 170 | $(filter %.java,$(LOCAL_GENERATED_SOURCES)) |
Nan Zhang | ad818dc | 2017-10-04 09:26:06 -0700 | [diff] [blame] | 171 | java_intermediate_sources := $(addprefix $(TARGET_OUT_COMMON_INTERMEDIATES)/, $(filter %.java,$(LOCAL_INTERMEDIATE_SOURCES))) |
| 172 | all_java_sources := $(java_sources) $(java_intermediate_sources) |
| 173 | |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 174 | include $(BUILD_SYSTEM)/java_common.mk |
| 175 | |
Anton Hansson | 7ff32d2 | 2018-02-21 15:29:44 +0000 | [diff] [blame] | 176 | include $(BUILD_SYSTEM)/sdk_check.mk |
| 177 | |
Narayan Kamath | bbcdc07 | 2017-08-22 15:47:08 +0100 | [diff] [blame] | 178 | # Set the profile source so that the odex / profile code included from java.mk |
| 179 | # can find it. |
| 180 | # |
| 181 | # TODO: b/64896089, this is broken when called from package_internal.mk, since the file |
| 182 | # we preopt from is a temporary file. This will be addressed in a follow up, possibly |
| 183 | # by disabling stripping for profile guided preopt (which may be desirable for other |
| 184 | # reasons anyway). |
| 185 | # |
| 186 | # Note that we set this only when called from package_internal.mk and not in other cases. |
| 187 | ifneq (,$(called_from_package_internal) |
| 188 | dex_preopt_profile_src_file := $(LOCAL_BUILT_MODULE) |
| 189 | endif |
| 190 | |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 191 | ####################################### |
| 192 | # defines built_odex along with rule to install odex |
| 193 | include $(BUILD_SYSTEM)/dex_preopt_odex_install.mk |
| 194 | ####################################### |
| 195 | |
Ying Wang | 990cf5e | 2013-08-28 13:04:46 -0700 | [diff] [blame] | 196 | # Make sure there's something to build. |
| 197 | ifdef full_classes_jar |
| 198 | ifndef need_compile_java |
Jeff Gaston | 960acf1 | 2018-02-26 21:00:25 -0500 | [diff] [blame] | 199 | $(call pretty-error,Target java module does not define any source or resource files) |
Ying Wang | 990cf5e | 2013-08-28 13:04:46 -0700 | [diff] [blame] | 200 | endif |
| 201 | endif |
| 202 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 203 | # Since we're using intermediates.COMMON, make sure that it gets cleaned |
| 204 | # properly. |
| 205 | $(cleantarget): PRIVATE_CLEAN_FILES += $(intermediates.COMMON) |
| 206 | |
Ying Wang | 990cf5e | 2013-08-28 13:04:46 -0700 | [diff] [blame] | 207 | ifdef full_classes_jar |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 208 | |
Joe Onorato | 64d85d0 | 2009-04-09 19:31:12 -0700 | [diff] [blame] | 209 | # Droiddoc isn't currently able to generate stubs for modules, so we're just |
| 210 | # allowing it to use the classes.jar as the "stubs" that would be use to link |
| 211 | # against, for the cases where someone needs the jar to link against. |
Colin Cross | 0e53734 | 2017-03-29 12:17:36 -0700 | [diff] [blame] | 212 | $(eval $(call copy-one-file,$(full_classes_jar),$(full_classes_stubs_jar))) |
Joe Onorato | 64d85d0 | 2009-04-09 19:31:12 -0700 | [diff] [blame] | 213 | ALL_MODULES.$(LOCAL_MODULE).STUBS := $(full_classes_stubs_jar) |
| 214 | |
Joe Onorato | 0eccce9 | 2011-10-30 21:37:35 -0700 | [diff] [blame] | 215 | # The layers file allows you to enforce a layering between java packages. |
Colin Cross | fdea893 | 2017-12-06 14:38:40 -0800 | [diff] [blame] | 216 | # Run build/make/tools/java-layers.py for more details. |
Joe Onorato | 0eccce9 | 2011-10-30 21:37:35 -0700 | [diff] [blame] | 217 | layers_file := $(addprefix $(LOCAL_PATH)/, $(LOCAL_JAVA_LAYERS_FILE)) |
| 218 | $(full_classes_compiled_jar): PRIVATE_JAVA_LAYERS_FILE := $(layers_file) |
Ying Wang | 057eba0 | 2012-10-18 10:54:49 -0700 | [diff] [blame] | 219 | $(full_classes_compiled_jar): PRIVATE_WARNINGS_ENABLE := $(LOCAL_WARNINGS_ENABLE) |
Joe Onorato | 0eccce9 | 2011-10-30 21:37:35 -0700 | [diff] [blame] | 220 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 221 | # Compile the java files to a .jar file. |
| 222 | # This intentionally depends on java_sources, not all_java_sources. |
| 223 | # Deps for generated source files must be handled separately, |
| 224 | # via deps on the target that generates the sources. |
Paul Duffin | 3ca9298 | 2016-09-20 15:12:30 +0100 | [diff] [blame] | 225 | |
Przemyslaw Szczepaniak | 2e81b3c | 2017-06-30 14:51:12 +0100 | [diff] [blame] | 226 | # For user / userdebug builds, strip the local variable table and the local variable |
| 227 | # type table. This has no bearing on stack traces, but will leave less information |
| 228 | # available via JDWP. |
| 229 | ifneq (,$(PRODUCT_MINIMIZE_JAVA_DEBUG_INFO)) |
| 230 | ifneq (,$(filter userdebug user,$(TARGET_BUILD_VARIANT))) |
| 231 | LOCAL_JAVACFLAGS+= -g:source,lines |
Przemyslaw Szczepaniak | 2e81b3c | 2017-06-30 14:51:12 +0100 | [diff] [blame] | 232 | endif |
| 233 | endif |
| 234 | |
Colin Cross | dfc45ec | 2017-05-26 15:22:02 -0700 | [diff] [blame] | 235 | # List of dependencies for anything that needs all java sources in place |
| 236 | java_sources_deps := \ |
| 237 | $(java_sources) \ |
| 238 | $(java_resource_sources) \ |
Colin Cross | dfc45ec | 2017-05-26 15:22:02 -0700 | [diff] [blame] | 239 | $(proto_java_sources_file_stamp) \ |
Colin Cross | 11e2d55 | 2018-03-07 15:44:54 -0800 | [diff] [blame] | 240 | $(LOCAL_SRCJARS) \ |
Colin Cross | dfc45ec | 2017-05-26 15:22:02 -0700 | [diff] [blame] | 241 | $(LOCAL_ADDITIONAL_DEPENDENCIES) |
| 242 | |
| 243 | $(java_source_list_file): $(java_sources_deps) |
| 244 | $(write-java-source-list) |
| 245 | |
Colin Cross | 7dc9043 | 2017-09-26 16:17:24 -0700 | [diff] [blame] | 246 | ifneq ($(TURBINE_ENABLED),false) |
| 247 | |
Nan Zhang | b3ec534 | 2017-08-31 21:43:04 +0000 | [diff] [blame] | 248 | $(full_classes_turbine_jar): PRIVATE_JAVACFLAGS := $(LOCAL_JAVACFLAGS) $(annotation_processor_flags) |
Colin Cross | 11e2d55 | 2018-03-07 15:44:54 -0800 | [diff] [blame] | 249 | $(full_classes_turbine_jar): PRIVATE_SRCJARS := $(LOCAL_SRCJARS) |
Nan Zhang | b3ec534 | 2017-08-31 21:43:04 +0000 | [diff] [blame] | 250 | $(full_classes_turbine_jar): PRIVATE_DONT_DELETE_JAR_META_INF := $(LOCAL_DONT_DELETE_JAR_META_INF) |
| 251 | $(full_classes_turbine_jar): \ |
| 252 | $(java_source_list_file) \ |
| 253 | $(java_sources_deps) \ |
| 254 | $(full_java_header_libs) \ |
Colin Cross | 1d1e5ef | 2017-09-23 18:19:05 -0700 | [diff] [blame] | 255 | $(full_java_bootclasspath_libs) \ |
Colin Cross | f960257 | 2017-10-12 13:34:40 -0700 | [diff] [blame] | 256 | $(full_java_system_modules_deps) \ |
Nan Zhang | b3ec534 | 2017-08-31 21:43:04 +0000 | [diff] [blame] | 257 | $(NORMALIZE_PATH) \ |
| 258 | $(JAR_ARGS) \ |
| 259 | $(ZIPTIME) \ |
Nan Zhang | 9bd5405 | 2017-09-13 13:13:53 -0700 | [diff] [blame] | 260 | | $(TURBINE) \ |
| 261 | $(MERGE_ZIPS) |
Nan Zhang | b3ec534 | 2017-08-31 21:43:04 +0000 | [diff] [blame] | 262 | $(transform-java-to-header.jar) |
| 263 | |
| 264 | .KATI_RESTAT: $(full_classes_turbine_jar) |
| 265 | |
| 266 | # Run jarjar before generate classes-header.jar if necessary. |
| 267 | ifneq ($(strip $(LOCAL_JARJAR_RULES)),) |
| 268 | $(full_classes_header_jarjar): PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES) |
| 269 | $(full_classes_header_jarjar): $(full_classes_turbine_jar) $(LOCAL_JARJAR_RULES) | $(JARJAR) |
| 270 | @echo Header JarJar: $@ |
| 271 | $(hide) $(JAVA) -jar $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@ |
| 272 | else |
| 273 | full_classes_header_jarjar := $(full_classes_turbine_jar) |
| 274 | endif |
| 275 | |
| 276 | $(eval $(call copy-one-file,$(full_classes_header_jarjar),$(full_classes_header_jar))) |
| 277 | |
Colin Cross | 7dc9043 | 2017-09-26 16:17:24 -0700 | [diff] [blame] | 278 | endif # TURBINE_ENABLED != false |
| 279 | |
Colin Cross | 5ef6e79 | 2018-03-07 14:16:43 -0800 | [diff] [blame] | 280 | $(full_classes_compiled_jar): PRIVATE_JAVACFLAGS := $(LOCAL_JAVACFLAGS) $(annotation_processor_flags) |
| 281 | $(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_FILES := $(LOCAL_JAR_EXCLUDE_FILES) |
| 282 | $(full_classes_compiled_jar): PRIVATE_JAR_PACKAGES := $(LOCAL_JAR_PACKAGES) |
| 283 | $(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_PACKAGES := $(LOCAL_JAR_EXCLUDE_PACKAGES) |
| 284 | $(full_classes_compiled_jar): PRIVATE_DONT_DELETE_JAR_META_INF := $(LOCAL_DONT_DELETE_JAR_META_INF) |
| 285 | $(full_classes_compiled_jar): PRIVATE_JAVA_SOURCE_LIST := $(java_source_list_file) |
| 286 | $(full_classes_compiled_jar): PRIVATE_ALL_JAVA_HEADER_LIBRARIES := $(full_java_header_libs) |
Colin Cross | 11e2d55 | 2018-03-07 15:44:54 -0800 | [diff] [blame] | 287 | $(full_classes_compiled_jar): PRIVATE_SRCJARS := $(LOCAL_SRCJARS) |
| 288 | $(full_classes_compiled_jar): PRIVATE_SRCJAR_LIST_FILE := $(intermediates.COMMON)/srcjar-list |
| 289 | $(full_classes_compiled_jar): PRIVATE_SRCJAR_INTERMEDIATES_DIR := $(intermediates.COMMON)/srcjars |
Colin Cross | 5ef6e79 | 2018-03-07 14:16:43 -0800 | [diff] [blame] | 290 | $(full_classes_compiled_jar): \ |
| 291 | $(java_source_list_file) \ |
| 292 | $(full_java_header_libs) \ |
| 293 | $(java_sources_deps) \ |
| 294 | $(full_java_bootclasspath_libs) \ |
| 295 | $(full_java_system_modules_deps) \ |
| 296 | $(layers_file) \ |
| 297 | $(annotation_processor_deps) \ |
| 298 | $(NORMALIZE_PATH) \ |
| 299 | $(JAR_ARGS) \ |
Colin Cross | 3f99cd5 | 2018-03-15 16:26:08 -0700 | [diff] [blame] | 300 | $(ZIPSYNC) \ |
Colin Cross | 5ef6e79 | 2018-03-07 14:16:43 -0800 | [diff] [blame] | 301 | | $(SOONG_JAVAC_WRAPPER) |
| 302 | @echo "Target Java: $@ |
| 303 | $(call compile-java,$(TARGET_JAVAC),$(PRIVATE_ALL_JAVA_HEADER_LIBRARIES)) |
| 304 | |
Ying Wang | cddeb6c | 2016-03-24 11:00:30 -0700 | [diff] [blame] | 305 | javac-check : $(full_classes_compiled_jar) |
Paul Duffin | 32bd0ad | 2016-09-15 14:34:42 +0100 | [diff] [blame] | 306 | javac-check-$(LOCAL_MODULE) : $(full_classes_compiled_jar) |
Dan Willemsen | 7a1da0e | 2018-07-24 01:21:12 -0700 | [diff] [blame] | 307 | .PHONY: javac-check-$(LOCAL_MODULE) |
Ying Wang | cddeb6c | 2016-03-24 11:00:30 -0700 | [diff] [blame] | 308 | |
Nan Zhang | 9bd5405 | 2017-09-13 13:13:53 -0700 | [diff] [blame] | 309 | $(full_classes_combined_jar): PRIVATE_DONT_DELETE_JAR_META_INF := $(LOCAL_DONT_DELETE_JAR_META_INF) |
| 310 | $(full_classes_combined_jar): $(full_classes_compiled_jar) \ |
Nan Zhang | b880117 | 2017-09-20 14:56:48 -0700 | [diff] [blame] | 311 | $(jar_manifest_file) \ |
Nan Zhang | 9bd5405 | 2017-09-13 13:13:53 -0700 | [diff] [blame] | 312 | $(full_static_java_libs) | $(MERGE_ZIPS) |
Nan Zhang | b880117 | 2017-09-20 14:56:48 -0700 | [diff] [blame] | 313 | $(if $(PRIVATE_JAR_MANIFEST), $(hide) sed -e "s/%BUILD_NUMBER%/$(BUILD_NUMBER_FROM_FILE)/" \ |
| 314 | $(PRIVATE_JAR_MANIFEST) > $(dir $@)/manifest.mf) |
Colin Cross | 5b73ab3 | 2018-02-14 10:32:48 -0800 | [diff] [blame] | 315 | $(MERGE_ZIPS) -j --ignore-duplicates $(if $(PRIVATE_JAR_MANIFEST),-m $(dir $@)/manifest.mf) \ |
Nan Zhang | b880117 | 2017-09-20 14:56:48 -0700 | [diff] [blame] | 316 | $(if $(PRIVATE_DONT_DELETE_JAR_META_INF),,-stripDir META-INF -zipToNotStrip $<) \ |
| 317 | $@ $< $(call reverse-list,$(PRIVATE_STATIC_JAVA_LIBRARIES)) |
Nan Zhang | 9bd5405 | 2017-09-13 13:13:53 -0700 | [diff] [blame] | 318 | |
Colin Cross | f8a49c5 | 2017-05-22 16:21:49 -0700 | [diff] [blame] | 319 | ifdef LOCAL_JAR_PROCESSOR |
| 320 | # LOCAL_JAR_PROCESSOR_ARGS must be evaluated here to set up the rule-local |
| 321 | # PRIVATE_JAR_PROCESSOR_ARGS variable, but $< and $@ are not available yet. |
| 322 | # Set ${in} and ${out} so they can be referenced by LOCAL_JAR_PROCESSOR_ARGS |
| 323 | # using deferred evaluation (LOCAL_JAR_PROCESSOR_ARGS = instead of :=). |
Nan Zhang | 9bd5405 | 2017-09-13 13:13:53 -0700 | [diff] [blame] | 324 | in := $(full_classes_combined_jar) |
Colin Cross | f8a49c5 | 2017-05-22 16:21:49 -0700 | [diff] [blame] | 325 | out := $(full_classes_processed_jar).tmp |
Colin Cross | 89b802b | 2017-07-13 19:25:47 -0700 | [diff] [blame] | 326 | my_jar_processor := $(HOST_OUT_JAVA_LIBRARIES)/$(LOCAL_JAR_PROCESSOR).jar |
| 327 | |
Colin Cross | f8a49c5 | 2017-05-22 16:21:49 -0700 | [diff] [blame] | 328 | $(full_classes_processed_jar): PRIVATE_JAR_PROCESSOR_ARGS := $(LOCAL_JAR_PROCESSOR_ARGS) |
Colin Cross | 89b802b | 2017-07-13 19:25:47 -0700 | [diff] [blame] | 329 | $(full_classes_processed_jar): PRIVATE_JAR_PROCESSOR := $(my_jar_processor) |
Colin Cross | f8a49c5 | 2017-05-22 16:21:49 -0700 | [diff] [blame] | 330 | $(full_classes_processed_jar): PRIVATE_TMP_OUT := $(out) |
| 331 | in := |
| 332 | out := |
| 333 | |
Nan Zhang | 9bd5405 | 2017-09-13 13:13:53 -0700 | [diff] [blame] | 334 | $(full_classes_processed_jar): $(full_classes_combined_jar) $(my_jar_processor) |
Colin Cross | f8a49c5 | 2017-05-22 16:21:49 -0700 | [diff] [blame] | 335 | @echo Processing $@ with $(PRIVATE_JAR_PROCESSOR) |
| 336 | $(hide) rm -f $@ $(PRIVATE_TMP_OUT) |
Colin Cross | 0851df8 | 2017-06-30 13:55:38 -0700 | [diff] [blame] | 337 | $(hide) $(JAVA) -jar $(PRIVATE_JAR_PROCESSOR) $(PRIVATE_JAR_PROCESSOR_ARGS) |
Colin Cross | f8a49c5 | 2017-05-22 16:21:49 -0700 | [diff] [blame] | 338 | $(hide) mv $(PRIVATE_TMP_OUT) $@ |
| 339 | |
Colin Cross | 89b802b | 2017-07-13 19:25:47 -0700 | [diff] [blame] | 340 | my_jar_processor := |
Colin Cross | f8a49c5 | 2017-05-22 16:21:49 -0700 | [diff] [blame] | 341 | else |
Nan Zhang | 9bd5405 | 2017-09-13 13:13:53 -0700 | [diff] [blame] | 342 | full_classes_processed_jar := $(full_classes_combined_jar) |
Colin Cross | f8a49c5 | 2017-05-22 16:21:49 -0700 | [diff] [blame] | 343 | endif |
| 344 | |
Nan Zhang | 870025f | 2017-09-13 14:56:11 -0700 | [diff] [blame] | 345 | # Run jarjar if necessary |
| 346 | ifneq ($(strip $(LOCAL_JARJAR_RULES)),) |
| 347 | $(full_classes_jarjar_jar): PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES) |
| 348 | $(full_classes_jarjar_jar): $(full_classes_processed_jar) $(LOCAL_JARJAR_RULES) | $(JARJAR) |
| 349 | @echo JarJar: $@ |
| 350 | $(hide) $(JAVA) -jar $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@ |
| 351 | else |
| 352 | full_classes_jarjar_jar := $(full_classes_processed_jar) |
| 353 | endif |
| 354 | |
Jeff Gaston | db6557e | 2018-02-27 14:05:40 -0500 | [diff] [blame] | 355 | $(eval $(call copy-one-file,$(full_classes_jarjar_jar),$(full_classes_jar))) |
Colin Cross | 9687348 | 2017-12-22 16:51:23 -0800 | [diff] [blame] | 356 | |
| 357 | ####################################### |
Jeff Gaston | d2ba724 | 2018-01-31 17:34:07 -0500 | [diff] [blame] | 358 | LOCAL_FULL_CLASSES_PRE_JACOCO_JAR := $(full_classes_jar) |
| 359 | |
Colin Cross | 9687348 | 2017-12-22 16:51:23 -0800 | [diff] [blame] | 360 | include $(BUILD_SYSTEM)/jacoco.mk |
| 361 | ####################################### |
| 362 | |
Tobias Thierer | 7ef760b | 2017-11-17 13:02:12 +0000 | [diff] [blame] | 363 | # Temporarily enable --multi-dex until proguard supports v53 class files |
| 364 | # ( http://b/67673860 ) or we move away from proguard altogether. |
Tobias Thierer | f6bd495 | 2017-11-15 20:55:03 +0000 | [diff] [blame] | 365 | ifdef TARGET_OPENJDK9 |
Tobias Thierer | 8974066 | 2017-10-25 02:38:01 +0100 | [diff] [blame] | 366 | LOCAL_DX_FLAGS := $(filter-out --multi-dex,$(LOCAL_DX_FLAGS)) --multi-dex |
| 367 | endif |
| 368 | |
Colin Cross | cf01085 | 2018-06-06 21:46:25 +0000 | [diff] [blame] | 369 | full_classes_pre_proguard_jar := $(LOCAL_FULL_CLASSES_JACOCO_JAR) |
Ying Wang | 3b2bdf1 | 2010-02-01 09:51:23 -0800 | [diff] [blame] | 370 | |
Colin Cross | 950f1ef | 2017-04-05 15:30:42 -0700 | [diff] [blame] | 371 | # Keep a copy of the jar just before proguard processing. |
| 372 | $(eval $(call copy-one-file,$(full_classes_pre_proguard_jar),$(intermediates.COMMON)/classes-pre-proguard.jar)) |
Shinichiro Hamaji | 89b255a | 2015-11-09 16:47:42 +0900 | [diff] [blame] | 373 | |
Colin Cross | 0e53734 | 2017-03-29 12:17:36 -0700 | [diff] [blame] | 374 | # Run proguard if necessary |
Ying Wang | 7311a34 | 2013-08-21 18:32:49 -0700 | [diff] [blame] | 375 | ifdef LOCAL_PROGUARD_ENABLED |
Colin Cross | e616f34 | 2017-12-28 09:43:41 -0800 | [diff] [blame] | 376 | ifneq ($(filter-out full custom obfuscation optimization,$(LOCAL_PROGUARD_ENABLED)),) |
Ying Wang | 7311a34 | 2013-08-21 18:32:49 -0700 | [diff] [blame] | 377 | $(warning while processing: $(LOCAL_MODULE)) |
| 378 | $(error invalid value for LOCAL_PROGUARD_ENABLED: $(LOCAL_PROGUARD_ENABLED)) |
| 379 | endif |
Joe Onorato | 2daa2b3 | 2009-08-30 13:39:24 -0700 | [diff] [blame] | 380 | proguard_dictionary := $(intermediates.COMMON)/proguard_dictionary |
Søren Gjesse | 9fbdd9e | 2018-04-13 15:34:20 +0200 | [diff] [blame] | 381 | proguard_configuration := $(intermediates.COMMON)/proguard_configuration |
Ying Wang | 4f5d0e6 | 2015-05-04 19:21:48 -0700 | [diff] [blame] | 382 | |
Colin Cross | b5f25a2 | 2017-10-20 19:16:41 -0700 | [diff] [blame] | 383 | # When an app contains references to APIs that are not in the SDK specified by |
Anton Hansson | 400673c | 2018-04-10 16:16:33 +0100 | [diff] [blame] | 384 | # its LOCAL_SDK_VERSION for example added by support library or by runtime |
Colin Cross | b5f25a2 | 2017-10-20 19:16:41 -0700 | [diff] [blame] | 385 | # classes added by desugar, we artifically raise the "SDK version" "linked" by |
| 386 | # ProGuard, to |
Ying Wang | 4f5d0e6 | 2015-05-04 19:21:48 -0700 | [diff] [blame] | 387 | # - suppress ProGuard warnings of referencing symbols unknown to the lower SDK version. |
| 388 | # - prevent ProGuard stripping subclass in the support library that extends class added in the higher SDK version. |
Colin Cross | b5f25a2 | 2017-10-20 19:16:41 -0700 | [diff] [blame] | 389 | # See b/20667396 |
| 390 | my_proguard_sdk_raise := |
Ying Wang | 4f5d0e6 | 2015-05-04 19:21:48 -0700 | [diff] [blame] | 391 | ifdef LOCAL_SDK_VERSION |
Ying Wang | 4f5d0e6 | 2015-05-04 19:21:48 -0700 | [diff] [blame] | 392 | ifdef TARGET_BUILD_APPS |
Jiyong Park | 5ebca30 | 2018-01-31 00:14:55 +0900 | [diff] [blame] | 393 | ifeq (,$(filter current system_current test_current core_current, $(LOCAL_SDK_VERSION))) |
Anton Hansson | 400673c | 2018-04-10 16:16:33 +0100 | [diff] [blame] | 394 | my_proguard_sdk_raise := $(call java-lib-header-files, $(call resolve-prebuilt-sdk-module,current)) |
Ying Wang | 742f583 | 2015-06-26 12:33:06 -0700 | [diff] [blame] | 395 | endif |
Ying Wang | 4f5d0e6 | 2015-05-04 19:21:48 -0700 | [diff] [blame] | 396 | else |
| 397 | # For platform build, we can't just raise to the "current" SDK, |
| 398 | # that would break apps that use APIs removed from the current SDK. |
Colin Cross | b5f25a2 | 2017-10-20 19:16:41 -0700 | [diff] [blame] | 399 | my_proguard_sdk_raise := $(call java-lib-header-files,$(TARGET_DEFAULT_BOOTCLASSPATH_LIBRARIES) $(TARGET_DEFAULT_JAVA_LIBRARIES)) |
Ying Wang | 4f5d0e6 | 2015-05-04 19:21:48 -0700 | [diff] [blame] | 400 | endif |
| 401 | endif |
Ying Wang | 4f5d0e6 | 2015-05-04 19:21:48 -0700 | [diff] [blame] | 402 | |
Colin Cross | 3ebfe73 | 2018-07-25 13:41:42 -0700 | [diff] [blame] | 403 | legacy_proguard_flags := $(addprefix -libraryjars ,$(my_proguard_sdk_raise) \ |
Colin Cross | b5f25a2 | 2017-10-20 19:16:41 -0700 | [diff] [blame] | 404 | $(filter-out $(my_proguard_sdk_raise), \ |
Colin Cross | b541aae | 2017-09-23 19:52:43 -0700 | [diff] [blame] | 405 | $(full_java_bootclasspath_libs) \ |
| 406 | $(full_shared_java_header_libs))) |
Nan Zhang | b3ec534 | 2017-08-31 21:43:04 +0000 | [diff] [blame] | 407 | |
Colin Cross | b5f25a2 | 2017-10-20 19:16:41 -0700 | [diff] [blame] | 408 | legacy_proguard_lib_deps := $(my_proguard_sdk_raise) \ |
| 409 | $(filter-out $(my_proguard_sdk_raise),$(full_shared_java_header_libs)) |
Yohann Roussel | b7de0fb | 2015-11-03 18:33:21 +0100 | [diff] [blame] | 410 | |
| 411 | legacy_proguard_flags += -printmapping $(proguard_dictionary) |
Søren Gjesse | 9fbdd9e | 2018-04-13 15:34:20 +0200 | [diff] [blame] | 412 | legacy_proguard_flags += -printconfiguration $(proguard_configuration) |
Yohann Roussel | b7de0fb | 2015-11-03 18:33:21 +0100 | [diff] [blame] | 413 | |
| 414 | common_proguard_flags := -forceprocessing |
Ying Wang | 7311a34 | 2013-08-21 18:32:49 -0700 | [diff] [blame] | 415 | |
Colin Cross | e616f34 | 2017-12-28 09:43:41 -0800 | [diff] [blame] | 416 | common_proguard_flag_files := $(BUILD_SYSTEM)/proguard.flags |
Ying Wang | 7311a34 | 2013-08-21 18:32:49 -0700 | [diff] [blame] | 417 | ifneq ($(LOCAL_INSTRUMENTATION_FOR)$(filter tests,$(LOCAL_MODULE_TAGS)),) |
Yohann Roussel | b4c49cb | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 418 | common_proguard_flags += -dontshrink # don't shrink tests by default |
Ying Wang | 3b2bdf1 | 2010-02-01 09:51:23 -0800 | [diff] [blame] | 419 | endif # test package |
Dan Willemsen | 1417c17 | 2017-11-17 13:11:26 -0800 | [diff] [blame] | 420 | ifneq ($(LOCAL_PROGUARD_ENABLED),custom) |
Colin Cross | 2029903 | 2018-05-09 13:29:51 -0700 | [diff] [blame] | 421 | ifeq ($(LOCAL_USE_AAPT2),true) |
Dan Willemsen | 1417c17 | 2017-11-17 13:11:26 -0800 | [diff] [blame] | 422 | common_proguard_flag_files += $(foreach l,$(LOCAL_STATIC_ANDROID_LIBRARIES),\ |
| 423 | $(call intermediates-dir-for,JAVA_LIBRARIES,$(l),,COMMON)/export_proguard_flags) |
| 424 | endif |
| 425 | endif |
Shinichiro Hamaji | 4eaeef8 | 2016-04-07 18:56:42 +0900 | [diff] [blame] | 426 | ifneq ($(common_proguard_flag_files),) |
| 427 | common_proguard_flags += $(addprefix -include , $(common_proguard_flag_files)) |
| 428 | # This is included from $(BUILD_SYSTEM)/proguard.flags |
| 429 | common_proguard_flag_files += $(BUILD_SYSTEM)/proguard_basic_keeps.flags |
| 430 | endif |
| 431 | |
Ying Wang | 7311a34 | 2013-08-21 18:32:49 -0700 | [diff] [blame] | 432 | ifeq ($(filter obfuscation,$(LOCAL_PROGUARD_ENABLED)),) |
| 433 | # By default no obfuscation |
Yohann Roussel | b4c49cb | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 434 | common_proguard_flags += -dontobfuscate |
Ying Wang | 7311a34 | 2013-08-21 18:32:49 -0700 | [diff] [blame] | 435 | endif # No obfuscation |
| 436 | ifeq ($(filter optimization,$(LOCAL_PROGUARD_ENABLED)),) |
| 437 | # By default no optimization |
Yohann Roussel | b4c49cb | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 438 | common_proguard_flags += -dontoptimize |
Ying Wang | 7311a34 | 2013-08-21 18:32:49 -0700 | [diff] [blame] | 439 | endif # No optimization |
Ying Wang | 3b2bdf1 | 2010-02-01 09:51:23 -0800 | [diff] [blame] | 440 | |
Ying Wang | 7311a34 | 2013-08-21 18:32:49 -0700 | [diff] [blame] | 441 | ifdef LOCAL_INSTRUMENTATION_FOR |
| 442 | ifeq ($(filter obfuscation,$(LOCAL_PROGUARD_ENABLED)),) |
| 443 | # If no obfuscation, link in the instrmented package's classes.jar as a library. |
| 444 | # link_instr_classes_jar is defined in base_rule.mk |
Yohann Roussel | b4c49cb | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 445 | legacy_proguard_flags += -libraryjars $(link_instr_classes_jar) |
Nan Zhang | b3ec534 | 2017-08-31 21:43:04 +0000 | [diff] [blame] | 446 | legacy_proguard_lib_deps += $(link_instr_classes_jar) |
Ying Wang | 7311a34 | 2013-08-21 18:32:49 -0700 | [diff] [blame] | 447 | else # obfuscation |
| 448 | # If obfuscation is enabled, the main app must be obfuscated too. |
| 449 | # We need to run obfuscation using the main app's dictionary, |
| 450 | # and treat the main app's class.jar as injars instead of libraryjars. |
Yohann Roussel | b4c49cb | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 451 | legacy_proguard_flags := -injars $(link_instr_classes_jar) \ |
Ying Wang | 7311a34 | 2013-08-21 18:32:49 -0700 | [diff] [blame] | 452 | -outjars $(intermediates.COMMON)/proguard.$(LOCAL_INSTRUMENTATION_FOR).jar \ |
| 453 | -include $(link_instr_intermediates_dir.COMMON)/proguard_options \ |
| 454 | -applymapping $(link_instr_intermediates_dir.COMMON)/proguard_dictionary \ |
| 455 | -verbose \ |
Yohann Roussel | b4c49cb | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 456 | $(legacy_proguard_flags) |
Colin Cross | fcb441b | 2018-07-25 13:40:05 -0700 | [diff] [blame] | 457 | legacy_proguard_lib_deps += \ |
| 458 | $(link_instr_classes_jar) \ |
| 459 | $(link_instr_intermediates_dir.COMMON)/proguard_options \ |
| 460 | $(link_instr_intermediates_dir.COMMON)/proguard_dictionary \ |
Ying Wang | 7311a34 | 2013-08-21 18:32:49 -0700 | [diff] [blame] | 461 | |
| 462 | # Sometimes (test + main app) uses different keep rules from the main app - |
| 463 | # apply the main app's dictionary anyway. |
Yohann Roussel | b4c49cb | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 464 | legacy_proguard_flags += -ignorewarnings |
Ying Wang | 7311a34 | 2013-08-21 18:32:49 -0700 | [diff] [blame] | 465 | |
Ying Wang | 7311a34 | 2013-08-21 18:32:49 -0700 | [diff] [blame] | 466 | endif # no obfuscation |
| 467 | endif # LOCAL_INSTRUMENTATION_FOR |
Joe Onorato | 2daa2b3 | 2009-08-30 13:39:24 -0700 | [diff] [blame] | 468 | |
Ying Wang | 0b9382c | 2010-09-29 14:50:41 -0700 | [diff] [blame] | 469 | proguard_flag_files := $(addprefix $(LOCAL_PATH)/, $(LOCAL_PROGUARD_FLAG_FILES)) |
Søren Gjesse | 0c1fe64 | 2017-10-12 16:09:13 +0200 | [diff] [blame] | 470 | proguard_flag_files += $(addprefix $(LOCAL_PATH)/, $(LOCAL_R8_FLAG_FILES)) |
Ying Wang | 0b9382c | 2010-09-29 14:50:41 -0700 | [diff] [blame] | 471 | LOCAL_PROGUARD_FLAGS += $(addprefix -include , $(proguard_flag_files)) |
| 472 | |
Mihail Dumitrescu | 4df82b3 | 2014-02-07 15:18:59 +0000 | [diff] [blame] | 473 | ifdef LOCAL_TEST_MODULE_TO_PROGUARD_WITH |
| 474 | extra_input_jar := $(call intermediates-dir-for,APPS,$(LOCAL_TEST_MODULE_TO_PROGUARD_WITH),,COMMON)/classes.jar |
| 475 | else |
| 476 | extra_input_jar := |
| 477 | endif |
Paul Duffin | f22aca1 | 2017-02-21 13:11:13 +0000 | [diff] [blame] | 478 | |
Dan Willemsen | bdd6a75 | 2017-09-25 23:36:19 -0700 | [diff] [blame] | 479 | ifneq ($(filter obfuscation,$(LOCAL_PROGUARD_ENABLED)),) |
Søren Gjesse | 9fbdd9e | 2018-04-13 15:34:20 +0200 | [diff] [blame] | 480 | $(built_dex_intermediate): .KATI_IMPLICIT_OUTPUTS := $(proguard_dictionary) $(proguard_configuration) |
Søren Gjesse | 4ab5b02 | 2017-10-25 17:10:59 +0200 | [diff] [blame] | 481 | endif |
Ying Wang | 3b2bdf1 | 2010-02-01 09:51:23 -0800 | [diff] [blame] | 482 | |
Ying Wang | 7311a34 | 2013-08-21 18:32:49 -0700 | [diff] [blame] | 483 | else # LOCAL_PROGUARD_ENABLED not defined |
ShuJie Wang | 76e93ba | 2017-11-06 14:35:52 +0800 | [diff] [blame] | 484 | proguard_flag_files := |
Ying Wang | 7311a34 | 2013-08-21 18:32:49 -0700 | [diff] [blame] | 485 | endif # LOCAL_PROGUARD_ENABLED defined |
| 486 | |
Colin Cross | 96476c1 | 2017-04-06 09:56:19 -0700 | [diff] [blame] | 487 | ifneq ($(LOCAL_IS_STATIC_JAVA_LIBRARY),true) |
Colin Cross | 79e2f73 | 2016-12-21 14:29:13 -0800 | [diff] [blame] | 488 | $(built_dex_intermediate): PRIVATE_DX_FLAGS := $(LOCAL_DX_FLAGS) |
Søren Gjesse | 0c1fe64 | 2017-10-12 16:09:13 +0200 | [diff] [blame] | 489 | |
Søren Gjesse | 0c1fe64 | 2017-10-12 16:09:13 +0200 | [diff] [blame] | 490 | ifdef LOCAL_PROGUARD_ENABLED |
Colin Cross | 3ebfe73 | 2018-07-25 13:41:42 -0700 | [diff] [blame] | 491 | $(built_dex_intermediate): PRIVATE_EXTRA_INPUT_JAR := $(extra_input_jar) |
| 492 | $(built_dex_intermediate): PRIVATE_PROGUARD_FLAGS := $(legacy_proguard_flags) $(common_proguard_flags) $(LOCAL_PROGUARD_FLAGS) |
Søren Gjesse | b229343 | 2018-08-23 11:17:17 +0200 | [diff] [blame] | 493 | $(built_dex_intermediate): PRIVATE_PROGUARD_DICTIONARY := $(proguard_dictionary) |
Colin Cross | 3ebfe73 | 2018-07-25 13:41:42 -0700 | [diff] [blame] | 494 | $(built_dex_intermediate) : $(full_classes_pre_proguard_jar) $(extra_input_jar) $(my_proguard_sdk_raise) $(common_proguard_flag_files) $(proguard_flag_files) $(legacy_proguard_lib_deps) $(R8_COMPAT_PROGUARD) |
Søren Gjesse | 0c1fe64 | 2017-10-12 16:09:13 +0200 | [diff] [blame] | 495 | $(transform-jar-to-dex-r8) |
Colin Cross | 3ebfe73 | 2018-07-25 13:41:42 -0700 | [diff] [blame] | 496 | else # !LOCAL_PROGUARD_ENABLED |
Colin Cross | ec17af3 | 2018-09-21 12:36:53 -0700 | [diff] [blame^] | 497 | $(built_dex_intermediate): PRIVATE_D8_LIBS := $(full_java_bootclasspath_libs) $(full_shared_java_header_libs) |
| 498 | $(built_dex_intermediate): $(full_java_bootclasspath_libs) $(full_shared_java_header_libs) |
Colin Cross | 3ebfe73 | 2018-07-25 13:41:42 -0700 | [diff] [blame] | 499 | $(built_dex_intermediate): $(full_classes_pre_proguard_jar) $(DX) $(ZIP2ZIP) |
Colin Cross | 79e2f73 | 2016-12-21 14:29:13 -0800 | [diff] [blame] | 500 | $(transform-classes.jar-to-dex) |
Søren Gjesse | 0c1fe64 | 2017-10-12 16:09:13 +0200 | [diff] [blame] | 501 | endif |
Colin Cross | 79e2f73 | 2016-12-21 14:29:13 -0800 | [diff] [blame] | 502 | |
David Brazdil | b8fa6dd | 2018-01-29 14:43:14 +0000 | [diff] [blame] | 503 | ifneq ($(filter $(LOCAL_MODULE),$(PRODUCT_BOOT_JARS)),) # is_boot_jar |
Mathew Inwood | 04c58de | 2018-07-11 15:14:00 +0100 | [diff] [blame] | 504 | # Derive API greylist from the classes jar. |
Colin Cross | 3ebfe73 | 2018-07-25 13:41:42 -0700 | [diff] [blame] | 505 | # We use full_classes_pre_proguard_jar here, as that is what is converted to |
| 506 | # dex later on. The difference is academic currently, as we don't proguard any |
Mathew Inwood | 04c58de | 2018-07-11 15:14:00 +0100 | [diff] [blame] | 507 | # bootclasspath code at the moment. If we were to do that, we should add keep |
| 508 | # rules for all members with the @UnsupportedAppUsage annotation. |
Mathew Inwood | edb1c84 | 2018-09-07 14:14:36 +0100 | [diff] [blame] | 509 | $(eval $(call hiddenapi-generate-greylist-txt, $(full_classes_pre_proguard_jar),$(hiddenapi_whitelist_txt),$(hiddenapi_greylist_txt),$(hiddenapi_darkgreylist_txt))) |
| 510 | LOCAL_INTERMEDIATE_TARGETS += $(hiddenapi_whitelist_txt) $(hiddenapi_greylist_txt) $(hiddenapi_darkgreylist_txt) |
David Brazdil | b8fa6dd | 2018-01-29 14:43:14 +0000 | [diff] [blame] | 511 | $(eval $(call hiddenapi-copy-dex-files,$(built_dex_intermediate),$(built_dex_hiddenapi))) |
| 512 | built_dex_copy_from := $(built_dex_hiddenapi) |
| 513 | else # !is_boot_jar |
| 514 | built_dex_copy_from := $(built_dex_intermediate) |
| 515 | endif # is_boot_jar |
| 516 | |
| 517 | $(built_dex): $(built_dex_copy_from) |
Guang Zhu | 155afe3 | 2010-03-10 15:48:03 -0800 | [diff] [blame] | 518 | @echo Copying: $@ |
Yohann Roussel | 8ffe9c3 | 2013-08-20 17:05:27 +0200 | [diff] [blame] | 519 | $(hide) mkdir -p $(dir $@) |
| 520 | $(hide) rm -f $(dir $@)/classes*.dex |
Colin Cross | 0e53734 | 2017-03-29 12:17:36 -0700 | [diff] [blame] | 521 | $(hide) cp -fp $(dir $<)/classes*.dex $(dir $@) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 522 | |
Colin Cross | 9eff830 | 2017-04-27 15:05:44 -0700 | [diff] [blame] | 523 | java-dex: $(built_dex) |
| 524 | |
Colin Cross | 96476c1 | 2017-04-06 09:56:19 -0700 | [diff] [blame] | 525 | endif # !LOCAL_IS_STATIC_JAVA_LIBRARY |
| 526 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 527 | findbugs_xml := $(intermediates.COMMON)/findbugs.xml |
Ying Wang | 702e01e | 2015-10-21 10:30:51 -0700 | [diff] [blame] | 528 | $(findbugs_xml): PRIVATE_AUXCLASSPATH := $(addprefix -auxclasspath ,$(strip \ |
| 529 | $(call normalize-path-list,$(filter %.jar,$(full_java_libs))))) |
| 530 | $(findbugs_xml): PRIVATE_FINDBUGS_FLAGS := $(LOCAL_FINDBUGS_FLAGS) |
Colin Cross | 950f1ef | 2017-04-05 15:30:42 -0700 | [diff] [blame] | 531 | $(findbugs_xml) : $(full_classes_pre_proguard_jar) $(filter %.xml, $(LOCAL_FINDBUGS_FLAGS)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 532 | @echo Findbugs: $@ |
| 533 | $(hide) $(FINDBUGS) -textui -effort:min -xml:withMessages \ |
Ying Wang | 702e01e | 2015-10-21 10:30:51 -0700 | [diff] [blame] | 534 | $(PRIVATE_AUXCLASSPATH) $(PRIVATE_FINDBUGS_FLAGS) \ |
Yohann Roussel | d2a76c1 | 2015-02-05 16:10:58 +0100 | [diff] [blame] | 535 | $< \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 536 | > $@ |
| 537 | |
| 538 | ALL_FINDBUGS_FILES += $(findbugs_xml) |
| 539 | |
| 540 | findbugs_html := $(PRODUCT_OUT)/findbugs/$(LOCAL_MODULE).html |
| 541 | $(findbugs_html) : PRIVATE_XML_FILE := $(findbugs_xml) |
| 542 | $(LOCAL_MODULE)-findbugs : $(findbugs_html) |
Dan Willemsen | 7a1da0e | 2018-07-24 01:21:12 -0700 | [diff] [blame] | 543 | .PHONY: $(LOCAL_MODULE)-findbugs |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 544 | $(findbugs_html) : $(findbugs_xml) |
| 545 | @mkdir -p $(dir $@) |
Andrew Stadler | cef9ed9 | 2009-05-13 00:44:59 -0700 | [diff] [blame] | 546 | @echo ConvertXmlToText: $@ |
Yuncheol Heo | 623d706 | 2014-05-20 17:04:16 +0900 | [diff] [blame] | 547 | $(hide) $(FINDBUGS_DIR)/convertXmlToText -html:fancy.xsl $(PRIVATE_XML_FILE) \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 548 | > $@ |
| 549 | |
| 550 | $(LOCAL_MODULE)-findbugs : $(findbugs_html) |
| 551 | |
Ying Wang | 990cf5e | 2013-08-28 13:04:46 -0700 | [diff] [blame] | 552 | endif # full_classes_jar is defined |
Yohann Roussel | b4c49cb | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 553 | |
Jiyong Park | 5ebca30 | 2018-01-31 00:14:55 +0900 | [diff] [blame] | 554 | ifneq (,$(filter-out current system_current test_current core_current, $(LOCAL_SDK_VERSION))) |
Sundong Ahn | ef212cb | 2017-10-16 19:20:34 +0900 | [diff] [blame] | 555 | my_default_app_target_sdk := $(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION)) |
| 556 | my_sdk_version := $(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION)) |
Colin Cross | 536ef4e | 2017-02-21 16:14:55 -0800 | [diff] [blame] | 557 | else |
Colin Cross | 9deb331 | 2017-09-28 16:17:36 -0700 | [diff] [blame] | 558 | my_default_app_target_sdk := $(DEFAULT_APP_TARGET_SDK) |
| 559 | my_sdk_version := $(PLATFORM_SDK_VERSION) |
Colin Cross | 536ef4e | 2017-02-21 16:14:55 -0800 | [diff] [blame] | 560 | endif |
| 561 | |
Colin Cross | 9deb331 | 2017-09-28 16:17:36 -0700 | [diff] [blame] | 562 | ifdef LOCAL_MIN_SDK_VERSION |
| 563 | my_min_sdk_version := $(LOCAL_MIN_SDK_VERSION) |
| 564 | else |
| 565 | my_min_sdk_version := $(call codename-or-sdk-to-sdk,$(my_default_app_target_sdk)) |
| 566 | endif |
| 567 | |
| 568 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_DEFAULT_APP_TARGET_SDK := $(my_default_app_target_sdk) |
| 569 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_SDK_VERSION := $(my_sdk_version) |
| 570 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_MIN_SDK_VERSION := $(my_min_sdk_version) |