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 | 950f1ef | 2017-04-05 15:30:42 -0700 | [diff] [blame] | 71 | full_classes_desugar_jar := $(intermediates.COMMON)/classes-desugar.jar |
Colin Cross | a6e8782 | 2017-12-20 17:33:01 -0800 | [diff] [blame] | 72 | full_classes_jarjar_jar := $(intermediates.COMMON)/classes-jarjar.jar |
Colin Cross | 950f1ef | 2017-04-05 15:30:42 -0700 | [diff] [blame] | 73 | full_classes_proguard_jar := $(intermediates.COMMON)/classes-proguard.jar |
Nan Zhang | 9bd5405 | 2017-09-13 13:13:53 -0700 | [diff] [blame] | 74 | full_classes_combined_jar := $(intermediates.COMMON)/classes-combined.jar |
Colin Cross | a6e8782 | 2017-12-20 17:33:01 -0800 | [diff] [blame] | 75 | built_dex_intermediate := $(intermediates.COMMON)/dex/classes.dex |
Ying Wang | 957fea5 | 2010-09-23 11:48:38 -0700 | [diff] [blame] | 76 | full_classes_stubs_jar := $(intermediates.COMMON)/stubs.jar |
Colin Cross | dfc45ec | 2017-05-26 15:22:02 -0700 | [diff] [blame] | 77 | java_source_list_file := $(intermediates.COMMON)/java-source-list |
| 78 | |
Ying Wang | 957fea5 | 2010-09-23 11:48:38 -0700 | [diff] [blame] | 79 | |
Ying Wang | 37b82aa | 2013-08-28 17:28:36 -0700 | [diff] [blame] | 80 | ifeq ($(LOCAL_MODULE_CLASS)$(LOCAL_SRC_FILES)$(LOCAL_STATIC_JAVA_LIBRARIES)$(LOCAL_SOURCE_FILES_ALL_GENERATED),APPS) |
| 81 | # 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] | 82 | full_classes_jar := |
| 83 | built_dex := |
| 84 | else |
Ying Wang | 957fea5 | 2010-09-23 11:48:38 -0700 | [diff] [blame] | 85 | full_classes_jar := $(intermediates.COMMON)/classes.jar |
Ying Wang | 7b7929a | 2013-09-12 17:35:21 -0700 | [diff] [blame] | 86 | built_dex := $(intermediates.COMMON)/classes.dex |
Ying Wang | 990cf5e | 2013-08-28 13:04:46 -0700 | [diff] [blame] | 87 | endif |
Joe Onorato | e334d25 | 2009-07-17 15:33:40 -0400 | [diff] [blame] | 88 | |
| 89 | LOCAL_INTERMEDIATE_TARGETS += \ |
Nan Zhang | b3ec534 | 2017-08-31 21:43:04 +0000 | [diff] [blame] | 90 | $(full_classes_turbine_jar) \ |
Joe Onorato | e334d25 | 2009-07-17 15:33:40 -0400 | [diff] [blame] | 91 | $(full_classes_compiled_jar) \ |
Colin Cross | eac5ce4 | 2016-12-21 17:11:03 -0800 | [diff] [blame] | 92 | $(full_classes_desugar_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 | a9c381e | 2010-10-02 18:35:51 -0700 | [diff] [blame] | 96 | $(full_classes_proguard_jar) \ |
Ying Wang | 957fea5 | 2010-09-23 11:48:38 -0700 | [diff] [blame] | 97 | $(built_dex_intermediate) \ |
Guang Zhu | 155afe3 | 2010-03-10 15:48:03 -0800 | [diff] [blame] | 98 | $(built_dex) \ |
Colin Cross | dfc45ec | 2017-05-26 15:22:02 -0700 | [diff] [blame] | 99 | $(full_classes_stubs_jar) \ |
| 100 | $(java_source_list_file) |
Ying Wang | 957fea5 | 2010-09-23 11:48:38 -0700 | [diff] [blame] | 101 | |
Joe Onorato | 77dc0a5 | 2010-05-17 18:16:11 -0700 | [diff] [blame] | 102 | LOCAL_INTERMEDIATE_SOURCE_DIR := $(intermediates.COMMON)/src |
Joe Onorato | e334d25 | 2009-07-17 15:33:40 -0400 | [diff] [blame] | 103 | |
Ying Wang | 0bd59a0 | 2010-07-15 17:17:52 -0700 | [diff] [blame] | 104 | ############################################################### |
| 105 | ## .rs files: RenderScript sources to .java files and .bc files |
Stephen Hines | 0ab6e3e | 2012-10-11 15:01:53 -0700 | [diff] [blame] | 106 | ## .fs files: Filterscript sources to .java files and .bc files |
Ying Wang | 0bd59a0 | 2010-07-15 17:17:52 -0700 | [diff] [blame] | 107 | ############################################################### |
Stephen Hines | 0ab6e3e | 2012-10-11 15:01:53 -0700 | [diff] [blame] | 108 | renderscript_sources := $(filter %.rs %.fs,$(LOCAL_SRC_FILES)) |
Ying Wang | 0bd59a0 | 2010-07-15 17:17:52 -0700 | [diff] [blame] | 109 | # Because names of the java files from RenderScript are unknown until the |
| 110 | # .rs file(s) are compiled, we have to depend on a timestamp file. |
| 111 | RenderScript_file_stamp := |
Ying Wang | dd71c85 | 2015-12-04 13:59:18 -0800 | [diff] [blame] | 112 | rs_generated_res_dir := |
Stephen Hines | 3b0fa10 | 2013-02-06 16:19:30 -0800 | [diff] [blame] | 113 | rs_compatibility_jni_libs := |
Ying Wang | 0bd59a0 | 2010-07-15 17:17:52 -0700 | [diff] [blame] | 114 | ifneq ($(renderscript_sources),) |
| 115 | renderscript_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(renderscript_sources)) |
| 116 | RenderScript_file_stamp := $(LOCAL_INTERMEDIATE_SOURCE_DIR)/RenderScript.stamp |
Dan Willemsen | cf324af | 2016-12-21 17:37:00 -0800 | [diff] [blame] | 117 | renderscript_intermediate.COMMON := $(intermediates.COMMON)/renderscript |
Ying Wang | 0bd59a0 | 2010-07-15 17:17:52 -0700 | [diff] [blame] | 118 | |
Miao Wang | 302e944 | 2015-07-28 17:43:51 -0700 | [diff] [blame] | 119 | # Defaulting to an empty string uses the latest available platform SDK. |
Stephen Hines | c963eae | 2011-08-10 13:53:05 -0700 | [diff] [blame] | 120 | renderscript_target_api := |
Stephen Hines | a941d13 | 2011-08-29 18:53:53 -0700 | [diff] [blame] | 121 | |
| 122 | ifneq (,$(LOCAL_RENDERSCRIPT_TARGET_API)) |
Miao Wang | 302e944 | 2015-07-28 17:43:51 -0700 | [diff] [blame] | 123 | renderscript_target_api := $(LOCAL_RENDERSCRIPT_TARGET_API) |
Stephen Hines | a941d13 | 2011-08-29 18:53:53 -0700 | [diff] [blame] | 124 | else |
Miao Wang | 302e944 | 2015-07-28 17:43:51 -0700 | [diff] [blame] | 125 | ifneq (,$(LOCAL_SDK_VERSION)) |
| 126 | # Set target-api for LOCAL_SDK_VERSIONs other than current. |
Michael Wright | 0fb087f | 2015-11-06 15:20:51 +0000 | [diff] [blame] | 127 | ifneq (,$(filter-out current system_current test_current, $(LOCAL_SDK_VERSION))) |
Sundong Ahn | 5a44d1f | 2017-10-16 19:20:34 +0900 | [diff] [blame] | 128 | renderscript_target_api := $(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION)) |
Miao Wang | 302e944 | 2015-07-28 17:43:51 -0700 | [diff] [blame] | 129 | endif |
| 130 | endif # LOCAL_SDK_VERSION is set |
Stephen Hines | a941d13 | 2011-08-29 18:53:53 -0700 | [diff] [blame] | 131 | endif # LOCAL_RENDERSCRIPT_TARGET_API is set |
Stephen Hines | c963eae | 2011-08-10 13:53:05 -0700 | [diff] [blame] | 132 | |
Miao Wang | a11f6c2 | 2015-07-29 11:46:23 -0700 | [diff] [blame] | 133 | # For 64-bit, we always have to upgrade to at least 21 for compat build. |
| 134 | ifneq ($(LOCAL_RENDERSCRIPT_COMPATIBILITY),) |
| 135 | ifeq ($(TARGET_IS_64_BIT),true) |
| 136 | ifneq ($(filter $(RSCOMPAT_32BIT_ONLY_API_LEVELS),$(renderscript_target_api)),) |
| 137 | renderscript_target_api := 21 |
| 138 | endif |
Miao Wang | 302e944 | 2015-07-28 17:43:51 -0700 | [diff] [blame] | 139 | endif |
| 140 | endif |
| 141 | |
Stephen Hines | c963eae | 2011-08-10 13:53:05 -0700 | [diff] [blame] | 142 | ifeq ($(LOCAL_RENDERSCRIPT_CC),) |
| 143 | LOCAL_RENDERSCRIPT_CC := $(LLVM_RS_CC) |
| 144 | endif |
| 145 | |
Stephen Hines | 914f7a2 | 2011-12-06 18:43:24 -0800 | [diff] [blame] | 146 | # Turn on all warnings and warnings as errors for RS compiles. |
| 147 | # This can be disabled with LOCAL_RENDERSCRIPT_FLAGS := -Wno-error |
| 148 | renderscript_flags := -Wall -Werror |
| 149 | renderscript_flags += $(LOCAL_RENDERSCRIPT_FLAGS) |
| 150 | |
Ying Wang | 5128027 | 2010-09-01 13:28:52 -0700 | [diff] [blame] | 151 | # prepend the RenderScript system include path |
Michael Wright | 0fb087f | 2015-11-06 15:20:51 +0000 | [diff] [blame] | 152 | ifneq ($(filter-out current system_current test_current,$(LOCAL_SDK_VERSION))$(if $(TARGET_BUILD_APPS),$(filter current system_current test_current,$(LOCAL_SDK_VERSION))),) |
Ying Wang | 0ec188f | 2012-05-10 17:25:51 -0700 | [diff] [blame] | 153 | # if a numeric LOCAL_SDK_VERSION, or current LOCAL_SDK_VERSION with TARGET_BUILD_APPS |
Ying Wang | fcf00d5 | 2011-03-29 11:47:12 -0700 | [diff] [blame] | 154 | LOCAL_RENDERSCRIPT_INCLUDES := \ |
Stephen Hines | 5a4eb5f | 2012-03-06 21:48:36 -0800 | [diff] [blame] | 155 | $(HISTORICAL_SDK_VERSIONS_ROOT)/renderscript/clang-include \ |
| 156 | $(HISTORICAL_SDK_VERSIONS_ROOT)/renderscript/include \ |
Ying Wang | fcf00d5 | 2011-03-29 11:47:12 -0700 | [diff] [blame] | 157 | $(LOCAL_RENDERSCRIPT_INCLUDES) |
| 158 | else |
Ying Wang | 85aa5de | 2011-01-19 11:49:21 -0800 | [diff] [blame] | 159 | LOCAL_RENDERSCRIPT_INCLUDES := \ |
Stephen Hines | c963eae | 2011-08-10 13:53:05 -0700 | [diff] [blame] | 160 | $(TOPDIR)external/clang/lib/Headers \ |
Jean-Luc Brouillet | eba4493 | 2017-01-08 17:40:21 -0800 | [diff] [blame] | 161 | $(TOPDIR)frameworks/rs/script_api/include \ |
Stephen Hines | c963eae | 2011-08-10 13:53:05 -0700 | [diff] [blame] | 162 | $(LOCAL_RENDERSCRIPT_INCLUDES) |
Ying Wang | 7d83ef8 | 2011-05-25 17:16:22 -0700 | [diff] [blame] | 163 | endif |
| 164 | |
Stephen Hines | d4136c0 | 2011-08-23 22:01:49 -0700 | [diff] [blame] | 165 | ifneq ($(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE),) |
| 166 | LOCAL_RENDERSCRIPT_INCLUDES := $(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE) |
| 167 | endif |
| 168 | |
Ying Wang | b931956 | 2015-04-03 16:15:28 -0700 | [diff] [blame] | 169 | bc_files := $(patsubst %.fs,%.bc, $(patsubst %.rs,%.bc, $(notdir $(renderscript_sources)))) |
| 170 | bc_dep_files := $(addprefix $(renderscript_intermediate.COMMON)/,$(patsubst %.bc,%.d,$(bc_files))) |
| 171 | |
Ying Wang | 5128027 | 2010-09-01 13:28:52 -0700 | [diff] [blame] | 172 | $(RenderScript_file_stamp): PRIVATE_RS_INCLUDES := $(LOCAL_RENDERSCRIPT_INCLUDES) |
Ying Wang | 7d83ef8 | 2011-05-25 17:16:22 -0700 | [diff] [blame] | 173 | $(RenderScript_file_stamp): PRIVATE_RS_CC := $(LOCAL_RENDERSCRIPT_CC) |
Stephen Hines | 914f7a2 | 2011-12-06 18:43:24 -0800 | [diff] [blame] | 174 | $(RenderScript_file_stamp): PRIVATE_RS_FLAGS := $(renderscript_flags) |
Ying Wang | 0bd59a0 | 2010-07-15 17:17:52 -0700 | [diff] [blame] | 175 | $(RenderScript_file_stamp): PRIVATE_RS_SOURCE_FILES := $(renderscript_sources_fullpath) |
| 176 | # By putting the generated java files into $(LOCAL_INTERMEDIATE_SOURCE_DIR), they will be |
| 177 | # automatically found by the java compiling function transform-java-to-classes.jar. |
Ying Wang | 370fa67 | 2013-02-25 16:06:42 -0800 | [diff] [blame] | 178 | $(RenderScript_file_stamp): PRIVATE_RS_OUTPUT_DIR := $(renderscript_intermediate.COMMON) |
Stephen Hines | c963eae | 2011-08-10 13:53:05 -0700 | [diff] [blame] | 179 | $(RenderScript_file_stamp): PRIVATE_RS_TARGET_API := $(renderscript_target_api) |
Ying Wang | b931956 | 2015-04-03 16:15:28 -0700 | [diff] [blame] | 180 | $(RenderScript_file_stamp): PRIVATE_DEP_FILES := $(bc_dep_files) |
Ying Wang | 7d83ef8 | 2011-05-25 17:16:22 -0700 | [diff] [blame] | 181 | $(RenderScript_file_stamp): $(renderscript_sources_fullpath) $(LOCAL_RENDERSCRIPT_CC) |
Ying Wang | 0bd59a0 | 2010-07-15 17:17:52 -0700 | [diff] [blame] | 182 | $(transform-renderscripts-to-java-and-bc) |
| 183 | |
Ying Wang | b931956 | 2015-04-03 16:15:28 -0700 | [diff] [blame] | 184 | # include the dependency files (.d/.P) generated by llvm-rs-cc. |
Shinichiro Hamaji | 52a1d6c | 2016-02-01 17:59:01 +0900 | [diff] [blame] | 185 | $(call include-depfile,$(RenderScript_file_stamp).P,$(RenderScript_file_stamp)) |
Ying Wang | cddece6 | 2015-04-03 09:53:41 -0700 | [diff] [blame] | 186 | |
Stephen Hines | e719f28 | 2012-11-28 16:52:41 -0800 | [diff] [blame] | 187 | ifneq ($(LOCAL_RENDERSCRIPT_COMPATIBILITY),) |
Miao Wang | e4359cf | 2015-01-07 18:18:41 -0800 | [diff] [blame] | 188 | |
| 189 | |
| 190 | ifeq ($(filter $(RSCOMPAT_32BIT_ONLY_API_LEVELS),$(renderscript_target_api)),) |
| 191 | ifeq ($(TARGET_IS_64_BIT),true) |
| 192 | renderscript_intermediate.bc_folder := $(renderscript_intermediate.COMMON)/res/raw/bc64/ |
| 193 | else |
| 194 | renderscript_intermediate.bc_folder := $(renderscript_intermediate.COMMON)/res/raw/bc32/ |
| 195 | endif |
| 196 | else |
| 197 | renderscript_intermediate.bc_folder := $(renderscript_intermediate.COMMON)/res/raw/ |
| 198 | endif |
| 199 | |
Stephen Hines | e719f28 | 2012-11-28 16:52:41 -0800 | [diff] [blame] | 200 | rs_generated_bc := $(addprefix \ |
Miao Wang | e4359cf | 2015-01-07 18:18:41 -0800 | [diff] [blame] | 201 | $(renderscript_intermediate.bc_folder), $(bc_files)) |
Stephen Hines | e719f28 | 2012-11-28 16:52:41 -0800 | [diff] [blame] | 202 | |
Ying Wang | 370fa67 | 2013-02-25 16:06:42 -0800 | [diff] [blame] | 203 | renderscript_intermediate := $(intermediates)/renderscript |
Tim Murray | 8e0567a | 2013-05-13 15:46:37 -0700 | [diff] [blame] | 204 | |
| 205 | # We don't need the .so files in bundled branches |
| 206 | # Prevent these from showing up on the device |
Miao Wang | c919b0b | 2015-02-12 16:22:59 -0800 | [diff] [blame] | 207 | # One exception is librsjni.so, which is needed for |
| 208 | # both native path and compat path. |
| 209 | rs_jni_lib := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/librsjni.so |
| 210 | LOCAL_JNI_SHARED_LIBRARIES += librsjni |
| 211 | |
Stephen Hines | c54e81c | 2013-09-30 15:57:36 -0700 | [diff] [blame] | 212 | ifneq (,$(TARGET_BUILD_APPS)$(FORCE_BUILD_RS_COMPAT)) |
Tim Murray | 8e0567a | 2013-05-13 15:46:37 -0700 | [diff] [blame] | 213 | |
Stephen Hines | e719f28 | 2012-11-28 16:52:41 -0800 | [diff] [blame] | 214 | rs_compatibility_jni_libs := $(addprefix \ |
Stephen Hines | ec02b4f | 2013-02-15 23:02:20 -0800 | [diff] [blame] | 215 | $(renderscript_intermediate)/librs., \ |
Stephen Hines | e719f28 | 2012-11-28 16:52:41 -0800 | [diff] [blame] | 216 | $(patsubst %.bc,%.so, $(bc_files))) |
| 217 | |
| 218 | $(rs_generated_bc) : $(RenderScript_file_stamp) |
| 219 | |
Stephen Hines | f692513 | 2012-12-17 14:23:14 -0800 | [diff] [blame] | 220 | rs_support_lib := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/libRSSupport.so |
Miao Wang | c919b0b | 2015-02-12 16:22:59 -0800 | [diff] [blame] | 221 | LOCAL_JNI_SHARED_LIBRARIES += libRSSupport |
Stephen Hines | f692513 | 2012-12-17 14:23:14 -0800 | [diff] [blame] | 222 | |
Miao Wang | ec27a89 | 2014-11-20 11:05:18 -0800 | [diff] [blame] | 223 | rs_support_io_lib := |
| 224 | # check if the target api level support USAGE_IO |
| 225 | ifeq ($(filter $(RSCOMPAT_NO_USAGEIO_API_LEVELS),$(renderscript_target_api)),) |
| 226 | rs_support_io_lib := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/libRSSupportIO.so |
| 227 | LOCAL_JNI_SHARED_LIBRARIES += libRSSupportIO |
| 228 | endif |
Tim Murray | 8e0567a | 2013-05-13 15:46:37 -0700 | [diff] [blame] | 229 | |
Miao Wang | 28e78f4 | 2017-08-16 16:05:26 -0700 | [diff] [blame] | 230 | my_arch := $(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH) |
| 231 | ifneq (,$(filter arm64 mips64 x86_64,$(my_arch))) |
| 232 | my_min_sdk_version := 21 |
| 233 | else |
| 234 | my_min_sdk_version := $(MIN_SUPPORTED_SDK_VERSION) |
| 235 | endif |
Tim Murray | 8e0567a | 2013-05-13 15:46:37 -0700 | [diff] [blame] | 236 | |
Tim Murray | 1a6f09a | 2013-03-05 11:07:15 -0800 | [diff] [blame] | 237 | $(rs_compatibility_jni_libs): $(RenderScript_file_stamp) $(RS_PREBUILT_CLCORE) \ |
Miao Wang | ec27a89 | 2014-11-20 11:05:18 -0800 | [diff] [blame] | 238 | $(rs_support_lib) $(rs_support_io_lib) $(rs_jni_lib) $(rs_compiler_rt) |
Stephen Hines | 8db4cce | 2013-03-27 16:51:38 -0700 | [diff] [blame] | 239 | $(rs_compatibility_jni_libs): $(BCC_COMPAT) |
Ying Wang | 57d9060 | 2015-07-20 18:40:18 -0700 | [diff] [blame] | 240 | $(rs_compatibility_jni_libs): PRIVATE_CXX := $(CXX_WRAPPER) $(TARGET_CXX) |
Miao Wang | 28e78f4 | 2017-08-16 16:05:26 -0700 | [diff] [blame] | 241 | $(rs_compatibility_jni_libs): PRIVATE_SDK_VERSION := $(my_min_sdk_version) |
Stephen Hines | ec02b4f | 2013-02-15 23:02:20 -0800 | [diff] [blame] | 242 | $(rs_compatibility_jni_libs): $(renderscript_intermediate)/librs.%.so: \ |
Miao Wang | 28e78f4 | 2017-08-16 16:05:26 -0700 | [diff] [blame] | 243 | $(renderscript_intermediate.bc_folder)%.bc \ |
| 244 | $(SOONG_OUT_DIR)/ndk.timestamp |
Stephen Hines | e719f28 | 2012-11-28 16:52:41 -0800 | [diff] [blame] | 245 | $(transform-bc-to-so) |
| 246 | |
| 247 | endif |
| 248 | |
Tim Murray | 8e0567a | 2013-05-13 15:46:37 -0700 | [diff] [blame] | 249 | endif |
| 250 | |
Ying Wang | 0bd59a0 | 2010-07-15 17:17:52 -0700 | [diff] [blame] | 251 | LOCAL_INTERMEDIATE_TARGETS += $(RenderScript_file_stamp) |
| 252 | # Make sure the generated resource will be added to the apk. |
Ying Wang | dd71c85 | 2015-12-04 13:59:18 -0800 | [diff] [blame] | 253 | rs_generated_res_dir := $(renderscript_intermediate.COMMON)/res |
| 254 | LOCAL_RESOURCE_DIR := $(rs_generated_res_dir) $(LOCAL_RESOURCE_DIR) |
Ying Wang | 0bd59a0 | 2010-07-15 17:17:52 -0700 | [diff] [blame] | 255 | endif |
| 256 | |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 257 | |
| 258 | ########################################################### |
| 259 | ## AIDL: Compile .aidl files to .java |
| 260 | ########################################################### |
| 261 | aidl_sources := $(filter %.aidl,$(LOCAL_SRC_FILES)) |
Christopher Wiley | d9205ba | 2016-06-23 16:44:47 -0700 | [diff] [blame] | 262 | aidl_java_sources := |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 263 | |
| 264 | ifneq ($(strip $(aidl_sources)),) |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 265 | |
| 266 | aidl_preprocess_import := |
| 267 | ifdef LOCAL_SDK_VERSION |
Michael Wright | 0fb087f | 2015-11-06 15:20:51 +0000 | [diff] [blame] | 268 | ifneq ($(filter current system_current test_current, $(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS)),) |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 269 | # LOCAL_SDK_VERSION is current and no TARGET_BUILD_APPS |
| 270 | aidl_preprocess_import := $(TARGET_OUT_COMMON_INTERMEDIATES)/framework.aidl |
| 271 | else |
| 272 | aidl_preprocess_import := $(HISTORICAL_SDK_VERSIONS_ROOT)/$(LOCAL_SDK_VERSION)/framework.aidl |
| 273 | endif # not current or system_current |
| 274 | else |
| 275 | # build against the platform. |
| 276 | LOCAL_AIDL_INCLUDES += $(FRAMEWORKS_BASE_JAVA_SRC_DIRS) |
| 277 | endif # LOCAL_SDK_VERSION |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 278 | |
Christopher Wiley | d9205ba | 2016-06-23 16:44:47 -0700 | [diff] [blame] | 279 | $(foreach s,$(aidl_sources),\ |
Dan Willemsen | 4d99527 | 2017-09-29 17:37:31 -0700 | [diff] [blame] | 280 | $(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] | 281 | $(foreach java,$(aidl_java_sources), \ |
| 282 | $(call include-depfile,$(java:%.java=%.P),$(java))) |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 283 | |
Christopher Wiley | d9205ba | 2016-06-23 16:44:47 -0700 | [diff] [blame] | 284 | $(aidl_java_sources) : $(LOCAL_ADDITIONAL_DEPENDENCIES) $(aidl_preprocess_import) |
| 285 | |
| 286 | $(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] | 287 | $(aidl_java_sources): PRIVATE_MODULE := $(LOCAL_MODULE) |
Christopher Wiley | d9205ba | 2016-06-23 16:44:47 -0700 | [diff] [blame] | 288 | |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 289 | endif |
| 290 | |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 291 | ########################################## |
| 292 | |
Ying Wang | 1d977e3 | 2013-01-30 11:22:06 -0800 | [diff] [blame] | 293 | # All of the rules after full_classes_compiled_jar are very unlikely |
| 294 | # to fail except for bugs in their respective tools. If you would |
| 295 | # like to run these rules, add the "all" modifier goal to the make |
| 296 | # command line. |
Ying Wang | 447d696 | 2015-09-01 19:12:05 -0700 | [diff] [blame] | 297 | ifndef LOCAL_CHECKED_MODULE |
Jean-Philippe Lesot | 0fbc9ff | 2015-01-20 14:18:48 +0000 | [diff] [blame] | 298 | ifdef full_classes_jar |
Colin Cross | b17f285 | 2017-04-27 13:34:02 -0700 | [diff] [blame] | 299 | LOCAL_CHECKED_MODULE := $(full_classes_compiled_jar) |
Ying Wang | 990cf5e | 2013-08-28 13:04:46 -0700 | [diff] [blame] | 300 | endif |
Yohann Roussel | ee57268 | 2015-08-18 19:18:18 +0200 | [diff] [blame] | 301 | endif |
Ying Wang | 1d977e3 | 2013-01-30 11:22:06 -0800 | [diff] [blame] | 302 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 303 | ####################################### |
| 304 | include $(BUILD_SYSTEM)/base_rules.mk |
| 305 | ####################################### |
| 306 | |
Yasuhiro Matsuda | ff82e82 | 2015-09-04 16:23:49 +0900 | [diff] [blame] | 307 | ########################################################### |
| 308 | ## logtags: emit java source |
| 309 | ########################################################### |
| 310 | ifneq ($(strip $(logtags_sources)),) |
| 311 | |
Dan Willemsen | 4d99527 | 2017-09-29 17:37:31 -0700 | [diff] [blame] | 312 | logtags_java_sources := $(patsubst %.logtags,%.java,$(addprefix $(intermediates.COMMON)/logtags/, $(logtags_sources))) |
Yasuhiro Matsuda | ff82e82 | 2015-09-04 16:23:49 +0900 | [diff] [blame] | 313 | logtags_sources := $(addprefix $(LOCAL_PATH)/, $(logtags_sources)) |
| 314 | |
Shinichiro Hamaji | d3ce14c | 2016-03-29 03:29:21 +0900 | [diff] [blame] | 315 | $(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] | 316 | $(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] | 317 | $(transform-logtags-to-java) |
| 318 | |
| 319 | else |
| 320 | logtags_java_sources := |
| 321 | endif |
| 322 | |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 323 | ########################################## |
| 324 | java_sources := $(addprefix $(LOCAL_PATH)/, $(filter %.java,$(LOCAL_SRC_FILES))) $(aidl_java_sources) $(logtags_java_sources) \ |
| 325 | $(filter %.java,$(LOCAL_GENERATED_SOURCES)) |
Nan Zhang | ad818dc | 2017-10-04 09:26:06 -0700 | [diff] [blame] | 326 | java_intermediate_sources := $(addprefix $(TARGET_OUT_COMMON_INTERMEDIATES)/, $(filter %.java,$(LOCAL_INTERMEDIATE_SOURCES))) |
| 327 | all_java_sources := $(java_sources) $(java_intermediate_sources) |
| 328 | |
| 329 | enable_sharding := |
| 330 | ifneq ($(TURBINE_ENABLED),false) |
| 331 | ifneq ($(LOCAL_JAVAC_SHARD_SIZE),) |
| 332 | ifneq ($(LOCAL_JAR_PROCESSOR),) |
| 333 | $(call pretty-error,Cannot set both LOCAL_JAVAC_SHARD_SIZE and LOCAL_JAR_PROCESSOR!) |
| 334 | endif # LOCAL_JAR_PROCESSOR is not empty |
| 335 | enable_sharding := true |
| 336 | |
| 337 | num_shards := $(call int_divide,$(words $(java_sources)),$(LOCAL_JAVAC_SHARD_SIZE)) |
| 338 | ifneq ($(words $(java_sources)),$(call int_multiply,$(LOCAL_JAVAC_SHARD_SIZE),$(num_shards))) |
| 339 | # increment number of shards by 1. |
| 340 | num_shards := $(call int_plus,$(num_shards),1) |
| 341 | endif |
| 342 | |
| 343 | shard_idx_list := $(call int_range_list,1,$(num_shards)) |
| 344 | sharded_java_source_list_files += $(foreach x,$(shard_idx_list),$(java_source_list_file).shard.$(x)) |
| 345 | sharded_jar_list += $(foreach x,$(shard_idx_list),$(full_classes_compiled_jar).shard.$(x)) |
| 346 | |
| 347 | # always put dynamically-located .java files (generated by Proto/resource, etc) in a new final shard. |
| 348 | # increment number of shards by 1. |
| 349 | num_shards := $(call int_plus,$(num_shards),1) |
| 350 | sharded_java_source_list_files += $(java_source_list_file).shard.$(num_shards) |
| 351 | sharded_jar_list += $(full_classes_compiled_jar).shard.$(num_shards) |
| 352 | LOCAL_INTERMEDIATE_TARGETS += $(sharded_java_source_list_files) |
| 353 | LOCAL_INTERMEDIATE_TARGETS += $(sharded_jar_list) |
| 354 | endif # LOCAL_JAVAC_SHARD_SIZE is not empty |
| 355 | endif # TURBINE_ENABLED != false |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 356 | |
| 357 | include $(BUILD_SYSTEM)/java_common.mk |
| 358 | |
Dan Willemsen | cf324af | 2016-12-21 17:37:00 -0800 | [diff] [blame] | 359 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HAS_RS_SOURCES := $(if $(renderscript_sources),true) |
| 360 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RS_SOURCE_INTERMEDIATES_DIR := $(intermediates.COMMON)/renderscript |
| 361 | |
Narayan Kamath | bbcdc07 | 2017-08-22 15:47:08 +0100 | [diff] [blame] | 362 | # Set the profile source so that the odex / profile code included from java.mk |
| 363 | # can find it. |
| 364 | # |
| 365 | # TODO: b/64896089, this is broken when called from package_internal.mk, since the file |
| 366 | # we preopt from is a temporary file. This will be addressed in a follow up, possibly |
| 367 | # by disabling stripping for profile guided preopt (which may be desirable for other |
| 368 | # reasons anyway). |
| 369 | # |
| 370 | # Note that we set this only when called from package_internal.mk and not in other cases. |
| 371 | ifneq (,$(called_from_package_internal) |
| 372 | dex_preopt_profile_src_file := $(LOCAL_BUILT_MODULE) |
| 373 | endif |
| 374 | |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 375 | ####################################### |
| 376 | # defines built_odex along with rule to install odex |
| 377 | include $(BUILD_SYSTEM)/dex_preopt_odex_install.mk |
| 378 | ####################################### |
| 379 | |
Ying Wang | 990cf5e | 2013-08-28 13:04:46 -0700 | [diff] [blame] | 380 | # Make sure there's something to build. |
| 381 | ifdef full_classes_jar |
| 382 | ifndef need_compile_java |
| 383 | $(error $(LOCAL_PATH): Target java module does not define any source or resource files) |
| 384 | endif |
| 385 | endif |
| 386 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 387 | # Since we're using intermediates.COMMON, make sure that it gets cleaned |
| 388 | # properly. |
| 389 | $(cleantarget): PRIVATE_CLEAN_FILES += $(intermediates.COMMON) |
| 390 | |
Ying Wang | 990cf5e | 2013-08-28 13:04:46 -0700 | [diff] [blame] | 391 | ifdef full_classes_jar |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 392 | |
Joe Onorato | 64d85d0 | 2009-04-09 19:31:12 -0700 | [diff] [blame] | 393 | # Droiddoc isn't currently able to generate stubs for modules, so we're just |
| 394 | # allowing it to use the classes.jar as the "stubs" that would be use to link |
| 395 | # against, for the cases where someone needs the jar to link against. |
Colin Cross | 0e53734 | 2017-03-29 12:17:36 -0700 | [diff] [blame] | 396 | $(eval $(call copy-one-file,$(full_classes_jar),$(full_classes_stubs_jar))) |
Joe Onorato | 64d85d0 | 2009-04-09 19:31:12 -0700 | [diff] [blame] | 397 | ALL_MODULES.$(LOCAL_MODULE).STUBS := $(full_classes_stubs_jar) |
| 398 | |
Joe Onorato | 0eccce9 | 2011-10-30 21:37:35 -0700 | [diff] [blame] | 399 | # The layers file allows you to enforce a layering between java packages. |
Colin Cross | fdea893 | 2017-12-06 14:38:40 -0800 | [diff] [blame] | 400 | # Run build/make/tools/java-layers.py for more details. |
Joe Onorato | 0eccce9 | 2011-10-30 21:37:35 -0700 | [diff] [blame] | 401 | layers_file := $(addprefix $(LOCAL_PATH)/, $(LOCAL_JAVA_LAYERS_FILE)) |
| 402 | $(full_classes_compiled_jar): PRIVATE_JAVA_LAYERS_FILE := $(layers_file) |
Ying Wang | 057eba0 | 2012-10-18 10:54:49 -0700 | [diff] [blame] | 403 | $(full_classes_compiled_jar): PRIVATE_WARNINGS_ENABLE := $(LOCAL_WARNINGS_ENABLE) |
Joe Onorato | 0eccce9 | 2011-10-30 21:37:35 -0700 | [diff] [blame] | 404 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 405 | # Compile the java files to a .jar file. |
| 406 | # This intentionally depends on java_sources, not all_java_sources. |
| 407 | # Deps for generated source files must be handled separately, |
| 408 | # via deps on the target that generates the sources. |
Paul Duffin | 3ca9298 | 2016-09-20 15:12:30 +0100 | [diff] [blame] | 409 | |
| 410 | # If error prone is enabled then add LOCAL_ERROR_PRONE_FLAGS to LOCAL_JAVACFLAGS |
| 411 | ifeq ($(RUN_ERROR_PRONE),true) |
| 412 | LOCAL_JAVACFLAGS += $(LOCAL_ERROR_PRONE_FLAGS) |
| 413 | endif |
| 414 | |
Przemyslaw Szczepaniak | 2e81b3c | 2017-06-30 14:51:12 +0100 | [diff] [blame] | 415 | # For user / userdebug builds, strip the local variable table and the local variable |
| 416 | # type table. This has no bearing on stack traces, but will leave less information |
| 417 | # available via JDWP. |
| 418 | ifneq (,$(PRODUCT_MINIMIZE_JAVA_DEBUG_INFO)) |
| 419 | ifneq (,$(filter userdebug user,$(TARGET_BUILD_VARIANT))) |
| 420 | LOCAL_JAVACFLAGS+= -g:source,lines |
Przemyslaw Szczepaniak | 2e81b3c | 2017-06-30 14:51:12 +0100 | [diff] [blame] | 421 | endif |
| 422 | endif |
| 423 | |
Colin Cross | dfc45ec | 2017-05-26 15:22:02 -0700 | [diff] [blame] | 424 | # List of dependencies for anything that needs all java sources in place |
| 425 | java_sources_deps := \ |
| 426 | $(java_sources) \ |
| 427 | $(java_resource_sources) \ |
| 428 | $(RenderScript_file_stamp) \ |
| 429 | $(proto_java_sources_file_stamp) \ |
| 430 | $(LOCAL_ADDITIONAL_DEPENDENCIES) |
| 431 | |
| 432 | $(java_source_list_file): $(java_sources_deps) |
| 433 | $(write-java-source-list) |
| 434 | |
Nan Zhang | ad818dc | 2017-10-04 09:26:06 -0700 | [diff] [blame] | 435 | ifdef enable_sharding |
| 436 | $(foreach x,$(shard_idx_list),\ |
| 437 | $(eval $(call save-sharded-java-source-list,$(x),\ |
| 438 | $(wordlist $(call int_plus,1,$(call int_multiply,$(LOCAL_JAVAC_SHARD_SIZE),$(call int_subtract,$(x),1))),\ |
| 439 | $(call int_multiply,$(LOCAL_JAVAC_SHARD_SIZE),$(x)),$(sort $(java_sources)))))) |
| 440 | |
| 441 | # always put dynamically-located .java files (generated by Proto/resource, etc) in a new final shard. |
| 442 | $(java_source_list_file).shard.$(num_shards): PRIVATE_JAVA_INTERMEDIATE_SOURCES := $(java_intermediate_sources) |
| 443 | $(java_source_list_file).shard.$(num_shards): $(java_resource_sources) \ |
| 444 | $(RenderScript_file_stamp) \ |
| 445 | $(proto_java_sources_file_stamp) \ |
| 446 | $(LOCAL_ADDITIONAL_DEPENDENCIES) \ |
| 447 | $(NORMALIZE_PATH) |
| 448 | $(hide) rm -f $@ |
| 449 | $(call dump-words-to-file,$(PRIVATE_JAVA_INTERMEDIATE_SOURCES),$@.tmp) |
| 450 | $(call fetch-additional-java-source,$@.tmp) |
| 451 | $(hide) tr ' ' '\n' < $@.tmp | $(NORMALIZE_PATH) | sort -u > $@ |
| 452 | |
| 453 | # Javac sharding with header libs including its own header jar as one of dependency. |
| 454 | $(foreach x,$(shard_idx_list),\ |
| 455 | $(eval $(call create-classes-full-debug.jar,$(full_classes_compiled_jar).shard.$(x),\ |
| 456 | $(java_source_list_file).shard.$(x),\ |
| 457 | $(full_java_header_libs) $(full_classes_header_jar),$(x),\ |
| 458 | $(wordlist $(call int_plus,1,$(call int_multiply,$(LOCAL_JAVAC_SHARD_SIZE),$(call int_subtract,$(x),1))),\ |
| 459 | $(call int_multiply,$(LOCAL_JAVAC_SHARD_SIZE),$(x)),$(sort $(java_sources)))))) |
| 460 | |
| 461 | # Javac sharding for last shard with additional Java dependencies. |
| 462 | $(eval $(call create-classes-full-debug.jar,$(full_classes_compiled_jar).shard.$(num_shards),\ |
| 463 | $(java_source_list_file).shard.$(num_shards),$(full_java_header_libs) $(full_classes_header_jar),$(strip \ |
| 464 | $(num_shards)),$$(java_resource_sources) $$(RenderScript_file_stamp) \ |
| 465 | $$(proto_java_sources_file_stamp) $$(LOCAL_ADDITIONAL_DEPENDENCIES))) |
| 466 | |
| 467 | $(full_classes_compiled_jar): PRIVATE_SHARDED_JAR_LIST := $(sharded_jar_list) |
| 468 | $(full_classes_compiled_jar): $(sharded_jar_list) | $(MERGE_ZIPS) |
| 469 | $(MERGE_ZIPS) -j $@ $(PRIVATE_SHARDED_JAR_LIST) |
| 470 | else |
| 471 | # we can't use single $ for java_sources_deps since it may contain hash '#' sign. |
| 472 | $(eval $(call create-classes-full-debug.jar,$(full_classes_compiled_jar),\ |
| 473 | $(java_source_list_file),$(full_java_header_libs),,$$(java_sources_deps))) |
| 474 | |
| 475 | endif # ifdef enable_sharding |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 476 | |
Colin Cross | 7dc9043 | 2017-09-26 16:17:24 -0700 | [diff] [blame] | 477 | ifneq ($(TURBINE_ENABLED),false) |
| 478 | |
Nan Zhang | b3ec534 | 2017-08-31 21:43:04 +0000 | [diff] [blame] | 479 | $(full_classes_turbine_jar): PRIVATE_JAVACFLAGS := $(LOCAL_JAVACFLAGS) $(annotation_processor_flags) |
| 480 | $(full_classes_turbine_jar): PRIVATE_DONT_DELETE_JAR_META_INF := $(LOCAL_DONT_DELETE_JAR_META_INF) |
| 481 | $(full_classes_turbine_jar): \ |
| 482 | $(java_source_list_file) \ |
| 483 | $(java_sources_deps) \ |
| 484 | $(full_java_header_libs) \ |
Colin Cross | 1d1e5ef | 2017-09-23 18:19:05 -0700 | [diff] [blame] | 485 | $(full_java_bootclasspath_libs) \ |
Colin Cross | f960257 | 2017-10-12 13:34:40 -0700 | [diff] [blame] | 486 | $(full_java_system_modules_deps) \ |
Nan Zhang | b3ec534 | 2017-08-31 21:43:04 +0000 | [diff] [blame] | 487 | $(NORMALIZE_PATH) \ |
| 488 | $(JAR_ARGS) \ |
| 489 | $(ZIPTIME) \ |
Nan Zhang | 9bd5405 | 2017-09-13 13:13:53 -0700 | [diff] [blame] | 490 | | $(TURBINE) \ |
| 491 | $(MERGE_ZIPS) |
Nan Zhang | b3ec534 | 2017-08-31 21:43:04 +0000 | [diff] [blame] | 492 | $(transform-java-to-header.jar) |
| 493 | |
| 494 | .KATI_RESTAT: $(full_classes_turbine_jar) |
| 495 | |
| 496 | # Run jarjar before generate classes-header.jar if necessary. |
| 497 | ifneq ($(strip $(LOCAL_JARJAR_RULES)),) |
| 498 | $(full_classes_header_jarjar): PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES) |
| 499 | $(full_classes_header_jarjar): $(full_classes_turbine_jar) $(LOCAL_JARJAR_RULES) | $(JARJAR) |
| 500 | @echo Header JarJar: $@ |
| 501 | $(hide) $(JAVA) -jar $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@ |
| 502 | else |
| 503 | full_classes_header_jarjar := $(full_classes_turbine_jar) |
| 504 | endif |
| 505 | |
| 506 | $(eval $(call copy-one-file,$(full_classes_header_jarjar),$(full_classes_header_jar))) |
| 507 | |
Colin Cross | 7dc9043 | 2017-09-26 16:17:24 -0700 | [diff] [blame] | 508 | endif # TURBINE_ENABLED != false |
| 509 | |
Ying Wang | cddeb6c | 2016-03-24 11:00:30 -0700 | [diff] [blame] | 510 | javac-check : $(full_classes_compiled_jar) |
Paul Duffin | 32bd0ad | 2016-09-15 14:34:42 +0100 | [diff] [blame] | 511 | javac-check-$(LOCAL_MODULE) : $(full_classes_compiled_jar) |
Ying Wang | cddeb6c | 2016-03-24 11:00:30 -0700 | [diff] [blame] | 512 | |
Nan Zhang | 9bd5405 | 2017-09-13 13:13:53 -0700 | [diff] [blame] | 513 | $(full_classes_combined_jar): PRIVATE_DONT_DELETE_JAR_META_INF := $(LOCAL_DONT_DELETE_JAR_META_INF) |
| 514 | $(full_classes_combined_jar): $(full_classes_compiled_jar) \ |
Nan Zhang | b880117 | 2017-09-20 14:56:48 -0700 | [diff] [blame] | 515 | $(jar_manifest_file) \ |
Nan Zhang | 9bd5405 | 2017-09-13 13:13:53 -0700 | [diff] [blame] | 516 | $(full_static_java_libs) | $(MERGE_ZIPS) |
Nan Zhang | b880117 | 2017-09-20 14:56:48 -0700 | [diff] [blame] | 517 | $(if $(PRIVATE_JAR_MANIFEST), $(hide) sed -e "s/%BUILD_NUMBER%/$(BUILD_NUMBER_FROM_FILE)/" \ |
| 518 | $(PRIVATE_JAR_MANIFEST) > $(dir $@)/manifest.mf) |
| 519 | $(MERGE_ZIPS) -j $(if $(PRIVATE_JAR_MANIFEST),-m $(dir $@)/manifest.mf) \ |
| 520 | $(if $(PRIVATE_DONT_DELETE_JAR_META_INF),,-stripDir META-INF -zipToNotStrip $<) \ |
| 521 | $@ $< $(call reverse-list,$(PRIVATE_STATIC_JAVA_LIBRARIES)) |
Nan Zhang | 9bd5405 | 2017-09-13 13:13:53 -0700 | [diff] [blame] | 522 | |
Colin Cross | f8a49c5 | 2017-05-22 16:21:49 -0700 | [diff] [blame] | 523 | ifdef LOCAL_JAR_PROCESSOR |
| 524 | # LOCAL_JAR_PROCESSOR_ARGS must be evaluated here to set up the rule-local |
| 525 | # PRIVATE_JAR_PROCESSOR_ARGS variable, but $< and $@ are not available yet. |
| 526 | # Set ${in} and ${out} so they can be referenced by LOCAL_JAR_PROCESSOR_ARGS |
| 527 | # using deferred evaluation (LOCAL_JAR_PROCESSOR_ARGS = instead of :=). |
Nan Zhang | 9bd5405 | 2017-09-13 13:13:53 -0700 | [diff] [blame] | 528 | in := $(full_classes_combined_jar) |
Colin Cross | f8a49c5 | 2017-05-22 16:21:49 -0700 | [diff] [blame] | 529 | out := $(full_classes_processed_jar).tmp |
Colin Cross | 89b802b | 2017-07-13 19:25:47 -0700 | [diff] [blame] | 530 | my_jar_processor := $(HOST_OUT_JAVA_LIBRARIES)/$(LOCAL_JAR_PROCESSOR).jar |
| 531 | |
Colin Cross | f8a49c5 | 2017-05-22 16:21:49 -0700 | [diff] [blame] | 532 | $(full_classes_processed_jar): PRIVATE_JAR_PROCESSOR_ARGS := $(LOCAL_JAR_PROCESSOR_ARGS) |
Colin Cross | 89b802b | 2017-07-13 19:25:47 -0700 | [diff] [blame] | 533 | $(full_classes_processed_jar): PRIVATE_JAR_PROCESSOR := $(my_jar_processor) |
Colin Cross | f8a49c5 | 2017-05-22 16:21:49 -0700 | [diff] [blame] | 534 | $(full_classes_processed_jar): PRIVATE_TMP_OUT := $(out) |
| 535 | in := |
| 536 | out := |
| 537 | |
Nan Zhang | 9bd5405 | 2017-09-13 13:13:53 -0700 | [diff] [blame] | 538 | $(full_classes_processed_jar): $(full_classes_combined_jar) $(my_jar_processor) |
Colin Cross | f8a49c5 | 2017-05-22 16:21:49 -0700 | [diff] [blame] | 539 | @echo Processing $@ with $(PRIVATE_JAR_PROCESSOR) |
| 540 | $(hide) rm -f $@ $(PRIVATE_TMP_OUT) |
Colin Cross | 0851df8 | 2017-06-30 13:55:38 -0700 | [diff] [blame] | 541 | $(hide) $(JAVA) -jar $(PRIVATE_JAR_PROCESSOR) $(PRIVATE_JAR_PROCESSOR_ARGS) |
Colin Cross | f8a49c5 | 2017-05-22 16:21:49 -0700 | [diff] [blame] | 542 | $(hide) mv $(PRIVATE_TMP_OUT) $@ |
| 543 | |
Colin Cross | 89b802b | 2017-07-13 19:25:47 -0700 | [diff] [blame] | 544 | my_jar_processor := |
Colin Cross | f8a49c5 | 2017-05-22 16:21:49 -0700 | [diff] [blame] | 545 | else |
Nan Zhang | 9bd5405 | 2017-09-13 13:13:53 -0700 | [diff] [blame] | 546 | full_classes_processed_jar := $(full_classes_combined_jar) |
Colin Cross | f8a49c5 | 2017-05-22 16:21:49 -0700 | [diff] [blame] | 547 | endif |
| 548 | |
Nan Zhang | 870025f | 2017-09-13 14:56:11 -0700 | [diff] [blame] | 549 | # Run jarjar if necessary |
| 550 | ifneq ($(strip $(LOCAL_JARJAR_RULES)),) |
| 551 | $(full_classes_jarjar_jar): PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES) |
| 552 | $(full_classes_jarjar_jar): $(full_classes_processed_jar) $(LOCAL_JARJAR_RULES) | $(JARJAR) |
| 553 | @echo JarJar: $@ |
| 554 | $(hide) $(JAVA) -jar $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@ |
| 555 | else |
| 556 | full_classes_jarjar_jar := $(full_classes_processed_jar) |
| 557 | endif |
| 558 | |
| 559 | $(eval $(call copy-one-file,$(full_classes_jarjar_jar),$(full_classes_jar))) |
| 560 | |
Colin Cross | 9687348 | 2017-12-22 16:51:23 -0800 | [diff] [blame^] | 561 | LOCAL_FULL_CLASSES_PRE_JACOCO_JAR := $(full_classes_jar) |
| 562 | |
| 563 | ####################################### |
| 564 | include $(BUILD_SYSTEM)/jacoco.mk |
| 565 | ####################################### |
| 566 | |
Tobias Thierer | 7ef760b | 2017-11-17 13:02:12 +0000 | [diff] [blame] | 567 | # Temporarily enable --multi-dex until proguard supports v53 class files |
| 568 | # ( http://b/67673860 ) or we move away from proguard altogether. |
Tobias Thierer | f6bd495 | 2017-11-15 20:55:03 +0000 | [diff] [blame] | 569 | ifdef TARGET_OPENJDK9 |
Tobias Thierer | 8974066 | 2017-10-25 02:38:01 +0100 | [diff] [blame] | 570 | LOCAL_DX_FLAGS := $(filter-out --multi-dex,$(LOCAL_DX_FLAGS)) --multi-dex |
| 571 | endif |
| 572 | |
Alan Leung | eaafb3c | 2017-12-01 14:32:58 -0800 | [diff] [blame] | 573 | ifneq ($(USE_D8_DESUGAR),true) |
Colin Cross | eac5ce4 | 2016-12-21 17:11:03 -0800 | [diff] [blame] | 574 | my_desugaring := |
Colin Cross | 31060fd | 2017-03-21 10:17:04 -0700 | [diff] [blame] | 575 | ifndef LOCAL_IS_STATIC_JAVA_LIBRARY |
Colin Cross | eac5ce4 | 2016-12-21 17:11:03 -0800 | [diff] [blame] | 576 | my_desugaring := true |
| 577 | $(full_classes_desugar_jar): PRIVATE_DX_FLAGS := $(LOCAL_DX_FLAGS) |
Colin Cross | 9687348 | 2017-12-22 16:51:23 -0800 | [diff] [blame^] | 578 | $(full_classes_desugar_jar): $(LOCAL_FULL_CLASSES_JACOCO_JAR) $(full_java_header_libs) $(DESUGAR) |
Colin Cross | eac5ce4 | 2016-12-21 17:11:03 -0800 | [diff] [blame] | 579 | $(desugar-classes-jar) |
| 580 | endif |
Alan Leung | eaafb3c | 2017-12-01 14:32:58 -0800 | [diff] [blame] | 581 | else |
| 582 | my_desugaring := |
| 583 | endif |
Colin Cross | eac5ce4 | 2016-12-21 17:11:03 -0800 | [diff] [blame] | 584 | |
| 585 | ifndef my_desugaring |
Colin Cross | 9687348 | 2017-12-22 16:51:23 -0800 | [diff] [blame^] | 586 | full_classes_desugar_jar := $(LOCAL_FULL_CLASSES_JACOCO_JAR) |
Colin Cross | eac5ce4 | 2016-12-21 17:11:03 -0800 | [diff] [blame] | 587 | endif |
| 588 | |
Colin Cross | 9687348 | 2017-12-22 16:51:23 -0800 | [diff] [blame^] | 589 | full_classes_pre_proguard_jar := $(full_classes_desugar_jar) |
Ying Wang | 3b2bdf1 | 2010-02-01 09:51:23 -0800 | [diff] [blame] | 590 | |
Colin Cross | 950f1ef | 2017-04-05 15:30:42 -0700 | [diff] [blame] | 591 | # Keep a copy of the jar just before proguard processing. |
| 592 | $(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] | 593 | |
Colin Cross | 0e53734 | 2017-03-29 12:17:36 -0700 | [diff] [blame] | 594 | # Run proguard if necessary |
Ying Wang | 7311a34 | 2013-08-21 18:32:49 -0700 | [diff] [blame] | 595 | ifdef LOCAL_PROGUARD_ENABLED |
Colin Cross | e4936e1 | 2017-12-27 17:58:21 -0800 | [diff] [blame] | 596 | ifneq ($(filter-out full custom nosystem obfuscation optimization,$(LOCAL_PROGUARD_ENABLED)),) |
Ying Wang | 7311a34 | 2013-08-21 18:32:49 -0700 | [diff] [blame] | 597 | $(warning while processing: $(LOCAL_MODULE)) |
| 598 | $(error invalid value for LOCAL_PROGUARD_ENABLED: $(LOCAL_PROGUARD_ENABLED)) |
| 599 | endif |
Joe Onorato | 2daa2b3 | 2009-08-30 13:39:24 -0700 | [diff] [blame] | 600 | proguard_dictionary := $(intermediates.COMMON)/proguard_dictionary |
Ying Wang | 4f5d0e6 | 2015-05-04 19:21:48 -0700 | [diff] [blame] | 601 | |
Colin Cross | b5f25a2 | 2017-10-20 19:16:41 -0700 | [diff] [blame] | 602 | # When an app contains references to APIs that are not in the SDK specified by |
| 603 | # its LOCAL_SDK_VERSION for example added by support library or by runtime |
| 604 | # classes added by desugar, we artifically raise the "SDK version" "linked" by |
| 605 | # ProGuard, to |
Ying Wang | 4f5d0e6 | 2015-05-04 19:21:48 -0700 | [diff] [blame] | 606 | # - suppress ProGuard warnings of referencing symbols unknown to the lower SDK version. |
| 607 | # - 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] | 608 | # See b/20667396 |
| 609 | my_proguard_sdk_raise := |
Ying Wang | 4f5d0e6 | 2015-05-04 19:21:48 -0700 | [diff] [blame] | 610 | ifdef LOCAL_SDK_VERSION |
Ying Wang | 4f5d0e6 | 2015-05-04 19:21:48 -0700 | [diff] [blame] | 611 | ifdef TARGET_BUILD_APPS |
Michael Wright | 0fb087f | 2015-11-06 15:20:51 +0000 | [diff] [blame] | 612 | ifeq (,$(filter current system_current test_current, $(LOCAL_SDK_VERSION))) |
Colin Cross | b5f25a2 | 2017-10-20 19:16:41 -0700 | [diff] [blame] | 613 | my_proguard_sdk_raise := $(call java-lib-header-files, sdk_vcurrent) |
Ying Wang | 742f583 | 2015-06-26 12:33:06 -0700 | [diff] [blame] | 614 | endif |
Ying Wang | 4f5d0e6 | 2015-05-04 19:21:48 -0700 | [diff] [blame] | 615 | else |
| 616 | # For platform build, we can't just raise to the "current" SDK, |
| 617 | # that would break apps that use APIs removed from the current SDK. |
Colin Cross | b5f25a2 | 2017-10-20 19:16:41 -0700 | [diff] [blame] | 618 | 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] | 619 | endif |
| 620 | endif |
Ying Wang | 4f5d0e6 | 2015-05-04 19:21:48 -0700 | [diff] [blame] | 621 | |
Colin Cross | b5f25a2 | 2017-10-20 19:16:41 -0700 | [diff] [blame] | 622 | legacy_proguard_flags := $(addprefix -libraryjars ,$(my_proguard_sdk_raise) \ |
| 623 | $(filter-out $(my_proguard_sdk_raise), \ |
Colin Cross | b541aae | 2017-09-23 19:52:43 -0700 | [diff] [blame] | 624 | $(full_java_bootclasspath_libs) \ |
| 625 | $(full_shared_java_header_libs))) |
Nan Zhang | b3ec534 | 2017-08-31 21:43:04 +0000 | [diff] [blame] | 626 | |
Colin Cross | b5f25a2 | 2017-10-20 19:16:41 -0700 | [diff] [blame] | 627 | legacy_proguard_lib_deps := $(my_proguard_sdk_raise) \ |
| 628 | $(filter-out $(my_proguard_sdk_raise),$(full_shared_java_header_libs)) |
Yohann Roussel | b7de0fb | 2015-11-03 18:33:21 +0100 | [diff] [blame] | 629 | |
| 630 | legacy_proguard_flags += -printmapping $(proguard_dictionary) |
Yohann Roussel | b7de0fb | 2015-11-03 18:33:21 +0100 | [diff] [blame] | 631 | |
| 632 | common_proguard_flags := -forceprocessing |
Ying Wang | 7311a34 | 2013-08-21 18:32:49 -0700 | [diff] [blame] | 633 | |
Shinichiro Hamaji | 4eaeef8 | 2016-04-07 18:56:42 +0900 | [diff] [blame] | 634 | common_proguard_flag_files := |
Ying Wang | 7311a34 | 2013-08-21 18:32:49 -0700 | [diff] [blame] | 635 | ifeq ($(filter nosystem,$(LOCAL_PROGUARD_ENABLED)),) |
Shinichiro Hamaji | 4eaeef8 | 2016-04-07 18:56:42 +0900 | [diff] [blame] | 636 | common_proguard_flag_files += $(BUILD_SYSTEM)/proguard.flags |
Ying Wang | 7311a34 | 2013-08-21 18:32:49 -0700 | [diff] [blame] | 637 | ifneq ($(LOCAL_INSTRUMENTATION_FOR)$(filter tests,$(LOCAL_MODULE_TAGS)),) |
Yohann Roussel | b4c49cb | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 638 | common_proguard_flags += -dontshrink # don't shrink tests by default |
Ying Wang | 3b2bdf1 | 2010-02-01 09:51:23 -0800 | [diff] [blame] | 639 | endif # test package |
Dan Willemsen | 1d64623 | 2017-11-17 13:11:26 -0800 | [diff] [blame] | 640 | ifneq ($(LOCAL_PROGUARD_ENABLED),custom) |
| 641 | ifdef LOCAL_USE_AAPT2 |
| 642 | common_proguard_flag_files += $(foreach l,$(LOCAL_STATIC_ANDROID_LIBRARIES),\ |
| 643 | $(call intermediates-dir-for,JAVA_LIBRARIES,$(l),,COMMON)/export_proguard_flags) |
| 644 | endif |
| 645 | endif |
Shinichiro Hamaji | 4eaeef8 | 2016-04-07 18:56:42 +0900 | [diff] [blame] | 646 | ifneq ($(common_proguard_flag_files),) |
| 647 | common_proguard_flags += $(addprefix -include , $(common_proguard_flag_files)) |
| 648 | # This is included from $(BUILD_SYSTEM)/proguard.flags |
| 649 | common_proguard_flag_files += $(BUILD_SYSTEM)/proguard_basic_keeps.flags |
| 650 | endif |
| 651 | |
Ying Wang | 7311a34 | 2013-08-21 18:32:49 -0700 | [diff] [blame] | 652 | ifeq ($(filter obfuscation,$(LOCAL_PROGUARD_ENABLED)),) |
| 653 | # By default no obfuscation |
Yohann Roussel | b4c49cb | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 654 | common_proguard_flags += -dontobfuscate |
Ying Wang | 7311a34 | 2013-08-21 18:32:49 -0700 | [diff] [blame] | 655 | endif # No obfuscation |
| 656 | ifeq ($(filter optimization,$(LOCAL_PROGUARD_ENABLED)),) |
| 657 | # By default no optimization |
Yohann Roussel | b4c49cb | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 658 | common_proguard_flags += -dontoptimize |
Ying Wang | 7311a34 | 2013-08-21 18:32:49 -0700 | [diff] [blame] | 659 | endif # No optimization |
Ying Wang | 3b2bdf1 | 2010-02-01 09:51:23 -0800 | [diff] [blame] | 660 | |
Ying Wang | 7311a34 | 2013-08-21 18:32:49 -0700 | [diff] [blame] | 661 | ifdef LOCAL_INSTRUMENTATION_FOR |
| 662 | ifeq ($(filter obfuscation,$(LOCAL_PROGUARD_ENABLED)),) |
| 663 | # If no obfuscation, link in the instrmented package's classes.jar as a library. |
| 664 | # link_instr_classes_jar is defined in base_rule.mk |
Yohann Roussel | b4c49cb | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 665 | legacy_proguard_flags += -libraryjars $(link_instr_classes_jar) |
Nan Zhang | b3ec534 | 2017-08-31 21:43:04 +0000 | [diff] [blame] | 666 | legacy_proguard_lib_deps += $(link_instr_classes_jar) |
Ying Wang | 7311a34 | 2013-08-21 18:32:49 -0700 | [diff] [blame] | 667 | else # obfuscation |
| 668 | # If obfuscation is enabled, the main app must be obfuscated too. |
| 669 | # We need to run obfuscation using the main app's dictionary, |
| 670 | # 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] | 671 | legacy_proguard_flags := -injars $(link_instr_classes_jar) \ |
Ying Wang | 7311a34 | 2013-08-21 18:32:49 -0700 | [diff] [blame] | 672 | -outjars $(intermediates.COMMON)/proguard.$(LOCAL_INSTRUMENTATION_FOR).jar \ |
| 673 | -include $(link_instr_intermediates_dir.COMMON)/proguard_options \ |
| 674 | -applymapping $(link_instr_intermediates_dir.COMMON)/proguard_dictionary \ |
| 675 | -verbose \ |
Yohann Roussel | b4c49cb | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 676 | $(legacy_proguard_flags) |
Ying Wang | 7311a34 | 2013-08-21 18:32:49 -0700 | [diff] [blame] | 677 | |
| 678 | # Sometimes (test + main app) uses different keep rules from the main app - |
| 679 | # apply the main app's dictionary anyway. |
Yohann Roussel | b4c49cb | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 680 | legacy_proguard_flags += -ignorewarnings |
Ying Wang | 7311a34 | 2013-08-21 18:32:49 -0700 | [diff] [blame] | 681 | |
| 682 | # Make sure we run Proguard on the main app first |
| 683 | $(full_classes_proguard_jar) : $(link_instr_intermediates_dir.COMMON)/proguard.classes.jar |
| 684 | |
| 685 | endif # no obfuscation |
| 686 | endif # LOCAL_INSTRUMENTATION_FOR |
| 687 | endif # LOCAL_PROGUARD_ENABLED is not nosystem |
Joe Onorato | 2daa2b3 | 2009-08-30 13:39:24 -0700 | [diff] [blame] | 688 | |
Ying Wang | 0b9382c | 2010-09-29 14:50:41 -0700 | [diff] [blame] | 689 | proguard_flag_files := $(addprefix $(LOCAL_PATH)/, $(LOCAL_PROGUARD_FLAG_FILES)) |
Søren Gjesse | 0c1fe64 | 2017-10-12 16:09:13 +0200 | [diff] [blame] | 690 | ifeq ($(USE_R8),true) |
| 691 | proguard_flag_files += $(addprefix $(LOCAL_PATH)/, $(LOCAL_R8_FLAG_FILES)) |
| 692 | endif # USE_R8 |
Ying Wang | 0b9382c | 2010-09-29 14:50:41 -0700 | [diff] [blame] | 693 | LOCAL_PROGUARD_FLAGS += $(addprefix -include , $(proguard_flag_files)) |
| 694 | |
Mihail Dumitrescu | 4df82b3 | 2014-02-07 15:18:59 +0000 | [diff] [blame] | 695 | ifdef LOCAL_TEST_MODULE_TO_PROGUARD_WITH |
| 696 | extra_input_jar := $(call intermediates-dir-for,APPS,$(LOCAL_TEST_MODULE_TO_PROGUARD_WITH),,COMMON)/classes.jar |
| 697 | else |
| 698 | extra_input_jar := |
| 699 | endif |
Paul Duffin | f22aca1 | 2017-02-21 13:11:13 +0000 | [diff] [blame] | 700 | |
Colin Cross | e673deb | 2017-09-27 14:28:41 -0700 | [diff] [blame] | 701 | # If building against the current SDK version then filter out the junit, |
| 702 | # android.test and c.a.i.u.Predicate classes that are to be removed from |
| 703 | # the Android API as part of b/30188076 but which are still present in |
| 704 | # the Android API. This is to allow changes to be made to the build to |
| 705 | # statically include those classes into the application without |
Paul Duffin | f22aca1 | 2017-02-21 13:11:13 +0000 | [diff] [blame] | 706 | # simultaneously removing those classes from the API. |
| 707 | proguard_injar_filters := |
Paul Duffin | f22aca1 | 2017-02-21 13:11:13 +0000 | [diff] [blame] | 708 | ifdef LOCAL_SDK_VERSION |
| 709 | ifeq (,$(filter-out current system_current test_current, $(LOCAL_SDK_VERSION))) |
Paul Duffin | 54747a7 | 2017-06-15 08:42:23 +0100 | [diff] [blame] | 710 | proguard_injar_filters := (!junit/framework/**,!junit/runner/**,!junit/textui/**,!android/test/**,!com/android/internal/util/*) |
Paul Duffin | f22aca1 | 2017-02-21 13:11:13 +0000 | [diff] [blame] | 711 | endif |
| 712 | endif |
Paul Duffin | f22aca1 | 2017-02-21 13:11:13 +0000 | [diff] [blame] | 713 | |
Dan Willemsen | bdd6a75 | 2017-09-25 23:36:19 -0700 | [diff] [blame] | 714 | ifneq ($(filter obfuscation,$(LOCAL_PROGUARD_ENABLED)),) |
Søren Gjesse | 4ab5b02 | 2017-10-25 17:10:59 +0200 | [diff] [blame] | 715 | ifneq ($(USE_R8),true) |
Dan Willemsen | bdd6a75 | 2017-09-25 23:36:19 -0700 | [diff] [blame] | 716 | $(full_classes_proguard_jar): .KATI_IMPLICIT_OUTPUTS := $(proguard_dictionary) |
Søren Gjesse | 4ab5b02 | 2017-10-25 17:10:59 +0200 | [diff] [blame] | 717 | else |
| 718 | $(built_dex_intermediate): .KATI_IMPLICIT_OUTPUTS := $(proguard_dictionary) |
| 719 | endif |
Dan Willemsen | bdd6a75 | 2017-09-25 23:36:19 -0700 | [diff] [blame] | 720 | endif |
Søren Gjesse | 0c1fe64 | 2017-10-12 16:09:13 +0200 | [diff] [blame] | 721 | |
| 722 | # If R8 is not enabled run Proguard. |
| 723 | ifneq ($(USE_R8),true) |
| 724 | # Changes to these dependencies need to be replicated below when using R8 |
| 725 | # instead of Proguard + dx. |
Paul Duffin | f22aca1 | 2017-02-21 13:11:13 +0000 | [diff] [blame] | 726 | $(full_classes_proguard_jar): PRIVATE_PROGUARD_INJAR_FILTERS := $(proguard_injar_filters) |
Mihail Dumitrescu | 4df82b3 | 2014-02-07 15:18:59 +0000 | [diff] [blame] | 727 | $(full_classes_proguard_jar): PRIVATE_EXTRA_INPUT_JAR := $(extra_input_jar) |
Yohann Roussel | b4c49cb | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 728 | $(full_classes_proguard_jar): PRIVATE_PROGUARD_FLAGS := $(legacy_proguard_flags) $(common_proguard_flags) $(LOCAL_PROGUARD_FLAGS) |
Colin Cross | b5f25a2 | 2017-10-20 19:16:41 -0700 | [diff] [blame] | 729 | $(full_classes_proguard_jar) : $(full_classes_pre_proguard_jar) $(extra_input_jar) $(my_proguard_sdk_raise) $(common_proguard_flag_files) $(proguard_flag_files) $(legacy_proguard_lib_deps) | $(PROGUARD) |
Ying Wang | 3b2bdf1 | 2010-02-01 09:51:23 -0800 | [diff] [blame] | 730 | $(call transform-jar-to-proguard) |
Søren Gjesse | 0c1fe64 | 2017-10-12 16:09:13 +0200 | [diff] [blame] | 731 | else # !USE_R8 |
| 732 | # Running R8 instead of Proguard, proguarded jar is actually the pre-Proguarded jar. |
| 733 | full_classes_proguard_jar := $(full_classes_pre_proguard_jar) |
| 734 | endif # !USE_R8 |
Ying Wang | 3b2bdf1 | 2010-02-01 09:51:23 -0800 | [diff] [blame] | 735 | |
Ying Wang | 7311a34 | 2013-08-21 18:32:49 -0700 | [diff] [blame] | 736 | else # LOCAL_PROGUARD_ENABLED not defined |
ShuJie Wang | 76e93ba | 2017-11-06 14:35:52 +0800 | [diff] [blame] | 737 | proguard_flag_files := |
Colin Cross | 950f1ef | 2017-04-05 15:30:42 -0700 | [diff] [blame] | 738 | full_classes_proguard_jar := $(full_classes_pre_proguard_jar) |
Ying Wang | 7311a34 | 2013-08-21 18:32:49 -0700 | [diff] [blame] | 739 | endif # LOCAL_PROGUARD_ENABLED defined |
| 740 | |
Colin Cross | 96476c1 | 2017-04-06 09:56:19 -0700 | [diff] [blame] | 741 | ifneq ($(LOCAL_IS_STATIC_JAVA_LIBRARY),true) |
Colin Cross | 79e2f73 | 2016-12-21 14:29:13 -0800 | [diff] [blame] | 742 | $(built_dex_intermediate): PRIVATE_DX_FLAGS := $(LOCAL_DX_FLAGS) |
Søren Gjesse | 0c1fe64 | 2017-10-12 16:09:13 +0200 | [diff] [blame] | 743 | |
| 744 | my_r8 := |
| 745 | ifdef LOCAL_PROGUARD_ENABLED |
| 746 | ifeq ($(USE_R8),true) |
| 747 | # These are the dependencies for the proguarded jar when running |
| 748 | # Proguard + dx. They are used for the generated dex when using R8, as |
| 749 | # R8 does Proguard + dx |
| 750 | my_r8 := true |
| 751 | $(built_dex_intermediate): PRIVATE_PROGUARD_INJAR_FILTERS := $(proguard_injar_filters) |
| 752 | $(built_dex_intermediate): PRIVATE_EXTRA_INPUT_JAR := $(extra_input_jar) |
| 753 | $(built_dex_intermediate): PRIVATE_PROGUARD_FLAGS := $(legacy_proguard_flags) $(common_proguard_flags) $(LOCAL_PROGUARD_FLAGS) |
Alan Leung | 7d6144d | 2017-11-16 15:51:07 -0800 | [diff] [blame] | 754 | $(built_dex_intermediate) : $(full_classes_proguard_jar) $(extra_input_jar) $(my_support_library_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] | 755 | $(transform-jar-to-dex-r8) |
| 756 | endif # USE_R8 |
| 757 | endif # LOCAL_PROGUARD_ENABLED |
| 758 | |
| 759 | ifndef my_r8 |
Alan Leung | 5eb88c0 | 2017-12-20 20:03:58 -0800 | [diff] [blame] | 760 | $(built_dex_intermediate): $(full_classes_proguard_jar) $(DX) $(ZIP2ZIP) |
Alan Leung | eaafb3c | 2017-12-01 14:32:58 -0800 | [diff] [blame] | 761 | ifneq ($(USE_D8_DESUGAR),true) |
Colin Cross | 79e2f73 | 2016-12-21 14:29:13 -0800 | [diff] [blame] | 762 | $(transform-classes.jar-to-dex) |
Alan Leung | eaafb3c | 2017-12-01 14:32:58 -0800 | [diff] [blame] | 763 | else |
| 764 | $(transform-classes-d8.jar-to-dex) |
| 765 | endif |
Søren Gjesse | 0c1fe64 | 2017-10-12 16:09:13 +0200 | [diff] [blame] | 766 | endif |
Colin Cross | 79e2f73 | 2016-12-21 14:29:13 -0800 | [diff] [blame] | 767 | |
Colin Cross | 0e53734 | 2017-03-29 12:17:36 -0700 | [diff] [blame] | 768 | $(built_dex): $(built_dex_intermediate) |
Guang Zhu | 155afe3 | 2010-03-10 15:48:03 -0800 | [diff] [blame] | 769 | @echo Copying: $@ |
Yohann Roussel | 8ffe9c3 | 2013-08-20 17:05:27 +0200 | [diff] [blame] | 770 | $(hide) mkdir -p $(dir $@) |
| 771 | $(hide) rm -f $(dir $@)/classes*.dex |
Colin Cross | 0e53734 | 2017-03-29 12:17:36 -0700 | [diff] [blame] | 772 | $(hide) cp -fp $(dir $<)/classes*.dex $(dir $@) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 773 | |
Colin Cross | 9eff830 | 2017-04-27 15:05:44 -0700 | [diff] [blame] | 774 | java-dex: $(built_dex) |
| 775 | |
Colin Cross | 96476c1 | 2017-04-06 09:56:19 -0700 | [diff] [blame] | 776 | endif # !LOCAL_IS_STATIC_JAVA_LIBRARY |
| 777 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 778 | findbugs_xml := $(intermediates.COMMON)/findbugs.xml |
Ying Wang | 702e01e | 2015-10-21 10:30:51 -0700 | [diff] [blame] | 779 | $(findbugs_xml): PRIVATE_AUXCLASSPATH := $(addprefix -auxclasspath ,$(strip \ |
| 780 | $(call normalize-path-list,$(filter %.jar,$(full_java_libs))))) |
| 781 | $(findbugs_xml): PRIVATE_FINDBUGS_FLAGS := $(LOCAL_FINDBUGS_FLAGS) |
Colin Cross | 950f1ef | 2017-04-05 15:30:42 -0700 | [diff] [blame] | 782 | $(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] | 783 | @echo Findbugs: $@ |
| 784 | $(hide) $(FINDBUGS) -textui -effort:min -xml:withMessages \ |
Ying Wang | 702e01e | 2015-10-21 10:30:51 -0700 | [diff] [blame] | 785 | $(PRIVATE_AUXCLASSPATH) $(PRIVATE_FINDBUGS_FLAGS) \ |
Yohann Roussel | d2a76c1 | 2015-02-05 16:10:58 +0100 | [diff] [blame] | 786 | $< \ |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 787 | > $@ |
| 788 | |
| 789 | ALL_FINDBUGS_FILES += $(findbugs_xml) |
| 790 | |
| 791 | findbugs_html := $(PRODUCT_OUT)/findbugs/$(LOCAL_MODULE).html |
| 792 | $(findbugs_html) : PRIVATE_XML_FILE := $(findbugs_xml) |
| 793 | $(LOCAL_MODULE)-findbugs : $(findbugs_html) |
| 794 | $(findbugs_html) : $(findbugs_xml) |
| 795 | @mkdir -p $(dir $@) |
Andrew Stadler | cef9ed9 | 2009-05-13 00:44:59 -0700 | [diff] [blame] | 796 | @echo ConvertXmlToText: $@ |
Yuncheol Heo | 623d706 | 2014-05-20 17:04:16 +0900 | [diff] [blame] | 797 | $(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] | 798 | > $@ |
| 799 | |
| 800 | $(LOCAL_MODULE)-findbugs : $(findbugs_html) |
| 801 | |
Ying Wang | 990cf5e | 2013-08-28 13:04:46 -0700 | [diff] [blame] | 802 | endif # full_classes_jar is defined |
Yohann Roussel | b4c49cb | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 803 | |
Colin Cross | 536ef4e | 2017-02-21 16:14:55 -0800 | [diff] [blame] | 804 | ifneq (,$(filter-out current system_current test_current, $(LOCAL_SDK_VERSION))) |
Sundong Ahn | 5a44d1f | 2017-10-16 19:20:34 +0900 | [diff] [blame] | 805 | my_default_app_target_sdk := $(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION)) |
| 806 | my_sdk_version := $(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION)) |
Colin Cross | 536ef4e | 2017-02-21 16:14:55 -0800 | [diff] [blame] | 807 | else |
Colin Cross | 9deb331 | 2017-09-28 16:17:36 -0700 | [diff] [blame] | 808 | my_default_app_target_sdk := $(DEFAULT_APP_TARGET_SDK) |
| 809 | my_sdk_version := $(PLATFORM_SDK_VERSION) |
Colin Cross | 536ef4e | 2017-02-21 16:14:55 -0800 | [diff] [blame] | 810 | endif |
| 811 | |
Colin Cross | 9deb331 | 2017-09-28 16:17:36 -0700 | [diff] [blame] | 812 | ifdef LOCAL_MIN_SDK_VERSION |
| 813 | my_min_sdk_version := $(LOCAL_MIN_SDK_VERSION) |
| 814 | else |
| 815 | my_min_sdk_version := $(call codename-or-sdk-to-sdk,$(my_default_app_target_sdk)) |
| 816 | endif |
| 817 | |
| 818 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_DEFAULT_APP_TARGET_SDK := $(my_default_app_target_sdk) |
| 819 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_SDK_VERSION := $(my_sdk_version) |
| 820 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_MIN_SDK_VERSION := $(my_min_sdk_version) |