From dc1e028994c5be1950d53a8379619cd90c68104e Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Tue, 20 Mar 2018 15:25:51 -0700 Subject: [PATCH 1/7] Use srcjar and resource zip as output of renderscript rules Replace RenderScript.stamp with a srcjar, with a resource zip as an implicit output. This makes the renderscript rules self contained, which will make it easier to move them before aapt. Bug: 73885582 Test: m checkbuild Change-Id: I12d33e52019aebac6ea33271939228e4690a4173 Merged-In: I12d33e52019aebac6ea33271939228e4690a4173 (cherry picked from commit e00e2fae52ea85c2e7f637d4760743363f9a0bcc) --- CleanSpec.mk | 3 +++ core/definitions.mk | 6 ++--- core/java.mk | 46 +++++++++++++++++-------------------- core/package_internal.mk | 5 ++-- core/static_java_library.mk | 5 ++-- 5 files changed, 30 insertions(+), 35 deletions(-) diff --git a/CleanSpec.mk b/CleanSpec.mk index 5ab64b35a..079aa05e7 100644 --- a/CleanSpec.mk +++ b/CleanSpec.mk @@ -463,6 +463,9 @@ $(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/manifest.xml) $(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/vendor/compatibility_matrix.xml) $(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/compatibility_matrix.xml) +# Remove obsolete intermedates src files +$(call add-clean-step, rm -rf $(TARGET_OUT_COMMON_INTERMEDIATES)/*/*_intermediates/src/RenderScript.stamp*) + # ************************************************ # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST # ************************************************ diff --git a/core/definitions.mk b/core/definitions.mk index b2b3bbbd9..0565603e2 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -1036,9 +1036,9 @@ $(hide) $(RS_CC_ASAN_OPTIONS) $(PRIVATE_RS_CC) \ $(PRIVATE_RS_FLAGS) \ $(foreach inc,$(PRIVATE_RS_INCLUDES),$(addprefix -I , $(inc))) \ $(PRIVATE_RS_SOURCE_FILES) +$(SOONG_ZIP) -o $@ -C $(PRIVATE_RS_OUTPUT_DIR)/src -D $(PRIVATE_RS_OUTPUT_DIR)/src +$(SOONG_ZIP) -o $(PRIVATE_RS_OUTPUT_RES_ZIP) -C $(PRIVATE_RS_OUTPUT_DIR)/res -D $(PRIVATE_RS_OUTPUT_DIR)/res $(call _merge-renderscript-d,$(PRIVATE_DEP_FILES),$@.d) -$(hide) mkdir -p $(dir $@) -$(hide) touch $@ endef define transform-bc-to-so @@ -2212,8 +2212,6 @@ $(hide) if [ -d "$(PRIVATE_SOURCE_INTERMEDIATES_DIR)" ]; then \ fi $(if $(PRIVATE_HAS_PROTO_SOURCES), \ $(hide) find $(PRIVATE_PROTO_SOURCE_INTERMEDIATES_DIR) -name '*.java' -and -not -name '.*' >> $(1)) -$(if $(PRIVATE_HAS_RS_SOURCES), \ - $(hide) find $(PRIVATE_RS_SOURCE_INTERMEDIATES_DIR) -name '*.java' -and -not -name '.*' >> $(1)) endef # Some historical notes: diff --git a/core/java.mk b/core/java.mk index e2639068e..aa63d5ad7 100644 --- a/core/java.mk +++ b/core/java.mk @@ -110,15 +110,16 @@ LOCAL_INTERMEDIATE_SOURCE_DIR := $(intermediates.COMMON)/src ## .rs files: RenderScript sources to .java files and .bc files ############################################################### renderscript_sources := $(filter %.rs,$(LOCAL_SRC_FILES)) -# Because names of the java files from RenderScript are unknown until the -# .rs file(s) are compiled, we have to depend on a timestamp file. -RenderScript_file_stamp := -rs_generated_res_dir := +rs_generated_res_zip := +rs_generated_src_jar := rs_compatibility_jni_libs := ifneq ($(renderscript_sources),) renderscript_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(renderscript_sources)) -RenderScript_file_stamp := $(LOCAL_INTERMEDIATE_SOURCE_DIR)/RenderScript.stamp renderscript_intermediate.COMMON := $(intermediates.COMMON)/renderscript +rs_generated_res_zip := $(renderscript_intermediate.COMMON)/res.zip +rs_generated_src_jar := $(renderscript_intermediate.COMMON)/rs.srcjar + +LOCAL_SRCJARS += $(rs_generated_src_jar) # Defaulting to an empty string uses the latest available platform SDK. renderscript_target_api := @@ -173,20 +174,20 @@ endif bc_files := $(patsubst %.rs,%.bc, $(notdir $(renderscript_sources))) bc_dep_files := $(addprefix $(renderscript_intermediate.COMMON)/,$(patsubst %.bc,%.d,$(bc_files))) -$(RenderScript_file_stamp): PRIVATE_RS_INCLUDES := $(LOCAL_RENDERSCRIPT_INCLUDES) -$(RenderScript_file_stamp): PRIVATE_RS_CC := $(LOCAL_RENDERSCRIPT_CC) -$(RenderScript_file_stamp): PRIVATE_RS_FLAGS := $(renderscript_flags) -$(RenderScript_file_stamp): PRIVATE_RS_SOURCE_FILES := $(renderscript_sources_fullpath) -# By putting the generated java files into $(LOCAL_INTERMEDIATE_SOURCE_DIR), they will be -# automatically found by the java compiling function transform-java-to-classes.jar. -$(RenderScript_file_stamp): PRIVATE_RS_OUTPUT_DIR := $(renderscript_intermediate.COMMON) -$(RenderScript_file_stamp): PRIVATE_RS_TARGET_API := $(renderscript_target_api) -$(RenderScript_file_stamp): PRIVATE_DEP_FILES := $(bc_dep_files) -$(RenderScript_file_stamp): $(renderscript_sources_fullpath) $(LOCAL_RENDERSCRIPT_CC) +$(rs_generated_src_jar): PRIVATE_RS_INCLUDES := $(LOCAL_RENDERSCRIPT_INCLUDES) +$(rs_generated_src_jar): PRIVATE_RS_CC := $(LOCAL_RENDERSCRIPT_CC) +$(rs_generated_src_jar): PRIVATE_RS_FLAGS := $(renderscript_flags) +$(rs_generated_src_jar): PRIVATE_RS_SOURCE_FILES := $(renderscript_sources_fullpath) +$(rs_generated_src_jar): PRIVATE_RS_OUTPUT_DIR := $(renderscript_intermediate.COMMON) +$(rs_generated_src_jar): PRIVATE_RS_TARGET_API := $(renderscript_target_api) +$(rs_generated_src_jar): PRIVATE_DEP_FILES := $(bc_dep_files) +$(rs_generated_src_jar): PRIVATE_RS_OUTPUT_RES_ZIP := $(rs_generated_res_zip) +$(rs_generated_src_jar): .KATI_IMPLICIT_OUTPUTS := $(rs_generated_res_zip) +$(rs_generated_src_jar): $(renderscript_sources_fullpath) $(LOCAL_RENDERSCRIPT_CC) $(SOONG_ZIP) $(transform-renderscripts-to-java-and-bc) # include the dependency files (.d/.P) generated by llvm-rs-cc. -$(call include-depfile,$(RenderScript_file_stamp).P,$(RenderScript_file_stamp)) +$(call include-depfile,$(rs_generated_src_jar).P,$(rs_generated_src_jar)) ifneq ($(LOCAL_RENDERSCRIPT_COMPATIBILITY),) @@ -219,7 +220,7 @@ rs_compatibility_jni_libs := $(addprefix \ $(renderscript_intermediate)/librs., \ $(patsubst %.bc,%.so, $(bc_files))) -$(rs_generated_bc) : $(RenderScript_file_stamp) +$(rs_generated_src_jar): .KATI_IMPLICIT_OUTPUTS += $(rs_generated_bc) rs_support_lib := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/libRSSupport.so LOCAL_JNI_SHARED_LIBRARIES += libRSSupport @@ -238,7 +239,7 @@ else my_min_sdk_version := $(MIN_SUPPORTED_SDK_VERSION) endif -$(rs_compatibility_jni_libs): $(RenderScript_file_stamp) $(RS_PREBUILT_CLCORE) \ +$(rs_compatibility_jni_libs): $(RS_PREBUILT_CLCORE) \ $(rs_support_lib) $(rs_support_io_lib) $(rs_jni_lib) $(rs_compiler_rt) $(rs_compatibility_jni_libs): $(BCC_COMPAT) $(rs_compatibility_jni_libs): PRIVATE_CXX := $(CXX_WRAPPER) $(TARGET_CXX) @@ -252,10 +253,9 @@ endif endif -LOCAL_INTERMEDIATE_TARGETS += $(RenderScript_file_stamp) +LOCAL_INTERMEDIATE_TARGETS += $(rs_generated_src_jar) # Make sure the generated resource will be added to the apk. -rs_generated_res_dir := $(renderscript_intermediate.COMMON)/res -LOCAL_RESOURCE_DIR := $(rs_generated_res_dir) $(LOCAL_RESOURCE_DIR) +LOCAL_RESOURCE_DIR := $(renderscript_intermediate.COMMON)/res $(LOCAL_RESOURCE_DIR) endif @@ -334,9 +334,6 @@ include $(BUILD_SYSTEM)/java_common.mk include $(BUILD_SYSTEM)/sdk_check.mk -$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HAS_RS_SOURCES := $(if $(renderscript_sources),true) -$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RS_SOURCE_INTERMEDIATES_DIR := $(intermediates.COMMON)/renderscript - # Set the profile source so that the odex / profile code included from java.mk # can find it. # @@ -403,7 +400,6 @@ endif java_sources_deps := \ $(java_sources) \ $(java_resource_sources) \ - $(RenderScript_file_stamp) \ $(proto_java_sources_file_stamp) \ $(LOCAL_SRCJARS) \ $(LOCAL_ADDITIONAL_DEPENDENCIES) diff --git a/core/package_internal.mk b/core/package_internal.mk index 858a1bfb7..9f37a917f 100644 --- a/core/package_internal.mk +++ b/core/package_internal.mk @@ -402,8 +402,7 @@ endif # LOCAL_SDK_VERSION is set endif # LOCAL_RENDERSCRIPT_TARGET_API is set ifneq (,$(renderscript_target_api)) ifneq ($(call math_gt_or_eq,$(renderscript_target_api),21),true) -my_generated_res_dirs := $(rs_generated_res_dir) -my_generated_res_dirs_deps := $(RenderScript_file_stamp) +my_generated_res_zips := $(rs_generated_res_zip) endif # renderscript_target_api < 21 endif # renderscript_target_api is set my_asset_dirs := $(LOCAL_ASSET_DIR) @@ -431,7 +430,7 @@ $(R_file_stamp): PRIVATE_RESOURCE_PUBLICS_OUTPUT := \ $(intermediates.COMMON)/public_resources.xml $(R_file_stamp): PRIVATE_PROGUARD_OPTIONS_FILE := $(proguard_options_file) $(R_file_stamp): PRIVATE_RESOURCE_LIST := $(all_res_assets) -$(R_file_stamp): $(all_res_assets) $(full_android_manifest) $(RenderScript_file_stamp) $(AAPT) | $(ACP) +$(R_file_stamp): $(all_res_assets) $(full_android_manifest) $(rs_generated_res_zip) $(AAPT) | $(ACP) @echo "target R.java/Manifest.java: $(PRIVATE_MODULE) ($@)" @rm -rf $@ && mkdir -p $(dir $@) $(create-resource-java-files) diff --git a/core/static_java_library.mk b/core/static_java_library.mk index 64e16c2c6..cb8527dc9 100644 --- a/core/static_java_library.mk +++ b/core/static_java_library.mk @@ -171,15 +171,14 @@ endif # LOCAL_SDK_VERSION is set endif # LOCAL_RENDERSCRIPT_TARGET_API is set ifneq (,$(renderscript_target_api)) ifneq ($(call math_gt_or_eq,$(renderscript_target_api),21),true) -my_generated_res_dirs := $(rs_generated_res_dir) -my_generated_res_dirs_deps := $(RenderScript_file_stamp) +my_generated_res_zips := $(rs_generated_res_zip) endif # renderscript_target_api < 21 endif # renderscript_target_api is set include $(BUILD_SYSTEM)/aapt2.mk $(my_res_package) : $(framework_res_package_export) else $(R_file_stamp): PRIVATE_RESOURCE_LIST := $(all_resources) -$(R_file_stamp) : $(all_resources) $(full_android_manifest) $(AAPT) $(framework_res_package_export) +$(R_file_stamp) : $(all_resources) $(full_android_manifest) $(AAPT) $(framework_res_package_export) $(rs_generated_res_zip) @echo "target R.java/Manifest.java: $(PRIVATE_MODULE) ($@)" $(create-resource-java-files) $(hide) find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) -name R.java | xargs cat > $@ From 1e047d39a5be0b0f81aaad8db1d9dc7d7e32b1d6 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Mon, 12 Mar 2018 18:23:15 -0700 Subject: [PATCH 2/7] Move java renderscript support to java_renderscript.mk Move java renderscript support to java_renderscript.mk in preparation to moving it before aapt. Filter *.rs files out of LOCAL_SRC_FILES and forbid them in java_common.mk so that using *.rs files is an error if java_renderscript.mk was not included. Bug: 73885582 Test: m checkbuild Change-Id: Ib37ce89daee58b025dec98f733c5a08149641afd Merged-In: Ib37ce89daee58b025dec98f733c5a08149641afd (cherry picked from commit 71822d6fb96facf4907a68d5401d7df22f3dc144) --- core/java.mk | 150 +----------------------------------- core/java_common.mk | 2 +- core/java_renderscript.mk | 155 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 157 insertions(+), 150 deletions(-) create mode 100644 core/java_renderscript.mk diff --git a/core/java.mk b/core/java.mk index aa63d5ad7..6ee2c043d 100644 --- a/core/java.mk +++ b/core/java.mk @@ -109,155 +109,7 @@ LOCAL_INTERMEDIATE_SOURCE_DIR := $(intermediates.COMMON)/src ############################################################### ## .rs files: RenderScript sources to .java files and .bc files ############################################################### -renderscript_sources := $(filter %.rs,$(LOCAL_SRC_FILES)) -rs_generated_res_zip := -rs_generated_src_jar := -rs_compatibility_jni_libs := -ifneq ($(renderscript_sources),) -renderscript_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(renderscript_sources)) -renderscript_intermediate.COMMON := $(intermediates.COMMON)/renderscript -rs_generated_res_zip := $(renderscript_intermediate.COMMON)/res.zip -rs_generated_src_jar := $(renderscript_intermediate.COMMON)/rs.srcjar - -LOCAL_SRCJARS += $(rs_generated_src_jar) - -# Defaulting to an empty string uses the latest available platform SDK. -renderscript_target_api := - -ifneq (,$(LOCAL_RENDERSCRIPT_TARGET_API)) - renderscript_target_api := $(LOCAL_RENDERSCRIPT_TARGET_API) -else - ifneq (,$(LOCAL_SDK_VERSION)) - # Set target-api for LOCAL_SDK_VERSIONs other than current. - ifneq (,$(filter-out current system_current test_current core_current, $(LOCAL_SDK_VERSION))) - renderscript_target_api := $(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION)) - endif - endif # LOCAL_SDK_VERSION is set -endif # LOCAL_RENDERSCRIPT_TARGET_API is set - -# For 64-bit, we always have to upgrade to at least 21 for compat build. -ifneq ($(LOCAL_RENDERSCRIPT_COMPATIBILITY),) - ifeq ($(TARGET_IS_64_BIT),true) - ifneq ($(filter $(RSCOMPAT_32BIT_ONLY_API_LEVELS),$(renderscript_target_api)),) - renderscript_target_api := 21 - endif - endif -endif - -ifeq ($(LOCAL_RENDERSCRIPT_CC),) -LOCAL_RENDERSCRIPT_CC := $(LLVM_RS_CC) -endif - -# Turn on all warnings and warnings as errors for RS compiles. -# This can be disabled with LOCAL_RENDERSCRIPT_FLAGS := -Wno-error -renderscript_flags := -Wall -Werror -renderscript_flags += $(LOCAL_RENDERSCRIPT_FLAGS) - -# prepend the RenderScript system include path -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))),) -# if a numeric LOCAL_SDK_VERSION, or current LOCAL_SDK_VERSION with TARGET_BUILD_APPS -LOCAL_RENDERSCRIPT_INCLUDES := \ - $(HISTORICAL_SDK_VERSIONS_ROOT)/renderscript/clang-include \ - $(HISTORICAL_SDK_VERSIONS_ROOT)/renderscript/include \ - $(LOCAL_RENDERSCRIPT_INCLUDES) -else -LOCAL_RENDERSCRIPT_INCLUDES := \ - $(TOPDIR)external/clang/lib/Headers \ - $(TOPDIR)frameworks/rs/script_api/include \ - $(LOCAL_RENDERSCRIPT_INCLUDES) -endif - -ifneq ($(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE),) -LOCAL_RENDERSCRIPT_INCLUDES := $(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE) -endif - -bc_files := $(patsubst %.rs,%.bc, $(notdir $(renderscript_sources))) -bc_dep_files := $(addprefix $(renderscript_intermediate.COMMON)/,$(patsubst %.bc,%.d,$(bc_files))) - -$(rs_generated_src_jar): PRIVATE_RS_INCLUDES := $(LOCAL_RENDERSCRIPT_INCLUDES) -$(rs_generated_src_jar): PRIVATE_RS_CC := $(LOCAL_RENDERSCRIPT_CC) -$(rs_generated_src_jar): PRIVATE_RS_FLAGS := $(renderscript_flags) -$(rs_generated_src_jar): PRIVATE_RS_SOURCE_FILES := $(renderscript_sources_fullpath) -$(rs_generated_src_jar): PRIVATE_RS_OUTPUT_DIR := $(renderscript_intermediate.COMMON) -$(rs_generated_src_jar): PRIVATE_RS_TARGET_API := $(renderscript_target_api) -$(rs_generated_src_jar): PRIVATE_DEP_FILES := $(bc_dep_files) -$(rs_generated_src_jar): PRIVATE_RS_OUTPUT_RES_ZIP := $(rs_generated_res_zip) -$(rs_generated_src_jar): .KATI_IMPLICIT_OUTPUTS := $(rs_generated_res_zip) -$(rs_generated_src_jar): $(renderscript_sources_fullpath) $(LOCAL_RENDERSCRIPT_CC) $(SOONG_ZIP) - $(transform-renderscripts-to-java-and-bc) - -# include the dependency files (.d/.P) generated by llvm-rs-cc. -$(call include-depfile,$(rs_generated_src_jar).P,$(rs_generated_src_jar)) - -ifneq ($(LOCAL_RENDERSCRIPT_COMPATIBILITY),) - - -ifeq ($(filter $(RSCOMPAT_32BIT_ONLY_API_LEVELS),$(renderscript_target_api)),) -ifeq ($(TARGET_IS_64_BIT),true) -renderscript_intermediate.bc_folder := $(renderscript_intermediate.COMMON)/res/raw/bc64/ -else -renderscript_intermediate.bc_folder := $(renderscript_intermediate.COMMON)/res/raw/bc32/ -endif -else -renderscript_intermediate.bc_folder := $(renderscript_intermediate.COMMON)/res/raw/ -endif - -rs_generated_bc := $(addprefix \ - $(renderscript_intermediate.bc_folder), $(bc_files)) - -renderscript_intermediate := $(intermediates)/renderscript - -# We don't need the .so files in bundled branches -# Prevent these from showing up on the device -# One exception is librsjni.so, which is needed for -# both native path and compat path. -rs_jni_lib := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/librsjni.so -LOCAL_JNI_SHARED_LIBRARIES += librsjni - -ifneq (,$(TARGET_BUILD_APPS)$(FORCE_BUILD_RS_COMPAT)) - -rs_compatibility_jni_libs := $(addprefix \ - $(renderscript_intermediate)/librs., \ - $(patsubst %.bc,%.so, $(bc_files))) - -$(rs_generated_src_jar): .KATI_IMPLICIT_OUTPUTS += $(rs_generated_bc) - -rs_support_lib := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/libRSSupport.so -LOCAL_JNI_SHARED_LIBRARIES += libRSSupport - -rs_support_io_lib := -# check if the target api level support USAGE_IO -ifeq ($(filter $(RSCOMPAT_NO_USAGEIO_API_LEVELS),$(renderscript_target_api)),) -rs_support_io_lib := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/libRSSupportIO.so -LOCAL_JNI_SHARED_LIBRARIES += libRSSupportIO -endif - -my_arch := $(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH) -ifneq (,$(filter arm64 mips64 x86_64,$(my_arch))) - my_min_sdk_version := 21 -else - my_min_sdk_version := $(MIN_SUPPORTED_SDK_VERSION) -endif - -$(rs_compatibility_jni_libs): $(RS_PREBUILT_CLCORE) \ - $(rs_support_lib) $(rs_support_io_lib) $(rs_jni_lib) $(rs_compiler_rt) -$(rs_compatibility_jni_libs): $(BCC_COMPAT) -$(rs_compatibility_jni_libs): PRIVATE_CXX := $(CXX_WRAPPER) $(TARGET_CXX) -$(rs_compatibility_jni_libs): PRIVATE_SDK_VERSION := $(my_min_sdk_version) -$(rs_compatibility_jni_libs): $(renderscript_intermediate)/librs.%.so: \ - $(renderscript_intermediate.bc_folder)%.bc \ - $(SOONG_OUT_DIR)/ndk.timestamp - $(transform-bc-to-so) - -endif - -endif - -LOCAL_INTERMEDIATE_TARGETS += $(rs_generated_src_jar) -# Make sure the generated resource will be added to the apk. -LOCAL_RESOURCE_DIR := $(renderscript_intermediate.COMMON)/res $(LOCAL_RESOURCE_DIR) -endif - +include $(BUILD_SYSTEM)/java_renderscript.mk ########################################################### ## AIDL: Compile .aidl files to .java diff --git a/core/java_common.mk b/core/java_common.mk index dea0435dc..44ee4b234 100644 --- a/core/java_common.mk +++ b/core/java_common.mk @@ -177,7 +177,7 @@ endif # java_resource_file_groups ##################################### ## Warn if there is unrecognized file in LOCAL_SRC_FILES. my_unknown_src_files := $(filter-out \ - %.java %.aidl %.proto %.logtags %.rs, \ + %.java %.aidl %.proto %.logtags, \ $(LOCAL_SRC_FILES) $(LOCAL_INTERMEDIATE_SOURCES) $(LOCAL_GENERATED_SOURCES)) ifneq ($(my_unknown_src_files),) $(warning $(LOCAL_MODULE_MAKEFILE): $(LOCAL_MODULE): Unused source files: $(my_unknown_src_files)) diff --git a/core/java_renderscript.mk b/core/java_renderscript.mk new file mode 100644 index 000000000..191b3be6a --- /dev/null +++ b/core/java_renderscript.mk @@ -0,0 +1,155 @@ +############################################################### +## Renderscript support for java +## Adds rules to convert .rs files to .java and .bc files +############################################################### + +renderscript_sources := $(filter %.rs,$(LOCAL_SRC_FILES)) +LOCAL_SRC_FILES := $(filter-out %.rs,$(LOCAL_SRC_FILES)) + +rs_generated_res_zip := +rs_generated_src_jar := +rs_compatibility_jni_libs := +ifneq ($(renderscript_sources),) +renderscript_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(renderscript_sources)) +renderscript_intermediate.COMMON := $(intermediates.COMMON)/renderscript +rs_generated_res_zip := $(renderscript_intermediate.COMMON)/res.zip +rs_generated_src_jar := $(renderscript_intermediate.COMMON)/rs.srcjar + +LOCAL_SRCJARS += $(rs_generated_src_jar) + +# Defaulting to an empty string uses the latest available platform SDK. +renderscript_target_api := + +ifneq (,$(LOCAL_RENDERSCRIPT_TARGET_API)) + renderscript_target_api := $(LOCAL_RENDERSCRIPT_TARGET_API) +else + ifneq (,$(LOCAL_SDK_VERSION)) + # Set target-api for LOCAL_SDK_VERSIONs other than current. + ifneq (,$(filter-out current system_current test_current core_current, $(LOCAL_SDK_VERSION))) + renderscript_target_api := $(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION)) + endif + endif # LOCAL_SDK_VERSION is set +endif # LOCAL_RENDERSCRIPT_TARGET_API is set + +# For 64-bit, we always have to upgrade to at least 21 for compat build. +ifneq ($(LOCAL_RENDERSCRIPT_COMPATIBILITY),) + ifeq ($(TARGET_IS_64_BIT),true) + ifneq ($(filter $(RSCOMPAT_32BIT_ONLY_API_LEVELS),$(renderscript_target_api)),) + renderscript_target_api := 21 + endif + endif +endif + +ifeq ($(LOCAL_RENDERSCRIPT_CC),) +LOCAL_RENDERSCRIPT_CC := $(LLVM_RS_CC) +endif + +# Turn on all warnings and warnings as errors for RS compiles. +# This can be disabled with LOCAL_RENDERSCRIPT_FLAGS := -Wno-error +renderscript_flags := -Wall -Werror +renderscript_flags += $(LOCAL_RENDERSCRIPT_FLAGS) + +# prepend the RenderScript system include path +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))),) +# if a numeric LOCAL_SDK_VERSION, or current LOCAL_SDK_VERSION with TARGET_BUILD_APPS +LOCAL_RENDERSCRIPT_INCLUDES := \ + $(HISTORICAL_SDK_VERSIONS_ROOT)/renderscript/clang-include \ + $(HISTORICAL_SDK_VERSIONS_ROOT)/renderscript/include \ + $(LOCAL_RENDERSCRIPT_INCLUDES) +else +LOCAL_RENDERSCRIPT_INCLUDES := \ + $(TOPDIR)external/clang/lib/Headers \ + $(TOPDIR)frameworks/rs/script_api/include \ + $(LOCAL_RENDERSCRIPT_INCLUDES) +endif + +ifneq ($(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE),) +LOCAL_RENDERSCRIPT_INCLUDES := $(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE) +endif + +bc_files := $(patsubst %.rs,%.bc, $(notdir $(renderscript_sources))) +bc_dep_files := $(addprefix $(renderscript_intermediate.COMMON)/,$(patsubst %.bc,%.d,$(bc_files))) + +$(rs_generated_src_jar): PRIVATE_RS_INCLUDES := $(LOCAL_RENDERSCRIPT_INCLUDES) +$(rs_generated_src_jar): PRIVATE_RS_CC := $(LOCAL_RENDERSCRIPT_CC) +$(rs_generated_src_jar): PRIVATE_RS_FLAGS := $(renderscript_flags) +$(rs_generated_src_jar): PRIVATE_RS_SOURCE_FILES := $(renderscript_sources_fullpath) +$(rs_generated_src_jar): PRIVATE_RS_OUTPUT_DIR := $(renderscript_intermediate.COMMON) +$(rs_generated_src_jar): PRIVATE_RS_TARGET_API := $(renderscript_target_api) +$(rs_generated_src_jar): PRIVATE_DEP_FILES := $(bc_dep_files) +$(rs_generated_src_jar): PRIVATE_RS_OUTPUT_RES_ZIP := $(rs_generated_res_zip) +$(rs_generated_src_jar): .KATI_IMPLICIT_OUTPUTS := $(rs_generated_res_zip) +$(rs_generated_src_jar): $(renderscript_sources_fullpath) $(LOCAL_RENDERSCRIPT_CC) $(SOONG_ZIP) + $(transform-renderscripts-to-java-and-bc) + +# include the dependency files (.d/.P) generated by llvm-rs-cc. +$(call include-depfile,$(rs_generated_src_jar).P,$(rs_generated_src_jar)) + +ifneq ($(LOCAL_RENDERSCRIPT_COMPATIBILITY),) + + +ifeq ($(filter $(RSCOMPAT_32BIT_ONLY_API_LEVELS),$(renderscript_target_api)),) +ifeq ($(TARGET_IS_64_BIT),true) +renderscript_intermediate.bc_folder := $(renderscript_intermediate.COMMON)/res/raw/bc64/ +else +renderscript_intermediate.bc_folder := $(renderscript_intermediate.COMMON)/res/raw/bc32/ +endif +else +renderscript_intermediate.bc_folder := $(renderscript_intermediate.COMMON)/res/raw/ +endif + +rs_generated_bc := $(addprefix \ + $(renderscript_intermediate.bc_folder), $(bc_files)) + +renderscript_intermediate := $(intermediates)/renderscript + +# We don't need the .so files in bundled branches +# Prevent these from showing up on the device +# One exception is librsjni.so, which is needed for +# both native path and compat path. +rs_jni_lib := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/librsjni.so +LOCAL_JNI_SHARED_LIBRARIES += librsjni + +ifneq (,$(TARGET_BUILD_APPS)$(FORCE_BUILD_RS_COMPAT)) + +rs_compatibility_jni_libs := $(addprefix \ + $(renderscript_intermediate)/librs., \ + $(patsubst %.bc,%.so, $(bc_files))) + +$(rs_generated_src_jar): .KATI_IMPLICIT_OUTPUTS += $(rs_generated_bc) + +rs_support_lib := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/libRSSupport.so +LOCAL_JNI_SHARED_LIBRARIES += libRSSupport + +rs_support_io_lib := +# check if the target api level support USAGE_IO +ifeq ($(filter $(RSCOMPAT_NO_USAGEIO_API_LEVELS),$(renderscript_target_api)),) +rs_support_io_lib := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/libRSSupportIO.so +LOCAL_JNI_SHARED_LIBRARIES += libRSSupportIO +endif + +my_arch := $(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH) +ifneq (,$(filter arm64 mips64 x86_64,$(my_arch))) + my_min_sdk_version := 21 +else + my_min_sdk_version := $(MIN_SUPPORTED_SDK_VERSION) +endif + +$(rs_compatibility_jni_libs): $(RS_PREBUILT_CLCORE) \ + $(rs_support_lib) $(rs_support_io_lib) $(rs_jni_lib) $(rs_compiler_rt) +$(rs_compatibility_jni_libs): $(BCC_COMPAT) +$(rs_compatibility_jni_libs): PRIVATE_CXX := $(CXX_WRAPPER) $(TARGET_CXX) +$(rs_compatibility_jni_libs): PRIVATE_SDK_VERSION := $(my_min_sdk_version) +$(rs_compatibility_jni_libs): $(renderscript_intermediate)/librs.%.so: \ + $(renderscript_intermediate.bc_folder)%.bc \ + $(SOONG_OUT_DIR)/ndk.timestamp + $(transform-bc-to-so) + +endif + +endif + +LOCAL_INTERMEDIATE_TARGETS += $(rs_generated_src_jar) +# Make sure the generated resource will be added to the apk. +LOCAL_RESOURCE_DIR := $(renderscript_intermediate.COMMON)/res $(LOCAL_RESOURCE_DIR) +endif From 39772feddea5adbc0a85232da60e9a3a728c9759 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Tue, 13 Mar 2018 09:41:27 -0700 Subject: [PATCH 3/7] Remove redundant renderscript_target_api computation renderscript_target_api is set by java_renderscript.mk, it doesn't need to be computed again in static_java_library.mk and package_internal.mk. Bug: 73885582 Test: no change to ninja file Change-Id: Ib6e00be425c385f4911def19ed5042a740f2c79b Merged-In: Ib6e00be425c385f4911def19ed5042a740f2c79b (cherry picked from commit 55cce2336028f1a6e0403eded4b9fea5b5514bba) --- core/package_internal.mk | 11 ----------- core/static_java_library.mk | 11 ----------- 2 files changed, 22 deletions(-) diff --git a/core/package_internal.mk b/core/package_internal.mk index 9f37a917f..4071e5291 100644 --- a/core/package_internal.mk +++ b/core/package_internal.mk @@ -389,17 +389,6 @@ endif ifdef LOCAL_USE_AAPT2 my_compiled_res_base_dir := $(intermediates.COMMON)/flat-res -renderscript_target_api := -ifneq (,$(LOCAL_RENDERSCRIPT_TARGET_API)) -renderscript_target_api := $(LOCAL_RENDERSCRIPT_TARGET_API) -else -ifneq (,$(LOCAL_SDK_VERSION)) -# Set target-api for LOCAL_SDK_VERSIONs other than current. -ifneq (,$(filter-out current system_current test_current core_current, $(LOCAL_SDK_VERSION))) -renderscript_target_api := $(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION)) -endif -endif # LOCAL_SDK_VERSION is set -endif # LOCAL_RENDERSCRIPT_TARGET_API is set ifneq (,$(renderscript_target_api)) ifneq ($(call math_gt_or_eq,$(renderscript_target_api),21),true) my_generated_res_zips := $(rs_generated_res_zip) diff --git a/core/static_java_library.mk b/core/static_java_library.mk index cb8527dc9..4a8d10325 100644 --- a/core/static_java_library.mk +++ b/core/static_java_library.mk @@ -158,17 +158,6 @@ $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_MANIFEST_INSTRUMENTATION_FOR := ifdef LOCAL_USE_AAPT2 # One more level with name res so we can zip up the flat resources that can be linked by apps. my_compiled_res_base_dir := $(intermediates.COMMON)/flat-res/res -renderscript_target_api := -ifneq (,$(LOCAL_RENDERSCRIPT_TARGET_API)) -renderscript_target_api := $(LOCAL_RENDERSCRIPT_TARGET_API) -else -ifneq (,$(LOCAL_SDK_VERSION)) -# Set target-api for LOCAL_SDK_VERSIONs other than current. -ifneq (,$(filter-out current system_current test_current core_current, $(LOCAL_SDK_VERSION))) -renderscript_target_api := $(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION)) -endif -endif # LOCAL_SDK_VERSION is set -endif # LOCAL_RENDERSCRIPT_TARGET_API is set ifneq (,$(renderscript_target_api)) ifneq ($(call math_gt_or_eq,$(renderscript_target_api),21),true) my_generated_res_zips := $(rs_generated_res_zip) From 7a28158b905a0b42181ed9dc16d66b431d8320f8 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Tue, 6 Mar 2018 16:21:36 -0800 Subject: [PATCH 4/7] Move aapt2.mk before java.mk aapt2.mk will export a srcjar that will be compiled by java.mk, so it needs to be evaluated first. Also move java_renderscript.mk before aapt2.mk so that the generated resoures are available. Bug: 73885582 Test: m checkbuild Test: rm -rf out/target/common/obj/APPS/RsHelloCompute_intermediates && m out/target/common/obj/APPS/RsHelloCompute_intermediates/src/R.stamp Change-Id: Ide3050ec993a945f7077b75e952c3b3532306ede Merged-In: Ide3050ec993a945f7077b75e952c3b3532306ede (cherry picked from commit 8528eabbba28fc5e554165cb75785682dbd68679) --- core/aapt_flags.mk | 5 - core/java.mk | 5 - core/package_internal.mk | 208 ++++++++++++++++++++---------------- core/static_java_library.mk | 38 ++++--- 4 files changed, 141 insertions(+), 115 deletions(-) diff --git a/core/aapt_flags.mk b/core/aapt_flags.mk index 4e3493aff..13d4817e6 100644 --- a/core/aapt_flags.mk +++ b/core/aapt_flags.mk @@ -13,8 +13,3 @@ ifdef LOCAL_AAPT_FLAGS aapt_flags := endif endif - -$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) -$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_AAPT_CHARACTERISTICS := $(TARGET_AAPT_CHARACTERISTICS) -$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_MANIFEST_PACKAGE_NAME := $(LOCAL_MANIFEST_PACKAGE_NAME) -$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_MANIFEST_INSTRUMENTATION_FOR := $(LOCAL_MANIFEST_INSTRUMENTATION_FOR) diff --git a/core/java.mk b/core/java.mk index 6ee2c043d..9823c133b 100644 --- a/core/java.mk +++ b/core/java.mk @@ -106,11 +106,6 @@ LOCAL_INTERMEDIATE_TARGETS += \ LOCAL_INTERMEDIATE_SOURCE_DIR := $(intermediates.COMMON)/src -############################################################### -## .rs files: RenderScript sources to .java files and .bc files -############################################################### -include $(BUILD_SYSTEM)/java_renderscript.mk - ########################################################### ## AIDL: Compile .aidl files to .java ########################################################### diff --git a/core/package_internal.mk b/core/package_internal.mk index 4071e5291..0385d9169 100644 --- a/core/package_internal.mk +++ b/core/package_internal.mk @@ -322,12 +322,118 @@ endif include $(BUILD_SYSTEM)/android_manifest.mk +resource_export_package := + +include $(BUILD_SYSTEM)/java_renderscript.mk + +include $(BUILD_SYSTEM)/aapt_flags.mk + +ifeq ($(need_compile_res),true) + +############################### +## APK splits +built_apk_splits := +installed_apk_splits := +my_apk_split_configs := + +ifdef LOCAL_PACKAGE_SPLITS +ifdef LOCAL_COMPRESSED_MODULE +$(error $(LOCAL_MODULE): LOCAL_COMPRESSED_MODULE is not currently supported for split installs) +endif # LOCAL_COMPRESSED_MODULE + +my_apk_split_configs := $(LOCAL_PACKAGE_SPLITS) +my_split_suffixes := $(subst $(comma),_,$(my_apk_split_configs)) +built_apk_splits := $(foreach s,$(my_split_suffixes),$(intermediates)/package_$(s).apk) +endif + +$(R_file_stamp) $(my_res_package): PRIVATE_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) +$(R_file_stamp) $(my_res_package): PRIVATE_TARGET_AAPT_CHARACTERISTICS := $(TARGET_AAPT_CHARACTERISTICS) +$(R_file_stamp) $(my_res_package): PRIVATE_MANIFEST_PACKAGE_NAME := $(LOCAL_MANIFEST_PACKAGE_NAME) +$(R_file_stamp) $(my_res_package): PRIVATE_MANIFEST_INSTRUMENTATION_FOR := $(LOCAL_MANIFEST_INSTRUMENTATION_FOR) + +############################### +## AAPT/AAPT2 + +ifdef LOCAL_USE_AAPT2 + my_compiled_res_base_dir := $(intermediates.COMMON)/flat-res + ifneq (,$(renderscript_target_api)) + ifneq ($(call math_gt_or_eq,$(renderscript_target_api),21),true) + my_generated_res_zips := $(rs_generated_res_zip) + endif # renderscript_target_api < 21 + endif # renderscript_target_api is set + my_asset_dirs := $(LOCAL_ASSET_DIR) + my_full_asset_paths := $(all_assets) + + # Add AAPT2 link specific flags. + $(my_res_package): PRIVATE_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) + ifndef LOCAL_AAPT_NAMESPACES + $(my_res_package): PRIVATE_AAPT_FLAGS += --no-static-lib-packages + endif + + include $(BUILD_SYSTEM)/aapt2.mk +else # LOCAL_USE_AAPT2 + + # Since we don't know where the real R.java file is going to end up, + # we need to use another file to stand in its place. We'll just + # copy the generated file to src/R.stamp, which means it will + # have the same contents and timestamp as the actual file. + # + # At the same time, this will copy the R.java file to a central + # 'R' directory to make it easier to add the files to an IDE. + # + + $(R_file_stamp): PRIVATE_RESOURCE_PUBLICS_OUTPUT := \ + $(intermediates.COMMON)/public_resources.xml + $(R_file_stamp): PRIVATE_PROGUARD_OPTIONS_FILE := $(proguard_options_file) + $(R_file_stamp): PRIVATE_RESOURCE_LIST := $(all_res_assets) + $(R_file_stamp): $(all_res_assets) $(full_android_manifest) $(rs_generated_res_zip) $(AAPT) | $(ACP) + @echo "target R.java/Manifest.java: $(PRIVATE_MODULE) ($@)" + @rm -rf $@ && mkdir -p $(dir $@) + $(create-resource-java-files) + $(call find-generated-R.java,$@) + + $(proguard_options_file): $(R_file_stamp) + + ifdef LOCAL_EXPORT_PACKAGE_RESOURCES + # Put this module's resources into a PRODUCT-agnositc package that + # other packages can use to build their own PRODUCT-agnostic R.java (etc.) + # files. + resource_export_package := $(intermediates.COMMON)/package-export.apk + $(R_file_stamp): $(resource_export_package) + + # add-assets-to-package looks at PRODUCT_AAPT_CONFIG, but this target + # can't know anything about PRODUCT. Clear it out just for this target. + $(resource_export_package): PRIVATE_PRODUCT_AAPT_CONFIG := + $(resource_export_package): PRIVATE_PRODUCT_AAPT_PREF_CONFIG := + $(resource_export_package): PRIVATE_RESOURCE_LIST := $(all_res_assets) + $(resource_export_package): $(all_res_assets) $(full_android_manifest) $(RenderScript_file_stamp) $(AAPT) + @echo "target Export Resources: $(PRIVATE_MODULE) ($@)" + $(create-empty-package) + $(add-assets-to-package) + endif + +endif # LOCAL_USE_AAPT2 + +endif # need_compile_res + called_from_package_internal := true ################################# include $(BUILD_SYSTEM)/java.mk ################################# called_from_package_internal := +ifeq ($(need_compile_res),true) + +# Other modules should depend on the BUILT module if +# they want to use this module's R.java file. +$(LOCAL_BUILT_MODULE): $(R_file_stamp) + +# The R.java file must exist by the time the java source +# list is generated +$(java_source_list_file): $(R_file_stamp) + +endif # need_compile_res + LOCAL_SDK_RES_VERSION:=$(strip $(LOCAL_SDK_RES_VERSION)) ifeq ($(LOCAL_SDK_RES_VERSION),) LOCAL_SDK_RES_VERSION:=$(LOCAL_SDK_VERSION) @@ -364,99 +470,6 @@ $(java_source_list_file): $(data_binding_stamp) $(full_classes_compiled_jar): $(data_binding_stamp) endif # LOCAL_DATA_BINDING -resource_export_package := - -include $(BUILD_SYSTEM)/aapt_flags.mk - -ifeq ($(need_compile_res),true) - -############################### -## APK splits -built_apk_splits := -installed_apk_splits := -my_apk_split_configs := - -ifdef LOCAL_PACKAGE_SPLITS -ifdef LOCAL_COMPRESSED_MODULE -$(error $(LOCAL_MODULE): LOCAL_COMPRESSED_MODULE is not currently supported for split installs) -endif # LOCAL_COMPRESSED_MODULE - -my_apk_split_configs := $(LOCAL_PACKAGE_SPLITS) -my_split_suffixes := $(subst $(comma),_,$(my_apk_split_configs)) -built_apk_splits := $(foreach s,$(my_split_suffixes),$(intermediates)/package_$(s).apk) -installed_apk_splits := $(foreach s,$(my_split_suffixes),$(my_module_path)/$(LOCAL_MODULE)_$(s).apk) -endif - -ifdef LOCAL_USE_AAPT2 -my_compiled_res_base_dir := $(intermediates.COMMON)/flat-res -ifneq (,$(renderscript_target_api)) -ifneq ($(call math_gt_or_eq,$(renderscript_target_api),21),true) -my_generated_res_zips := $(rs_generated_res_zip) -endif # renderscript_target_api < 21 -endif # renderscript_target_api is set -my_asset_dirs := $(LOCAL_ASSET_DIR) -my_full_asset_paths := $(all_assets) - -# Add AAPT2 link specific flags. -$(my_res_package): PRIVATE_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) -ifndef LOCAL_AAPT_NAMESPACES - $(my_res_package): PRIVATE_AAPT_FLAGS += --no-static-lib-packages -endif - -include $(BUILD_SYSTEM)/aapt2.mk -else # LOCAL_USE_AAPT2 - -# Since we don't know where the real R.java file is going to end up, -# we need to use another file to stand in its place. We'll just -# copy the generated file to src/R.stamp, which means it will -# have the same contents and timestamp as the actual file. -# -# At the same time, this will copy the R.java file to a central -# 'R' directory to make it easier to add the files to an IDE. -# - -$(R_file_stamp): PRIVATE_RESOURCE_PUBLICS_OUTPUT := \ - $(intermediates.COMMON)/public_resources.xml -$(R_file_stamp): PRIVATE_PROGUARD_OPTIONS_FILE := $(proguard_options_file) -$(R_file_stamp): PRIVATE_RESOURCE_LIST := $(all_res_assets) -$(R_file_stamp): $(all_res_assets) $(full_android_manifest) $(rs_generated_res_zip) $(AAPT) | $(ACP) - @echo "target R.java/Manifest.java: $(PRIVATE_MODULE) ($@)" - @rm -rf $@ && mkdir -p $(dir $@) - $(create-resource-java-files) - $(call find-generated-R.java,$@) - -$(proguard_options_file): $(R_file_stamp) - -ifdef LOCAL_EXPORT_PACKAGE_RESOURCES -# Put this module's resources into a PRODUCT-agnositc package that -# other packages can use to build their own PRODUCT-agnostic R.java (etc.) -# files. -resource_export_package := $(intermediates.COMMON)/package-export.apk -$(R_file_stamp): $(resource_export_package) - -# add-assets-to-package looks at PRODUCT_AAPT_CONFIG, but this target -# can't know anything about PRODUCT. Clear it out just for this target. -$(resource_export_package): PRIVATE_PRODUCT_AAPT_CONFIG := -$(resource_export_package): PRIVATE_PRODUCT_AAPT_PREF_CONFIG := -$(resource_export_package): PRIVATE_RESOURCE_LIST := $(all_res_assets) -$(resource_export_package): $(all_res_assets) $(full_android_manifest) $(RenderScript_file_stamp) $(AAPT) - @echo "target Export Resources: $(PRIVATE_MODULE) ($@)" - $(create-empty-package) - $(add-assets-to-package) -endif - -endif # LOCAL_USE_AAPT2 - -# Other modules should depend on the BUILT module if -# they want to use this module's R.java file. -$(LOCAL_BUILT_MODULE): $(R_file_stamp) - -# The R.java file must exist by the time the java source -# list is generated -$(java_source_list_file): $(R_file_stamp) - -endif # need_compile_res - framework_res_package_export := ifneq ($(LOCAL_NO_STANDARD_LIBRARIES),true) @@ -492,6 +505,14 @@ ifdef LOCAL_USE_AAPT2 $(my_res_package) : $(all_library_res_package_export_deps) endif +# These four are set above for $(R_stamp_file) and $(my_res_package), but +# $(LOCAL_BUILT_MODULE) is not set before java.mk, so they have to be set again +# here. +$(LOCAL_BUILT_MODULE): PRIVATE_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) +$(LOCAL_BUILT_MODULE): PRIVATE_TARGET_AAPT_CHARACTERISTICS := $(TARGET_AAPT_CHARACTERISTICS) +$(LOCAL_BUILT_MODULE): PRIVATE_MANIFEST_PACKAGE_NAME := $(LOCAL_MANIFEST_PACKAGE_NAME) +$(LOCAL_BUILT_MODULE): PRIVATE_MANIFEST_INSTRUMENTATION_FOR := $(LOCAL_MANIFEST_INSTRUMENTATION_FOR) + ifneq ($(full_classes_jar),) $(LOCAL_BUILT_MODULE): PRIVATE_DEX_FILE := $(built_dex) # Use the jarjar processed arhive as the initial package file. @@ -658,6 +679,7 @@ $(built_apk_splits) : $(intermediates)/%.apk : $(LOCAL_BUILT_MODULE) $(sign-package) # Rules to install the splits +installed_apk_splits := $(foreach s,$(my_split_suffixes),$(my_module_path)/$(LOCAL_MODULE)_$(s).apk) $(installed_apk_splits) : $(my_module_path)/$(LOCAL_MODULE)_%.apk : $(intermediates)/package_%.apk @echo "Install: $@" $(copy-file-to-new-target) diff --git a/core/static_java_library.mk b/core/static_java_library.mk index 4a8d10325..e1d1918cb 100644 --- a/core/static_java_library.mk +++ b/core/static_java_library.mk @@ -92,7 +92,7 @@ endif # need_compile_res all_res_assets := $(all_resources) -include $(BUILD_SYSTEM)/java_library.mk +include $(BUILD_SYSTEM)/java_renderscript.mk ifeq (true,$(need_compile_res)) include $(BUILD_SYSTEM)/android_manifest.mk @@ -130,6 +130,14 @@ endif include $(BUILD_SYSTEM)/aapt_flags.mk +$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) +$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_AAPT_CHARACTERISTICS := $(TARGET_AAPT_CHARACTERISTICS) +$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_MANIFEST_PACKAGE_NAME := $(LOCAL_MANIFEST_PACKAGE_NAME) +$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_MANIFEST_INSTRUMENTATION_FOR := $(LOCAL_MANIFEST_INSTRUMENTATION_FOR) + +# LOCAL_INTERMEDIATE_SOURCE_DIR is set later by java.mk, but we need it for AAPT +LOCAL_INTERMEDIATE_SOURCE_DIR := $(intermediates.COMMON)/src + # add --non-constant-id to prevent inlining constants. # AAR needs text symbol file R.txt. ifdef LOCAL_USE_AAPT2 @@ -156,23 +164,29 @@ $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_MANIFEST_PACKAGE_NAME := $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_MANIFEST_INSTRUMENTATION_FOR := ifdef LOCAL_USE_AAPT2 -# One more level with name res so we can zip up the flat resources that can be linked by apps. -my_compiled_res_base_dir := $(intermediates.COMMON)/flat-res/res -ifneq (,$(renderscript_target_api)) -ifneq ($(call math_gt_or_eq,$(renderscript_target_api),21),true) -my_generated_res_zips := $(rs_generated_res_zip) -endif # renderscript_target_api < 21 -endif # renderscript_target_api is set -include $(BUILD_SYSTEM)/aapt2.mk -$(my_res_package) : $(framework_res_package_export) + # One more level with name res so we can zip up the flat resources that can be linked by apps. + my_compiled_res_base_dir := $(intermediates.COMMON)/flat-res/res + ifneq (,$(renderscript_target_api)) + ifneq ($(call math_gt_or_eq,$(renderscript_target_api),21),true) + my_generated_res_zips := $(rs_generated_res_zip) + endif # renderscript_target_api < 21 + endif # renderscript_target_api is set + include $(BUILD_SYSTEM)/aapt2.mk + $(my_res_package) : $(framework_res_package_export) else -$(R_file_stamp): PRIVATE_RESOURCE_LIST := $(all_resources) -$(R_file_stamp) : $(all_resources) $(full_android_manifest) $(AAPT) $(framework_res_package_export) $(rs_generated_res_zip) + $(R_file_stamp): PRIVATE_RESOURCE_LIST := $(all_resources) + $(R_file_stamp) : $(all_resources) $(full_android_manifest) $(AAPT) $(framework_res_package_export) $(rs_generated_res_zip) @echo "target R.java/Manifest.java: $(PRIVATE_MODULE) ($@)" $(create-resource-java-files) $(hide) find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) -name R.java | xargs cat > $@ endif # LOCAL_USE_AAPT2 +endif # need_compile_res + +include $(BUILD_SYSTEM)/java_library.mk + +ifeq (true,$(need_compile_res)) + $(LOCAL_BUILT_MODULE): $(R_file_stamp) $(java_source_list_file): $(R_file_stamp) $(full_classes_compiled_jar): $(R_file_stamp) From 2ae710c29fd8c03bf6c38a8856baad4f611df206 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Mon, 12 Mar 2018 14:56:27 -0700 Subject: [PATCH 5/7] Move R.txt and make aapt2 generate it Move R.txt from $(intermediates.COMMON)/src to $(intermediates.COMMON) in preparation for moving aapt/aapt2 java files out of src. Also make aapt2 generate R.txt, and make it an implicit output of the rule and and input to the aar rule. Bug: 73885582 Test: m out/target/common/obj/JAVA_LIBRARIES/SettingsLib_intermediates/javalib.aar Test: m checkbuild Change-Id: Ia858de226355965b69794c002f841333df16a612 Merged-In: Ia858de226355965b69794c002f841333df16a612 (cherry picked from commit 7c24f8ec85266cc93c873b2daffc3952a70b2d5f) --- core/static_java_library.mk | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/core/static_java_library.mk b/core/static_java_library.mk index e1d1918cb..e764f3113 100644 --- a/core/static_java_library.mk +++ b/core/static_java_library.mk @@ -141,7 +141,7 @@ LOCAL_INTERMEDIATE_SOURCE_DIR := $(intermediates.COMMON)/src # add --non-constant-id to prevent inlining constants. # AAR needs text symbol file R.txt. ifdef LOCAL_USE_AAPT2 -$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) --static-lib +$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) --static-lib --output-text-symbols $(intermediates.COMMON)/R.txt ifndef LOCAL_AAPT_NAMESPACES $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_AAPT_FLAGS += --no-static-lib-packages endif @@ -149,7 +149,7 @@ $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_PRODUCT_AAPT_CONFIG := $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_PRODUCT_AAPT_PREF_CONFIG := $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_AAPT_CHARACTERISTICS := else -$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) --non-constant-id --output-text-symbols $(LOCAL_INTERMEDIATE_SOURCE_DIR) +$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) --non-constant-id --output-text-symbols $(intermediates.COMMON) endif $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_SOURCE_INTERMEDIATES_DIR := $(LOCAL_INTERMEDIATE_SOURCE_DIR) @@ -173,7 +173,9 @@ ifdef LOCAL_USE_AAPT2 endif # renderscript_target_api is set include $(BUILD_SYSTEM)/aapt2.mk $(my_res_package) : $(framework_res_package_export) + $(my_res_package): .KATI_IMPLICIT_OUTPUTS += $(intermediates.COMMON)/R.txt else + $(R_file_stamp): .KATI_IMPLICIT_OUTPUTS := $(intermediates.COMMON)/R.txt $(R_file_stamp): PRIVATE_RESOURCE_LIST := $(all_resources) $(R_file_stamp) : $(all_resources) $(full_android_manifest) $(AAPT) $(framework_res_package_export) $(rs_generated_res_zip) @echo "target R.java/Manifest.java: $(PRIVATE_MODULE) ($@)" @@ -206,9 +208,9 @@ $(built_aar): PRIVATE_MODULE := $(LOCAL_MODULE) $(built_aar): PRIVATE_ANDROID_MANIFEST := $(full_android_manifest) $(built_aar): PRIVATE_CLASSES_JAR := $(aar_classes_jar) $(built_aar): PRIVATE_RESOURCE_DIR := $(LOCAL_RESOURCE_DIR) -$(built_aar): PRIVATE_R_TXT := $(LOCAL_INTERMEDIATE_SOURCE_DIR)/R.txt +$(built_aar): PRIVATE_R_TXT := $(intermediates.COMMON)/R.txt $(built_aar): $(JAR_ARGS) -$(built_aar) : $(aar_classes_jar) $(full_android_manifest) +$(built_aar) : $(aar_classes_jar) $(full_android_manifest) $(intermediates.COMMON)/R.txt @echo "target AAR: $(PRIVATE_MODULE) ($@)" $(hide) rm -rf $(dir $@)aar && mkdir -p $(dir $@)aar/res $(hide) cp $(PRIVATE_ANDROID_MANIFEST) $(dir $@)aar/AndroidManifest.xml From f6d68cf6fe4918880704dc3e0ebdeefa0f655162 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Thu, 8 Mar 2018 16:49:16 -0800 Subject: [PATCH 6/7] Use a srcjar for aapt and aapt2 output Dumping files in the *_intermediates/src causes incremental build problems, because we don't know when to delete them if they are no longer generated. Switch to outputting a srcjar instead, and pass it in to the turbine and javac compiles. Bug: 73885582 Test: m checkbuild Change-Id: Ibef28507522339d930c09426d0c98372eb864cb6 Merged-In: Ibef28507522339d930c09426d0c98372eb864cb6 (cherry picked from commit 2d1cddd5674d88c07350a52fa656cc441be04418) --- CleanSpec.mk | 5 +++++ core/aapt2.mk | 11 ++++++++--- core/definitions.mk | 21 +++++++++++++-------- core/package_internal.mk | 9 +++++++-- core/static_java_library.mk | 17 ++++++++++------- 5 files changed, 43 insertions(+), 20 deletions(-) diff --git a/CleanSpec.mk b/CleanSpec.mk index 079aa05e7..de3944142 100644 --- a/CleanSpec.mk +++ b/CleanSpec.mk @@ -465,6 +465,11 @@ $(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/compatibility_matrix.xml) # Remove obsolete intermedates src files $(call add-clean-step, rm -rf $(TARGET_OUT_COMMON_INTERMEDIATES)/*/*_intermediates/src/RenderScript.stamp*) +$(call add-clean-step, rm -rf $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS/*_intermediates/src) +$(call add-clean-step, rm -rf $(TARGET_OUT_COMMON_INTERMEDIATES)/JAVA_LIBRARIES/*_intermediates/src) +$(call add-clean-step, rm -rf $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS/*_intermediates/java-source-list) +$(call add-clean-step, rm -rf $(TARGET_OUT_COMMON_INTERMEDIATES)/JAVA_LIBRARIES/*_intermediates/java-source-list) +$(call add-clean-step, rm -rf $(OUT_DOCS)/*-timestamp) # ************************************************ # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST diff --git a/core/aapt2.mk b/core/aapt2.mk index 7d9d8ceb8..109bb392d 100644 --- a/core/aapt2.mk +++ b/core/aapt2.mk @@ -78,12 +78,17 @@ ifneq ($(my_apk_split_configs),) $(my_res_package): PRIVATE_AAPT_FLAGS += $(addprefix --split ,$(join $(built_apk_splits),$(addprefix :,$(my_apk_split_configs)))) endif +my_srcjar := $(intermediates.COMMON)/aapt2.srcjar +LOCAL_SRCJARS += $(my_srcjar) + $(my_res_package): PRIVATE_RES_FLAT := $(my_res_resources_flat) $(my_res_package): PRIVATE_OVERLAY_FLAT := $(my_static_library_resources) $(my_resources_flata) $(my_overlay_resources_flat) $(my_res_package): PRIVATE_SHARED_ANDROID_LIBRARIES := $(my_shared_library_resources) $(my_res_package): PRIVATE_PROGUARD_OPTIONS_FILE := $(proguard_options_file) $(my_res_package): PRIVATE_ASSET_DIRS := $(my_asset_dirs) -$(my_res_package): .KATI_IMPLICIT_OUTPUTS := +$(my_res_package): PRIVATE_JAVA_GEN_DIR := $(intermediates.COMMON)/aapt2 +$(my_res_package): PRIVATE_SRCJAR := $(my_srcjar) +$(my_res_package): .KATI_IMPLICIT_OUTPUTS := $(my_srcjar) ifdef R_file_stamp $(my_res_package): PRIVATE_R_FILE_STAMP := $(R_file_stamp) @@ -108,12 +113,12 @@ $(my_res_package): $(full_android_manifest) $(my_static_library_resources) $(my_ $(my_res_package): $(my_full_asset_paths) $(my_res_package): $(my_res_resources_flat) $(my_overlay_resources_flat) \ $(my_resources_flata) $(my_static_library_resources) \ - $(AAPT2) + $(AAPT2) $(SOONG_ZIP) @echo "AAPT2 link $@" $(call aapt2-link) ifdef R_file_stamp @rm -f $(PRIVATE_R_FILE_STAMP) - $(call find-generated-R.java,$(PRIVATE_R_FILE_STAMP)) + $(call find-generated-R.java,$(PRIVATE_JAVA_GEN_DIR),$(PRIVATE_R_FILE_STAMP)) endif ifdef LOCAL_EXPORT_PACKAGE_RESOURCES @rm -f $(PRIVATE_RESOURCE_EXPORT_PACKAGE) diff --git a/core/definitions.mk b/core/definitions.mk index 0565603e2..e259e1981 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -2021,11 +2021,12 @@ AAPT_ASAN_OPTIONS := ASAN_OPTIONS=detect_leaks=0 # This rule creates the R.java and Manifest.java files, both of which # are PRODUCT-neutral. Don't pass PRIVATE_PRODUCT_AAPT_CONFIG to this invocation. define create-resource-java-files -@mkdir -p $(PRIVATE_SOURCE_INTERMEDIATES_DIR) @mkdir -p $(dir $(PRIVATE_RESOURCE_PUBLICS_OUTPUT)) +rm -rf $(PRIVATE_JAVA_GEN_DIR) +mkdir -p $(PRIVATE_JAVA_GEN_DIR) $(hide) $(AAPT_ASAN_OPTIONS) $(AAPT) package $(PRIVATE_AAPT_FLAGS) -m \ $(eval # PRIVATE_PRODUCT_AAPT_CONFIG is intentionally missing-- see comment.) \ - $(addprefix -J , $(PRIVATE_SOURCE_INTERMEDIATES_DIR)) \ + $(addprefix -J , $(PRIVATE_JAVA_GEN_DIR)) \ $(addprefix -M , $(PRIVATE_ANDROID_MANIFEST)) \ $(addprefix -P , $(PRIVATE_RESOURCE_PUBLICS_OUTPUT)) \ $(addprefix -S , $(PRIVATE_RESOURCE_DIR)) \ @@ -2039,30 +2040,31 @@ $(hide) $(AAPT_ASAN_OPTIONS) $(AAPT) package $(PRIVATE_AAPT_FLAGS) -m \ $(addprefix --rename-manifest-package , $(PRIVATE_MANIFEST_PACKAGE_NAME)) \ $(addprefix --rename-instrumentation-target-package , $(PRIVATE_MANIFEST_INSTRUMENTATION_FOR)) \ --skip-symbols-without-default-localization +$(SOONG_ZIP) -o $(PRIVATE_SRCJAR) -C $(PRIVATE_JAVA_GEN_DIR) -D $(PRIVATE_JAVA_GEN_DIR) # So that we re-run aapt when the list of input files change $(hide) echo $(PRIVATE_RESOURCE_LIST) >/dev/null endef -# Search for generated R.java/Manifest.java, copy the found R.java as $1. +# Search for generated R.java/Manifest.java in $1, copy the found R.java as $2. # Also copy them to a central 'R' directory to make it easier to add the files to an IDE. define find-generated-R.java -$(hide) for GENERATED_MANIFEST_FILE in `find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) \ +$(hide) for GENERATED_MANIFEST_FILE in `find $(1) \ -name Manifest.java 2> /dev/null`; do \ dir=`awk '/package/{gsub(/\./,"/",$$2);gsub(/;/,"",$$2);print $$2;exit}' $$GENERATED_MANIFEST_FILE`; \ mkdir -p $(TARGET_COMMON_OUT_ROOT)/R/$$dir; \ $(ACP) -fp $$GENERATED_MANIFEST_FILE $(TARGET_COMMON_OUT_ROOT)/R/$$dir; \ done; -$(hide) for GENERATED_R_FILE in `find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) \ +$(hide) for GENERATED_R_FILE in `find $(1) \ -name R.java 2> /dev/null`; do \ dir=`awk '/package/{gsub(/\./,"/",$$2);gsub(/;/,"",$$2);print $$2;exit}' $$GENERATED_R_FILE`; \ mkdir -p $(TARGET_COMMON_OUT_ROOT)/R/$$dir; \ $(ACP) -fp $$GENERATED_R_FILE $(TARGET_COMMON_OUT_ROOT)/R/$$dir \ || exit 31; \ - $(ACP) -fp $$GENERATED_R_FILE $1 || exit 32; \ + $(ACP) -fp $$GENERATED_R_FILE $(2) || exit 32; \ done; @# Ensure that the target file is always created, i.e. also in case we did not @# enter the GENERATED_R_FILE-loop above. This avoids unnecessary rebuilding. -$(hide) touch $1 +$(hide) touch $(2) endef ########################################################### @@ -2110,6 +2112,8 @@ endef define aapt2-link @mkdir -p $(dir $@) +rm -rf $(PRIVATE_JAVA_GEN_DIR) +mkdir -p $(PRIVATE_JAVA_GEN_DIR) $(call dump-words-to-file,$(PRIVATE_RES_FLAT),$(dir $@)aapt2-flat-list) $(call dump-words-to-file,$(PRIVATE_OVERLAY_FLAT),$(dir $@)aapt2-flat-overlay-list) $(hide) $(AAPT2) link -o $@ \ @@ -2118,7 +2122,7 @@ $(hide) $(AAPT2) link -o $@ \ $(addprefix -I ,$(PRIVATE_AAPT_INCLUDES)) \ $(addprefix -I ,$(PRIVATE_SHARED_ANDROID_LIBRARIES)) \ $(addprefix -A ,$(PRIVATE_ASSET_DIR)) \ - $(addprefix --java ,$(PRIVATE_SOURCE_INTERMEDIATES_DIR)) \ + $(addprefix --java ,$(PRIVATE_JAVA_GEN_DIR)) \ $(addprefix --proguard ,$(PRIVATE_PROGUARD_OPTIONS_FILE)) \ $(addprefix --min-sdk-version ,$(PRIVATE_DEFAULT_APP_TARGET_SDK)) \ $(addprefix --target-sdk-version ,$(PRIVATE_DEFAULT_APP_TARGET_SDK)) \ @@ -2131,6 +2135,7 @@ $(hide) $(AAPT2) link -o $@ \ $(addprefix --rename-instrumentation-target-package ,$(PRIVATE_MANIFEST_INSTRUMENTATION_FOR)) \ -R \@$(dir $@)aapt2-flat-overlay-list \ \@$(dir $@)aapt2-flat-list +$(SOONG_ZIP) -o $(PRIVATE_SRCJAR) -C $(PRIVATE_JAVA_GEN_DIR) -D $(PRIVATE_JAVA_GEN_DIR) endef ########################################################### diff --git a/core/package_internal.mk b/core/package_internal.mk index 0385d9169..fba50a167 100644 --- a/core/package_internal.mk +++ b/core/package_internal.mk @@ -373,6 +373,11 @@ ifdef LOCAL_USE_AAPT2 include $(BUILD_SYSTEM)/aapt2.mk else # LOCAL_USE_AAPT2 + my_srcjar := $(intermediates.COMMON)/aapt.srcjar + LOCAL_SRCJARS += $(my_srcjar) + $(R_file_stamp): PRIVATE_SRCJAR := $(my_srcjar) + $(R_file_stamp): PRIVATE_JAVA_GEN_DIR := $(intermediates.COMMON)/aapt + $(R_file_stamp): .KATI_IMPLICIT_OUTPUTS := $(my_srcjar) # Since we don't know where the real R.java file is going to end up, # we need to use another file to stand in its place. We'll just # copy the generated file to src/R.stamp, which means it will @@ -386,11 +391,11 @@ else # LOCAL_USE_AAPT2 $(intermediates.COMMON)/public_resources.xml $(R_file_stamp): PRIVATE_PROGUARD_OPTIONS_FILE := $(proguard_options_file) $(R_file_stamp): PRIVATE_RESOURCE_LIST := $(all_res_assets) - $(R_file_stamp): $(all_res_assets) $(full_android_manifest) $(rs_generated_res_zip) $(AAPT) | $(ACP) + $(R_file_stamp): $(all_res_assets) $(full_android_manifest) $(rs_generated_res_zip) $(AAPT) $(SOONG_ZIP) | $(ACP) @echo "target R.java/Manifest.java: $(PRIVATE_MODULE) ($@)" @rm -rf $@ && mkdir -p $(dir $@) $(create-resource-java-files) - $(call find-generated-R.java,$@) + $(call find-generated-R.java,$(PRIVATE_JAVA_GEN_DIR),$@) $(proguard_options_file): $(R_file_stamp) diff --git a/core/static_java_library.mk b/core/static_java_library.mk index e764f3113..3219bb1ca 100644 --- a/core/static_java_library.mk +++ b/core/static_java_library.mk @@ -135,9 +135,6 @@ $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_AAPT_CHARACTERISTICS := $(TARGET_A $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_MANIFEST_PACKAGE_NAME := $(LOCAL_MANIFEST_PACKAGE_NAME) $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_MANIFEST_INSTRUMENTATION_FOR := $(LOCAL_MANIFEST_INSTRUMENTATION_FOR) -# LOCAL_INTERMEDIATE_SOURCE_DIR is set later by java.mk, but we need it for AAPT -LOCAL_INTERMEDIATE_SOURCE_DIR := $(intermediates.COMMON)/src - # add --non-constant-id to prevent inlining constants. # AAR needs text symbol file R.txt. ifdef LOCAL_USE_AAPT2 @@ -150,9 +147,14 @@ $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_PRODUCT_AAPT_PREF_CONFIG := $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_AAPT_CHARACTERISTICS := else $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) --non-constant-id --output-text-symbols $(intermediates.COMMON) + +my_srcjar := $(intermediates.COMMON)/aapt.srcjar +LOCAL_SRCJARS += $(my_srcjar) +$(R_file_stamp): PRIVATE_SRCJAR := $(my_srcjar) +$(R_file_stamp): PRIVATE_JAVA_GEN_DIR := $(intermediates.COMMON)/aapt +$(R_file_stamp): .KATI_IMPLICIT_OUTPUTS := $(intermediates.COMMON)/R.txt) $(my_srcjar) endif -$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_SOURCE_INTERMEDIATES_DIR := $(LOCAL_INTERMEDIATE_SOURCE_DIR) $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ANDROID_MANIFEST := $(full_android_manifest) $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RESOURCE_PUBLICS_OUTPUT := $(intermediates.COMMON)/public_resources.xml $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RESOURCE_DIR := $(LOCAL_RESOURCE_DIR) @@ -175,12 +177,13 @@ ifdef LOCAL_USE_AAPT2 $(my_res_package) : $(framework_res_package_export) $(my_res_package): .KATI_IMPLICIT_OUTPUTS += $(intermediates.COMMON)/R.txt else - $(R_file_stamp): .KATI_IMPLICIT_OUTPUTS := $(intermediates.COMMON)/R.txt + $(R_file_stamp): .KATI_IMPLICIT_OUTPUTS += $(intermediates.COMMON)/R.txt $(R_file_stamp): PRIVATE_RESOURCE_LIST := $(all_resources) - $(R_file_stamp) : $(all_resources) $(full_android_manifest) $(AAPT) $(framework_res_package_export) $(rs_generated_res_zip) + $(R_file_stamp) : $(all_resources) $(full_android_manifest) $(AAPT) $(SOONG_ZIP) \ + $(framework_res_package_export) $(rs_generated_res_zip) @echo "target R.java/Manifest.java: $(PRIVATE_MODULE) ($@)" $(create-resource-java-files) - $(hide) find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) -name R.java | xargs cat > $@ + $(hide) find $(PRIVATE_JAVA_GEN_DIR) -name R.java | xargs cat > $@ endif # LOCAL_USE_AAPT2 endif # need_compile_res From 96b0c0d9d7dd65d36461be3920832d4f9e410be9 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Tue, 20 Mar 2018 13:36:40 -0700 Subject: [PATCH 7/7] Add asan-specific CleanSpec ASAN builds run as two consecutive builds. The cleanspec is applied by the first one, which cleans the obj directory, and ignored by the second. This can result in old entries in the obj_asan directory. Test: obj_asan dirs are deleted Change-Id: I54b8ec9cff581fcd9ec2a843aa7126805340c387 Merged-In: I54b8ec9cff581fcd9ec2a843aa7126805340c387 (cherry picked from commit 4e2da3277a1297bd403b07abcf9a36275826424b) --- CleanSpec.mk | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CleanSpec.mk b/CleanSpec.mk index de3944142..043aa6056 100644 --- a/CleanSpec.mk +++ b/CleanSpec.mk @@ -471,6 +471,11 @@ $(call add-clean-step, rm -rf $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS/*_intermed $(call add-clean-step, rm -rf $(TARGET_OUT_COMMON_INTERMEDIATES)/JAVA_LIBRARIES/*_intermediates/java-source-list) $(call add-clean-step, rm -rf $(OUT_DOCS)/*-timestamp) +$(call add-clean-step, rm -rf $(TARGET_COMMON_OUT_ROOT)/obj_asan/APPS/*_intermediates/src) +$(call add-clean-step, rm -rf $(TARGET_COMMON_OUT_ROOT)/obj_asan/JAVA_LIBRARIES/*_intermediates/src) +$(call add-clean-step, rm -rf $(TARGET_COMMON_OUT_ROOT)/obj_asan/APPS/*_intermediates/java-source-list) +$(call add-clean-step, rm -rf $(TARGET_COMMON_OUT_ROOT)/obj_asan/JAVA_LIBRARIES/*_intermediates/java-source-list) + # ************************************************ # NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST # ************************************************