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