From 42f00c7b61513bf324ad869deceab67acae65e92 Mon Sep 17 00:00:00 2001 From: Bob Badour Date: Sat, 19 Mar 2022 23:20:59 -0700 Subject: [PATCH] Test suite notices using dependencies. Switch from combine-notice-files to html-notice-rule and text-notice-rule. Bug: 151177513 Bug: 213388645 Bug: 210912771 Test: m cts reportmissinglicenses Change-Id: I59d78553f15f0fd6be87228c933693b63e2ebf04 --- core/base_rules.mk | 3 +++ core/clear_vars.mk | 2 ++ core/definitions.mk | 18 ++++++++++++----- core/notice_files.mk | 2 +- core/tasks/cts.mk | 3 +++ core/tasks/tools/compatibility.mk | 33 ++++++++++++++++++++++++------- 6 files changed, 48 insertions(+), 13 deletions(-) diff --git a/core/base_rules.mk b/core/base_rules.mk index e26f456b2c..c01cde8e9e 100644 --- a/core/base_rules.mk +++ b/core/base_rules.mk @@ -33,6 +33,9 @@ ifeq ($(LOCAL_MODULE),) endif $(call verify-module-name) +my_test_data := +my_test_config := + LOCAL_IS_HOST_MODULE := $(strip $(LOCAL_IS_HOST_MODULE)) ifdef LOCAL_IS_HOST_MODULE ifneq ($(LOCAL_IS_HOST_MODULE),true) diff --git a/core/clear_vars.mk b/core/clear_vars.mk index 57f9ef8aef..b5b371c186 100644 --- a/core/clear_vars.mk +++ b/core/clear_vars.mk @@ -510,6 +510,8 @@ LOCAL_TEST_PACKAGE := full_android_manifest := non_system_module := +module_license_metadata := + # Trim MAKEFILE_LIST so that $(call my-dir) doesn't need to # iterate over thousands of entries every time. # Leave the current makefile to make sure we don't break anything diff --git a/core/definitions.mk b/core/definitions.mk index 1c9ebad78b..d4d6a67785 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -680,12 +680,12 @@ $(strip $(eval _deps := $(sort $(filter-out 0p: :,$(foreach d,$(strip $(ALL_NON_ $(strip $(eval _notices := $(sort $(ALL_NON_MODULES.$(_tgt).NOTICES)))) $(strip $(eval _path := $(sort $(ALL_NON_MODULES.$(_tgt).PATH)))) $(strip $(eval _install_map := $(ALL_NON_MODULES.$(_tgt).ROOT_MAPPINGS))) -$(strip \ - $(foreach d,$(strip $(ALL_NON_MODULES.$(_tgt).DEPENDENCIES)), \ - $(if $(strip $(ALL_TARGETS.$(d).META_LIC)), \ +$(strip $(eval \ + $$(foreach d,$(strip $(ALL_NON_MODULES.$(_tgt).DEPENDENCIES)), \ + $$(if $$(strip $$(ALL_TARGETS.$$(d).META_LIC)), \ , \ - $(eval NON_MODULES_WITHOUT_LICENSE_METADATA += $(d))) \ - ) \ + $$(eval NON_MODULES_WITHOUT_LICENSE_METADATA += $$(d))) \ + )) \ ) $(_dir)/$(_tgt).meta_lic: PRIVATE_KINDS := $(sort $(ALL_NON_MODULES.$(_tgt).LICENSE_KINDS)) @@ -3321,6 +3321,14 @@ endef # and use my_compat_dist_$(suite) to define the others. define create-suite-dependencies $(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \ + $(eval $(if $(strip $(module_license_metadata)),\ + $$(foreach f,$$(my_compat_dist_$(suite)),$$(eval ALL_TARGETS.$$(call word-colon,2,$$(f)).META_LIC := $(module_license_metadata))),\ + $$(eval my_test_data += $$(foreach f,$$(my_compat_dist_$(suite)), $$(call word-colon,2,$$(f)))) \ + )) \ + $(eval $(if $(strip $(module_license_metadata)),\ + $$(foreach f,$$(my_compat_dist_config_$(suite)),$$(eval ALL_TARGETS.$$(call word-colon,2,$$(f)).META_LIC := $(module_license_metadata))),\ + $$(eval my_test_config += $$(foreach f,$$(my_compat_dist_config_$(suite)), $$(call word-colon,2,$$(f)))) \ + )) \ $(if $(filter $(suite),$(ALL_COMPATIBILITY_SUITES)),,\ $(eval ALL_COMPATIBILITY_SUITES += $(suite)) \ $(eval COMPATIBILITY.$(suite).FILES :=) \ diff --git a/core/notice_files.mk b/core/notice_files.mk index 4ebbe2eeef..8b2dade8bb 100644 --- a/core/notice_files.mk +++ b/core/notice_files.mk @@ -127,7 +127,7 @@ module_license_metadata := ifdef my_register_name module_license_metadata := $(call local-intermediates-dir)/$(my_register_name).meta_lic - $(foreach target,$(ALL_MODULES.$(my_register_name).BUILT) $(ALL_MODULES.$(my_register_name).INSTALLED),\ + $(foreach target,$(ALL_MODULES.$(my_register_name).BUILT) $(ALL_MODULES.$(my_register_name).INSTALLED) $(my_test_data) $(my_test_config),\ $(eval ALL_TARGETS.$(target).META_LIC := $(module_license_metadata))) ALL_MODULES.$(my_register_name).META_LIC := $(strip $(ALL_MODULES.$(my_register_name).META_LIC) $(module_license_metadata)) diff --git a/core/tasks/cts.mk b/core/tasks/cts.mk index 876d77a641..3f846687a3 100644 --- a/core/tasks/cts.mk +++ b/core/tasks/cts.mk @@ -17,6 +17,9 @@ test_suite_tradefed := cts-tradefed test_suite_dynamic_config := cts/tools/cts-tradefed/DynamicConfig.xml test_suite_readme := cts/tools/cts-tradefed/README +$(call declare-1p-target,$(test_suite_dynamic_config),cts) +$(call declare-1p-target,$(test_suite_readme),cts) + include $(BUILD_SYSTEM)/tasks/tools/compatibility.mk .PHONY: cts diff --git a/core/tasks/tools/compatibility.mk b/core/tasks/tools/compatibility.mk index 47cf4400dd..3b348bd059 100644 --- a/core/tasks/tools/compatibility.mk +++ b/core/tasks/tools/compatibility.mk @@ -40,6 +40,8 @@ test_tools := $(HOST_OUT_JAVA_LIBRARIES)/tradefed.jar \ $(HOST_OUT_EXECUTABLES)/$(test_suite_tradefed) \ $(test_suite_readme) +$(foreach f,$(test_suite_readme),$(if $(strip $(ALL_TARGETS.$(f).META_LIC)),,$(eval ALL_TARGETS.$(f).META_LIC := $(module_license_metadata)))) + test_tools += $(test_suite_tools) # The JDK to package into the test suite zip file. Always package the linux JDK. @@ -51,9 +53,24 @@ $(test_suite_jdk): $(shell find $(test_suite_jdk_dir) -type f | sort) $(test_suite_jdk): $(SOONG_ZIP) $(SOONG_ZIP) -o $@ -P $(PRIVATE_SUBDIR)/jdk -C $(PRIVATE_JDK_DIR) -D $(PRIVATE_JDK_DIR) +$(call declare-license-metadata,$(test_suite_jdk),SPDX-license-identifier-GPL-2.0-with-classpath-exception,restricted,\ + $(test_suite_jdk_dir)/legal/java.base/LICENSE,JDK,prebuilts/jdk/$(notdir $(patsubst %/,%,$(dir $(test_suite_jdk_dir))))) + + # Include host shared libraries host_shared_libs := $(call copy-many-files, $(COMPATIBILITY.$(test_suite_name).HOST_SHARED_LIBRARY.FILES)) +$(if $(strip $(host_shared_libs)),\ + $(foreach p,$(COMPATIBILITY.$(test_suite_name).HOST_SHARED_LIBRARY.FILES),\ + $(eval _src := $(call word-colon,1,$(p)))\ + $(eval _dst := $(call word-colon,2,$(p)))\ + $(if $(strip $(ALL_TARGETS.$(_src).META_LIC)),\ + $(eval ALL_TARGETS.$(_dst).META_LIC := $(ALL_TARGETS.$(_src).META_LIC)),\ + $(warning $(_src) has no license metadata for $(_dst))\ + )\ + )\ +) + compatibility_zip_deps := \ $(test_artifacts) \ $(test_tools) \ @@ -70,13 +87,6 @@ compatibility_zip_resources := $(out_dir)/tools $(out_dir)/testcases $(out_dir)/ test_suite_notice_txt := $(out_dir)/NOTICE.txt test_suite_notice_html := $(out_dir)/NOTICE.html -$(eval $(call combine-notice-files, html, \ - $(test_suite_notice_txt), \ - $(test_suite_notice_html), \ - "Notices for files contained in the test suites filesystem image in this directory:", \ - $(HOST_OUT_NOTICE_FILES) $(TARGET_OUT_NOTICE_FILES), \ - $(compatibility_zip_deps))) - compatibility_zip_deps += $(test_suite_notice_txt) compatibility_zip_resources += $(test_suite_notice_txt) @@ -110,6 +120,15 @@ $(compatibility_zip): $(compatibility_zip_deps) | $(ADB) $(ACP) $(SOONG_ZIP) -d -o $(PRIVATE_tests_list_zip) -j -f $(PRIVATE_tests_list) rm -f $(PRIVATE_tests_list) +$(call declare-1p-container,$(compatibility_zip),) +$(call declare-container-license-deps,$(compatibility_zip),$(compatibility_zip_deps) $(test_suite_jdk),$(out_dir)/:/) + +$(eval $(call html-notice-rule,$(test_suite_notice_html),"Test suites","Notices for files contained in the test suites filesystem image:",$(compatibility_zip),$(compatibility_zip))) +$(eval $(call text-notice-rule,$(test_suite_notice_txt),"Test suites","Notices for files contained in the test suites filesystem image:",$(compatibility_zip),$(compatibility_zip))) + +$(call declare-0p-target,$(test_suite_notice_html)) +$(call declare-0p-target,$(test_suite_notice_txt)) + # Reset all input variables test_suite_name := test_suite_tradefed :=