From 649311868c402c6de126730a99cfe90b438efee3 Mon Sep 17 00:00:00 2001 From: Dan Willemsen Date: Sun, 17 Jun 2018 21:47:18 -0700 Subject: [PATCH 1/2] Fix vndk packaging to stop depending on phony targets These had been depending on the phony target for the library (liblz4.vendor), not the actual built file and notice file. Since we hadn't been saving the NOTICE file, and were only assuming the installed notice file path. save that away for use during packaging. Test: m vndk; diff out/target/product/generic/android-vndk-aosp_arm.zip Test: m vndk; diff out/target/product/generic_arm64/android-vndk-aosp_arm64.zip Change-Id: If9a4bed27030b7bd464cd3987739df94d32a0037 --- core/notice_files.mk | 4 ++ core/tasks/vndk.mk | 118 +++++++++++++++++++++++-------------------- 2 files changed, 67 insertions(+), 55 deletions(-) diff --git a/core/notice_files.mk b/core/notice_files.mk index 9dce2b35f8..08778c5f7f 100644 --- a/core/notice_files.mk +++ b/core/notice_files.mk @@ -40,6 +40,10 @@ endif ifdef notice_file +ifdef my_register_name +ALL_MODULES.$(my_register_name).NOTICES := $(ALL_MODULES.$(my_register_name).NOTICES) $(notice_file) +endif + # This relies on the name of the directory in PRODUCT_OUT matching where # it's installed on the target - i.e. system, data, etc. This does # not work for root and isn't exact, but it's probably good enough for diff --git a/core/tasks/vndk.mk b/core/tasks/vndk.mk index b9133df02f..ba48df7a31 100644 --- a/core/tasks/vndk.mk +++ b/core/tasks/vndk.mk @@ -36,38 +36,38 @@ $(strip \ ) endef -# Returns list of file paths of the intermediate objs +# Returns list of src:dest paths of the intermediate objs # # Args: # $(1): list of module and filename pairs (e.g., ld.config.txt:ld.config.27.txt ...) -# $(2): target class (e.g., SHARED_LIBRARIES, STATIC_LIBRARIES, ETC) -# $(3): if not empty, evaluates for TARGET_2ND_ARCH +# $(2): if not empty, evaluates for TARGET_2ND_ARCH define paths-of-intermediates $(strip \ $(foreach pair,$(1), \ - $(eval split_pair := $(subst :,$(space),$(pair))) \ - $(eval module := $(word 1,$(split_pair))) \ - $(eval filename := $(word 2,$(split_pair))) \ - $(eval dir := $(call intermediates-dir-for,$(2),$(module),,,$(3))) \ - $(call append-path,$(dir),$(filename)) \ + $(eval module := $(call word-colon,1,$(pair))$(if $(2),$(TARGET_2ND_ARCH_MODULE_SUFFIX))) \ + $(eval built := $(ALL_MODULES.$(module).BUILT_INSTALLED)) \ + $(eval filename := $(call word-colon,2,$(pair))) \ + $(if $(wordlist 2,100,$(built)), \ + $(error Unable to handle multiple built files ($(module)): $(built))) \ + $(if $(built),$(call word-colon,1,$(built)):$(filename)) \ ) \ ) endef -# Returns paths of notice files under $(TARGET_OUT_NOTICE_FILES) +# Returns src:dest list of notice files # # Args: # $(1): list of lib names (e.g., libfoo.vendor) -# $(2): vndk lib type, one of 'vndk' or 'vndk-sp' define paths-of-notice-files $(strip \ - $(eval lib_dir := lib$(if $(TARGET_IS_64BIT),64,)) \ - $(eval vndk_dir := $(2)-$(PLATFORM_VNDK_VERSION)) \ $(foreach lib,$(1), \ - $(eval notice_file_name := $(patsubst %.vendor,%.so.txt,$(lib))) \ - $(TARGET_OUT_NOTICE_FILES)/src/system/$(lib_dir)/$(vndk_dir)/$(notice_file_name) \ - ) \ -) + $(eval notice := $(sort \ + $(ALL_MODULES.$(lib).NOTICES) \ + $(if $(TARGET_2ND_ARCH), + $(ALL_MODULES.$(lib)$(TARGET_2ND_ARCH_MODULE_SUFFIX).NOTICES)))) \ + $(if $(wordlist 2,100,$(notice)), \ + $(error Unable to handle multiple notice files ($(lib)): $(notice))) \ + $(if $(notice),$(notice):$(subst .vendor,,$(lib)).so.txt))) endef # If in the future libclang_rt.ubsan* is removed from the VNDK-core list, @@ -103,34 +103,37 @@ vndk_snapshot_configs_out := $(vndk_snapshot_top)/configs ####################################### # vndkcore.libraries.txt vndkcore.libraries.txt := $(vndk_snapshot_configs_out)/vndkcore.libraries.txt -$(vndkcore.libraries.txt): $(vndk_core_libs) +$(vndkcore.libraries.txt): PRIVATE_LIBS := $(vndk_core_libs) +$(vndkcore.libraries.txt): @echo 'Generating: $@' @rm -f $@ @mkdir -p $(dir $@) $(hide) echo -n > $@ - $(hide) $(foreach lib,$^,echo $(patsubst %.vendor,%,$(lib)).so >> $@;) + $(hide) $(foreach lib,$(PRIVATE_LIBS),echo $(patsubst %.vendor,%,$(lib)).so >> $@;) ####################################### # vndkprivate.libraries.txt vndkprivate.libraries.txt := $(vndk_snapshot_configs_out)/vndkprivate.libraries.txt -$(vndkprivate.libraries.txt): $(vndk_private_libs) +$(vndkprivate.libraries.txt): PRIVATE_LIBS := $(vndk_private_libs) +$(vndkprivate.libraries.txt): @echo 'Generating: $@' @rm -f $@ @mkdir -p $(dir $@) $(hide) echo -n > $@ - $(hide) $(foreach lib,$^,echo $(patsubst %.vendor,%,$(lib)).so >> $@;) + $(hide) $(foreach lib,$(PRIVATE_LIBS),echo $(patsubst %.vendor,%,$(lib)).so >> $@;) ####################################### # module_paths.txt module_paths.txt := $(vndk_snapshot_configs_out)/module_paths.txt -$(module_paths.txt): $(vndk_snapshot_libs) +$(module_paths.txt): PRIVATE_LIBS := $(vndk_snapshot_libs) +$(module_paths.txt): @echo 'Generating: $@' @rm -f $@ @mkdir -p $(dir $@) $(hide) echo -n > $@ - $(hide) $(foreach lib,$^,echo $(patsubst %.vendor,%,$(lib)).so $(ALL_MODULES.$(lib).PATH) >> $@;) + $(hide) $(foreach lib,$(PRIVATE_LIBS),echo $(patsubst %.vendor,%,$(lib)).so $(ALL_MODULES.$(lib).PATH) >> $@;) vndk_snapshot_configs := \ @@ -151,70 +154,76 @@ vndk_snapshot_zip := $(PRODUCT_OUT)/android-vndk-$(TARGET_PRODUCT).zip $(vndk_snapshot_zip): PRIVATE_VNDK_SNAPSHOT_OUT := $(vndk_snapshot_out) +deps := $(call paths-of-intermediates,$(foreach lib,$(vndk_core_libs),$(lib):$(subst .vendor,,$(lib)).so)) $(vndk_snapshot_zip): PRIVATE_VNDK_CORE_OUT := $(vndk_lib_dir)/shared/vndk-core -$(vndk_snapshot_zip): PRIVATE_VNDK_CORE_INTERMEDIATES := \ - $(call paths-of-intermediates,$(foreach lib,$(vndk_core_libs),$(lib):$(lib).so),SHARED_LIBRARIES) +$(vndk_snapshot_zip): PRIVATE_VNDK_CORE_INTERMEDIATES := $(deps) +$(vndk_snapshot_zip): $(foreach d,$(deps),$(call word-colon,1,$(d))) +deps := +deps := $(call paths-of-intermediates,$(foreach lib,$(vndk_sp_libs),$(lib):$(subst .vendor,,$(lib)).so)) $(vndk_snapshot_zip): PRIVATE_VNDK_SP_OUT := $(vndk_lib_dir)/shared/vndk-sp -$(vndk_snapshot_zip): PRIVATE_VNDK_SP_INTERMEDIATES := \ - $(call paths-of-intermediates,$(foreach lib,$(vndk_sp_libs),$(lib):$(lib).so),SHARED_LIBRARIES) +$(vndk_snapshot_zip): PRIVATE_VNDK_SP_INTERMEDIATES := $(deps) +$(vndk_snapshot_zip): $(foreach d,$(deps),$(call word-colon,1,$(d))) +deps := +deps := $(call paths-of-intermediates,$(foreach txt,$(vndk_prebuilt_txts), \ + $(txt):$(patsubst %.txt,%.$(PLATFORM_VNDK_VERSION).txt,$(txt)))) \ + $(foreach config,$(vndk_snapshot_configs),$(config):$(notdir $(config))) $(vndk_snapshot_zip): PRIVATE_CONFIGS_OUT := $(vndk_snapshot_variant)/configs -$(vndk_snapshot_zip): PRIVATE_CONFIGS_INTERMEDIATES := \ - $(call paths-of-intermediates,$(foreach txt,$(vndk_prebuilt_txts), \ - $(txt):$(patsubst %.txt,%.$(PLATFORM_VNDK_VERSION).txt,$(txt))),ETC) \ - $(vndk_snapshot_configs) +$(vndk_snapshot_zip): PRIVATE_CONFIGS_INTERMEDIATES := $(deps) +$(vndk_snapshot_zip): $(foreach d,$(deps),$(call word-colon,1,$(d))) +deps := +notices := $(call paths-of-notice-files,$(vndk_core_libs) $(vndk_sp_libs)) $(vndk_snapshot_zip): PRIVATE_NOTICE_FILES_OUT := $(vndk_snapshot_variant)/NOTICE_FILES -$(vndk_snapshot_zip): PRIVATE_NOTICE_FILES_INTERMEDIATES := \ - $(call paths-of-notice-files,$(vndk_core_libs),vndk) \ - $(call paths-of-notice-files,$(vndk_sp_libs),vndk-sp) +$(vndk_snapshot_zip): PRIVATE_NOTICE_FILES_INTERMEDIATES := $(notices) +$(vndk_snapshot_zip): $(foreach n,$(notices),$(call word-colon,1,$(n))) +notices := ifdef TARGET_2ND_ARCH +deps := $(call paths-of-intermediates,$(foreach lib,$(vndk_core_libs),$(lib):$(subst .vendor,,$(lib)).so),true) $(vndk_snapshot_zip): PRIVATE_VNDK_CORE_OUT_2ND := $(vndk_lib_dir_2nd)/shared/vndk-core -$(vndk_snapshot_zip): PRIVATE_VNDK_CORE_INTERMEDIATES_2ND := \ - $(call paths-of-intermediates,$(foreach lib,$(vndk_core_libs),$(lib):$(lib).so),SHARED_LIBRARIES,true) +$(vndk_snapshot_zip): PRIVATE_VNDK_CORE_INTERMEDIATES_2ND := $(deps) +$(vndk_snapshot_zip): $(foreach d,$(deps),$(call word-colon,1,$(d))) +deps := +deps := $(call paths-of-intermediates,$(foreach lib,$(vndk_sp_libs),$(lib):$(subst .vendor,,$(lib)).so),true) $(vndk_snapshot_zip): PRIVATE_VNDK_SP_OUT_2ND := $(vndk_lib_dir_2nd)/shared/vndk-sp -$(vndk_snapshot_zip): PRIVATE_VNDK_SP_INTERMEDIATES_2ND := \ - $(call paths-of-intermediates,$(foreach lib,$(vndk_sp_libs),$(lib):$(lib).so),SHARED_LIBRARIES,true) +$(vndk_snapshot_zip): PRIVATE_VNDK_SP_INTERMEDIATES_2ND := $(deps) +$(vndk_snapshot_zip): $(foreach d,$(deps),$(call word-colon,1,$(d))) +deps := endif # Args # $(1): destination directory -# $(2): list of files to copy -$(vndk_snapshot_zip): private-copy-vndk-intermediates = \ +# $(2): list of files (src:dest) to copy +$(vndk_snapshot_zip): private-copy-intermediates = \ $(if $(2),$(strip \ - @mkdir -p $(1); \ + @mkdir -p $(1) && \ $(foreach file,$(2), \ - if [ -e $(file) ]; then \ - cp -p $(file) $(call append-path,$(1),$(subst .vendor,,$(notdir $(file)))); \ - fi; \ + cp $(call word-colon,1,$(file)) $(call append-path,$(1),$(call word-colon,2,$(file))) && \ ) \ + true \ )) -vndk_snapshot_dependencies := \ - $(vndk_snapshot_libs) \ - $(vndk_prebuilt_txts) \ - $(vndk_snapshot_configs) -$(vndk_snapshot_zip): $(vndk_snapshot_dependencies) $(SOONG_ZIP) +$(vndk_snapshot_zip): $(SOONG_ZIP) @echo 'Generating VNDK snapshot: $@' @rm -f $@ @rm -rf $(PRIVATE_VNDK_SNAPSHOT_OUT) @mkdir -p $(PRIVATE_VNDK_SNAPSHOT_OUT) - $(call private-copy-vndk-intermediates, \ + $(call private-copy-intermediates, \ $(PRIVATE_VNDK_CORE_OUT),$(PRIVATE_VNDK_CORE_INTERMEDIATES)) - $(call private-copy-vndk-intermediates, \ + $(call private-copy-intermediates, \ $(PRIVATE_VNDK_SP_OUT),$(PRIVATE_VNDK_SP_INTERMEDIATES)) - $(call private-copy-vndk-intermediates, \ + $(call private-copy-intermediates, \ $(PRIVATE_CONFIGS_OUT),$(PRIVATE_CONFIGS_INTERMEDIATES)) - $(call private-copy-vndk-intermediates, \ + $(call private-copy-intermediates, \ $(PRIVATE_NOTICE_FILES_OUT),$(PRIVATE_NOTICE_FILES_INTERMEDIATES)) ifdef TARGET_2ND_ARCH - $(call private-copy-vndk-intermediates, \ + $(call private-copy-intermediates, \ $(PRIVATE_VNDK_CORE_OUT_2ND),$(PRIVATE_VNDK_CORE_INTERMEDIATES_2ND)) - $(call private-copy-vndk-intermediates, \ + $(call private-copy-intermediates, \ $(PRIVATE_VNDK_SP_OUT_2ND),$(PRIVATE_VNDK_SP_INTERMEDIATES_2ND)) endif $(hide) $(SOONG_ZIP) -o $@ -C $(PRIVATE_VNDK_SNAPSHOT_OUT) -D $(PRIVATE_VNDK_SNAPSHOT_OUT) @@ -240,7 +249,6 @@ vndk_snapshot_variant := binder := vndk_lib_dir := vndk_lib_dir_2nd := -vndk_snapshot_dependencies := else # BOARD_VNDK_RUNTIME_DISABLE is set to 'true' error_msg := "CANNOT generate VNDK snapshot. BOARD_VNDK_RUNTIME_DISABLE must not be set to 'true'." From 14e1026372ae806ecaa06b418b47b0831fa05112 Mon Sep 17 00:00:00 2001 From: Dan Willemsen Date: Sun, 17 Jun 2018 21:54:21 -0700 Subject: [PATCH 2/2] Fix PHONY uses found by --warn_real_to_phony Switch a use of `ndk` to the timestamp file that `ndk` depends on itself. Mark more module-specific rules as PHONY. Test: diff build-aosp_arm.ninja (stripping _kati_always_build_) Test: Turn on --warn_real_to_phony for Kati, see fewer warnings Change-Id: I101ced4067780e38d18820f5d916596429087e49 --- core/Makefile | 2 +- core/base_rules.mk | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/core/Makefile b/core/Makefile index 1161e4df3e..a5109f0ae8 100644 --- a/core/Makefile +++ b/core/Makefile @@ -2917,7 +2917,7 @@ endif # ----------------------------------------------------------------- # NDK Sysroot Package NDK_SYSROOT_TARGET := $(PRODUCT_OUT)/ndk_sysroot.tar.bz2 -$(NDK_SYSROOT_TARGET): ndk +$(NDK_SYSROOT_TARGET): $(SOONG_OUT_DIR)/ndk.timestamp @echo Package NDK sysroot... $(hide) tar cjf $@ -C $(SOONG_OUT_DIR) ndk diff --git a/core/base_rules.mk b/core/base_rules.mk index 41af27b6a2..4f0e39f39c 100644 --- a/core/base_rules.mk +++ b/core/base_rules.mk @@ -793,8 +793,10 @@ ifneq (,$(filter $(my_module_tags),tests)) $(j_or_n)-$(h_or_t)-tests $(j_or_n)-tests $(h_or_t)-tests : $(my_checked_module) endif $(LOCAL_MODULE)-$(h_or_hc_or_t) : $(my_all_targets) +.PHONY: $(LOCAL_MODULE)-$(h_or_hc_or_t) ifeq ($(j_or_n),native) $(LOCAL_MODULE)-$(h_or_hc_or_t)$(my_32_64_bit_suffix) : $(my_all_targets) +.PHONY: $(LOCAL_MODULE)-$(h_or_hc_or_t)$(my_32_64_bit_suffix) endif endif