Regenerate R.java files from LOCAL_STATIC_ANDROID_LIBRARIES
If a static android library lib1 has LOCAL_STATIC_ANDROID_LIBRARIES lib2, then the R.class files for packages in lib2 will be merged into the jar for lib1. If an app has lib1 in its LOCAL_STATIC_ANDROID_LIBRARIES it will get the R.class files from lib2 through lib1, instead of regenerating the R.java files with numbering that matches the resource table of the app. This was worked around for support libraries by keeping a fix_dependencies.mk that added transitive static support libraries to the direct static dependencies of apps. Instead, propagate the packages that aapt2 generated R.java files for up as --extra-packages arguments to the next aapt2 invocation, which will force aapt2 to regenerate the R.java files for those packages. Bug: 78300023 Test: m checkbuild Change-Id: I7375e13241b4c4f2933032409fb7935abe133bfc
This commit is contained in:
parent
fc8e281bc3
commit
43c247e181
4 changed files with 15 additions and 3 deletions
|
@ -66,6 +66,8 @@ $(my_res_resources_flat) $(my_overlay_resources_flat) $(my_resources_flata): \
|
|||
|
||||
my_static_library_resources := $(foreach l, $(call reverse-list,$(LOCAL_STATIC_ANDROID_LIBRARIES)),\
|
||||
$(call intermediates-dir-for,JAVA_LIBRARIES,$(l),,COMMON)/package-res.apk)
|
||||
my_static_library_extra_packages := $(foreach l, $(call reverse-list,$(LOCAL_STATIC_ANDROID_LIBRARIES)),\
|
||||
$(call intermediates-dir-for,JAVA_LIBRARIES,$(l),,COMMON)/extra_packages)
|
||||
my_shared_library_resources := $(foreach l, $(LOCAL_SHARED_ANDROID_LIBRARIES),\
|
||||
$(call intermediates-dir-for,JAVA_LIBRARIES,$(l),,COMMON)/package-res.apk)
|
||||
|
||||
|
@ -81,6 +83,8 @@ endif
|
|||
my_srcjar := $(intermediates.COMMON)/aapt2.srcjar
|
||||
LOCAL_SRCJARS += $(my_srcjar)
|
||||
|
||||
aapt_extra_packages := $(intermediates.COMMON)/extra_packages
|
||||
|
||||
$(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)
|
||||
|
@ -88,7 +92,9 @@ $(my_res_package): PRIVATE_PROGUARD_OPTIONS_FILE := $(proguard_options_file)
|
|||
$(my_res_package): PRIVATE_ASSET_DIRS := $(my_asset_dirs)
|
||||
$(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)
|
||||
$(my_res_package): PRIVATE_STATIC_LIBRARY_EXTRA_PACKAGES := $(my_static_library_extra_packages)
|
||||
$(my_res_package): PRIVATE_AAPT_EXTRA_PACKAGES := $(aapt_extra_packages)
|
||||
$(my_res_package): .KATI_IMPLICIT_OUTPUTS := $(my_srcjar) $(aapt_extra_packages)
|
||||
|
||||
ifdef R_file_stamp
|
||||
$(my_res_package): PRIVATE_R_FILE_STAMP := $(R_file_stamp)
|
||||
|
@ -112,8 +118,8 @@ endif
|
|||
$(my_res_package): $(full_android_manifest) $(my_static_library_resources) $(my_shared_library_resources)
|
||||
$(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) $(SOONG_ZIP)
|
||||
$(my_resources_flata) $(my_static_library_resources) $(my_static_library_extra_packages) \
|
||||
$(AAPT2) $(SOONG_ZIP) $(EXTRACT_JAR_PACKAGES)
|
||||
@echo "AAPT2 link $@"
|
||||
$(call aapt2-link)
|
||||
ifdef R_file_stamp
|
||||
|
|
|
@ -244,6 +244,7 @@ LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR :=
|
|||
LOCAL_SOONG_PROGUARD_DICT :=
|
||||
LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE :=
|
||||
LOCAL_SOONG_RRO_DIRS :=
|
||||
LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES :=
|
||||
LOCAL_DROIDDOC_STUBS_SRCJAR :=
|
||||
LOCAL_DROIDDOC_DOC_ZIP :=
|
||||
# '',true
|
||||
|
|
|
@ -2125,6 +2125,7 @@ $(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 $@ \
|
||||
$(PRIVATE_AAPT_FLAGS) \
|
||||
$(if $(PRIVATE_STATIC_LIBRARY_EXTRA_PACKAGES),$$(cat $(PRIVATE_STATIC_LIBRARY_EXTRA_PACKAGES))) \
|
||||
$(addprefix --manifest ,$(PRIVATE_ANDROID_MANIFEST)) \
|
||||
$(addprefix -I ,$(PRIVATE_AAPT_INCLUDES)) \
|
||||
$(addprefix -I ,$(PRIVATE_SHARED_ANDROID_LIBRARIES)) \
|
||||
|
@ -2143,6 +2144,7 @@ $(hide) $(AAPT2) link -o $@ \
|
|||
-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)
|
||||
$(EXTRACT_JAR_PACKAGES) -i $(PRIVATE_SRCJAR) -o $(PRIVATE_AAPT_EXTRA_PACKAGES) --prefix '--extra-packages '
|
||||
endef
|
||||
|
||||
###########################################################
|
||||
|
|
|
@ -61,6 +61,9 @@ ifdef LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE
|
|||
|
||||
$(call add-dependency,$(LOCAL_BUILT_MODULE),$(my_proguard_flags))
|
||||
|
||||
my_static_library_extra_packages := $(intermediates.COMMON)/extra_packages
|
||||
$(eval $(call copy-one-file,$(LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES),$(my_static_library_extra_packages)))
|
||||
$(call add-dependency,$(LOCAL_BUILT_MODULE),$(my_static_library_extra_packages))
|
||||
endif # LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE
|
||||
|
||||
ifneq ($(TURBINE_ENABLED),false)
|
||||
|
|
Loading…
Reference in a new issue