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