Rewrite how to generate apexkeys.txt

Instead of listing all apexes in the source tree, now each apex emits
its own fragment for apexkeys.txt, which is pointed by
LOCAL_APEX_KEYS_FILE. Makefile collects apexkeys.txt from installed apex
files. This is to avoid listing unrelated apexes (not installed,
testdata, unexported namespaces, etc.)

Bug: 304914238
Test: m apexkeys.txt
Test: m blueprint-tests
Change-Id: I6b5601609d16452a0717f09ecaa703ee09693094
This commit is contained in:
Jooyung Han 2023-10-30 16:22:53 +09:00
parent da88660301
commit 8b162283f7
3 changed files with 22 additions and 4 deletions

View file

@ -793,9 +793,25 @@ $(call declare-0p-target,$(APKCERTS_FILE))
.PHONY: apkcerts-list
apkcerts-list: $(APKCERTS_FILE)
intermediates := $(call intermediates-dir-for,PACKAGING,apexkeys)
APEX_KEYS_FILE := $(intermediates)/apexkeys.txt
all_apex_keys_files := $(sort $(foreach m,$(call product-installed-modules,$(INTERNAL_PRODUCT)),$(ALL_MODULES.$(m).APEX_KEYS_FILE)))
$(APEX_KEYS_FILE): $(all_apex_keys_files)
@mkdir -p $(dir $@)
@rm -f $@
$(hide) touch $@
$(hide) $(foreach file,$^,cat $(file) >> $@ $(newline))
all_apex_keys_files :=
$(call declare-0p-target,$(APEX_KEYS_FILE))
.PHONY: apexkeys.txt
apexkeys.txt: $(APEX_KEYS_FILE)
ifneq (,$(TARGET_BUILD_APPS))
$(call dist-for-goals, apps_only, $(APKCERTS_FILE):apkcerts.txt)
$(call dist-for-goals, apps_only, $(SOONG_APEX_KEYS_FILE):apexkeys.txt)
$(call dist-for-goals, apps_only, $(APEX_KEYS_FILE):apexkeys.txt)
endif
@ -6336,7 +6352,7 @@ $(BUILT_TARGET_FILES_DIR): \
$(INSTALLED_MISC_INFO_TARGET) \
$(INSTALLED_FASTBOOT_INFO_TARGET) \
$(APKCERTS_FILE) \
$(SOONG_APEX_KEYS_FILE) \
$(APEX_KEYS_FILE) \
$(SOONG_ZIP) \
$(HOST_OUT_EXECUTABLES)/fs_config \
$(HOST_OUT_EXECUTABLES)/map_file_generator \
@ -6547,7 +6563,7 @@ endif
@# build them.
$(hide) mkdir -p $(zip_root)/META
$(hide) cp $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt
$(hide) cp $(SOONG_APEX_KEYS_FILE) $(zip_root)/META/apexkeys.txt
$(hide) cp $(APEX_KEYS_FILE) $(zip_root)/META/apexkeys.txt
ifneq ($(tool_extension),)
$(hide) cp $(PRIVATE_TOOL_EXTENSION) $(zip_root)/META/
endif
@ -6810,7 +6826,7 @@ $(call declare-container-license-deps,$(BUILT_TARGET_FILES_PACKAGE), $(INSTALLED
$(INSTALLED_MISC_INFO_TARGET) \
$(INSTALLED_FASTBOOT_INFO_TARGET) \
$(APKCERTS_FILE) \
$(SOONG_APEX_KEYS_FILE) \
$(APEX_KEYS_FILE) \
$(HOST_OUT_EXECUTABLES)/fs_config \
$(HOST_OUT_EXECUTABLES)/map_file_generator \
$(ADD_IMG_TO_TARGET_FILES) \

View file

@ -1180,6 +1180,7 @@ ALL_MODULES.$(my_register_name).EXTRA_TEST_CONFIGS := $(LOCAL_EXTRA_FULL_TEST_CO
ALL_MODULES.$(my_register_name).TEST_MAINLINE_MODULES := $(LOCAL_TEST_MAINLINE_MODULES)
ifndef LOCAL_IS_HOST_MODULE
ALL_MODULES.$(my_register_name).FILE_CONTEXTS := $(LOCAL_FILE_CONTEXTS)
ALL_MODULES.$(my_register_name).APEX_KEYS_FILE := $(LOCAL_APEX_KEY_PATH)
endif
ifdef LOCAL_IS_UNIT_TEST
ALL_MODULES.$(my_register_name).IS_UNIT_TEST := $(LOCAL_IS_UNIT_TEST)

View file

@ -19,6 +19,7 @@ LOCAL_AIDL_INCLUDES:=
LOCAL_ALLOW_UNDEFINED_SYMBOLS:=
LOCAL_ANNOTATION_PROCESSORS:=
LOCAL_ANNOTATION_PROCESSOR_CLASSES:=
LOCAL_APEX_KEY_PATH:=
LOCAL_APIDIFF_NEWAPI:=
LOCAL_APIDIFF_OLDAPI:=
LOCAL_APK_LIBRARIES:=