Phony target to report all library names.
Bug: 68860345
Bug: 151177513
Bug: 151953481
Test: m nothing reportallnoticelibrarynames
Change-Id: I0f791e2d92b8135d6af3a6c93f0db348fc69f5a1
diff --git a/core/definitions.mk b/core/definitions.mk
index 94e03a2..314ba0a 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -874,6 +874,34 @@
endef
+
+###########################################################
+# Returns the unique list of built license metadata files.
+###########################################################
+define all-license-metadata
+$(sort \
+ $(foreach t,$(ALL_NON_MODULES),$(if $(filter 0p,$(ALL_TARGETS.$(t).META_LIC)),, $(ALL_TARGETS.$(t).META_LIC))) \
+ $(foreach m,$(ALL_MODULES), $(ALL_MODULES.$(m).META_LIC)) \
+)
+endef
+
+###########################################################
+# Declares the rule to report all library names used in any notice files.
+###########################################################
+define report-all-notice-library-names-rule
+$(strip $(eval _all := $(call all-license-metadata)))
+
+.PHONY: reportallnoticelibrarynames
+reportallnoticelibrarynames: PRIVATE_LIST_FILE := $(call license-metadata-dir)/filelist
+reportallnoticelibrarynames: | $(COMPLIANCENOTICE_SHIPPEDLIBS)
+reportallnoticelibrarynames: $(_all)
+ @echo Reporting notice library names for at least $$(words $(_all)) license metadata files
+ $(hide) rm -f $$(PRIVATE_LIST_FILE)
+ $(hide) mkdir -p $$(dir $$(PRIVATE_LIST_FILE))
+ $(hide) find out -name '*meta_lic' -type f -printf '"%p"\n' >$$(PRIVATE_LIST_FILE)
+ $(COMPLIANCENOTICE_SHIPPEDLIBS) @$$(PRIVATE_LIST_FILE)
+endef
+
###########################################################
## Declares a license metadata build rule for ALL_MODULES
###########################################################
@@ -888,7 +916,8 @@
) \
$(foreach t,$(sort $(ALL_NON_MODULES)),$(eval $(call non-module-license-metadata-rule,$(t)))) \
$(foreach m,$(sort $(ALL_MODULES)),$(eval $(call license-metadata-rule,$(m)))) \
- $(eval $(call report-missing-licenses-rule)))
+ $(eval $(call report-missing-licenses-rule)) \
+ $(eval $(call report-all-notice-library-names-rule)))
endef
###########################################################