Merge "Create license metadata for copied targets." am: 1f0c3583a6

Original change: https://android-review.googlesource.com/c/platform/build/+/2109383

Change-Id: I7998946185221bf572ff678c837893dcf0b44064
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Treehugger Robot 2022-06-03 03:14:22 +00:00 committed by Automerger Merge Worker
commit 62f582272d
5 changed files with 79 additions and 13 deletions

View file

@ -3506,7 +3506,7 @@ INSTALLED_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
$(eval $(call copy-one-file,$(BOARD_PREBUILT_VENDORIMAGE),$(INSTALLED_VENDORIMAGE_TARGET)))
$(if $(strip $(ALL_TARGETS.$(INSTALLED_VENDORIMAGE_TARGET).META_LIC)),,\
$(if $(strip $(ALL_TARGETS.$(BOARD_PREBUILT_VENDORIMAGE).META_LIC)),\
$(eval ALL_TARGETS.$(INSTALLED_VENDORIMAGE_TARGET).META_LIC:=$(ALL_TARGETS.$(BOARD_PREBUILT_VENDORIMAGE).META_LIC)),\
$(call declare-copy-target-license-metadata,$(INSTALLED_VENDORIMAGE_TARGET),$(BOARD_PREBUILT_VENDORIMAGE)),\
$(call declare-license-metadata,$(INSTALLED_VENDORIMAGE_TARGET),legacy_proprietary,proprietary,,"Vendor Image",vendor)))
endif

View file

@ -41,6 +41,9 @@ ALL_MODULES:=
ALL_NON_MODULES:=
NON_MODULES_WITHOUT_LICENSE_METADATA:=
# List of copied targets that need license metadata copied.
ALL_COPIED_TARGETS:=
# Full paths to targets that should be added to the "make droid"
# set of installed targets.
ALL_DEFAULT_INSTALLED_MODULES:=
@ -582,6 +585,19 @@ $(strip $(foreach target, $(sort $(1)), \
$(call append-path,$(call license-metadata-dir),$(patsubst $(OUT_DIR)%,out%,$(target).meta_lic))))))
endef
###########################################################
## Record a target $(1) copied from another target(s) $(2) that will need
## license metadata.
###########################################################
define declare-copy-target-license-metadata
$(strip $(if $(filter $(OUT_DIR)%,$(2)),$(eval _dir:=$(call license-metadata-dir))\
$(eval _tgt:=$(strip $(1)))\
$(eval _meta := $(call append-path,$(_dir),$(patsubst $(OUT_DIR)%,out%,$(_tgt).meta_lic)))\
$(eval ALL_COPIED_TARGETS.$(_tgt).SOURCES := $(ALL_COPIED_TARGETS.$(_tgt).SOURCES) $(filter $(OUT_DIR)%,$(2)))\
$(eval ALL_COPIED_TARGETS += $(_tgt)),\
$(eval ALL_TARGETS.$(1).META_LIC:=$(module_license_metadata))))
endef
###########################################################
## License metadata build rule for my_register_name $(1)
###########################################################
@ -661,13 +677,6 @@ $(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 $(eval \
$$(foreach d,$(strip $(ALL_NON_MODULES.$(_tgt).DEPENDENCIES)), \
$$(if $$(strip $$(ALL_TARGETS.$$(d).META_LIC)), \
, \
$$(eval NON_MODULES_WITHOUT_LICENSE_METADATA += $$(d))) \
)) \
)
$(_meta): PRIVATE_KINDS := $(sort $(ALL_NON_MODULES.$(_tgt).LICENSE_KINDS))
$(_meta): PRIVATE_CONDITIONS := $(sort $(ALL_NON_MODULES.$(_tgt).LICENSE_CONDITIONS))
@ -704,6 +713,60 @@ $(_meta) : $(foreach d,$(_deps),$(call word-colon,1,$(d))) $(foreach n,$(_notice
endef
###########################################################
## Record missing dependencies for non-module target $(1)
###########################################################
define record-missing-non-module-dependencies
$(strip $(eval _tgt := $(strip $(1))))
$(strip $(foreach d,$(strip $(ALL_NON_MODULES.$(_tgt).DEPENDENCIES)), \
$(if $(strip $(ALL_TARGETS.$(d).META_LIC)), \
, \
$(eval NON_MODULES_WITHOUT_LICENSE_METADATA += $(d))) \
))
endef
###########################################################
## License metadata build rule for copied target $(1)
###########################################################
define copied-target-license-metadata-rule
$(if $(strip $(ALL_TARGETS.$(1).META_LIC)),,$(call _copied-target-license-metadata-rule,$(1)))
endef
define _copied-target-license-metadata-rule
$(strip $(eval _dir := $(call license-metadata-dir)))
$(strip $(eval _meta := $(call append-path,$(_dir),$(patsubst $(OUT_DIR)%,out%,$(1).meta_lic))))
$(strip $(eval ALL_TARGETS.$(1).META_LIC:=$(_meta)))
$(strip $(eval _dep:=))
$(strip $(foreach s,$(ALL_COPIED_TARGETS.$(1).SOURCES),\
$(eval _dmeta:=$(ALL_TARGETS.$(s).META_LIC))\
$(if $(filter 0p,$(_dmeta)),\
$(if $(filter-out 0p,$(_dep)),,$(eval ALL_TARGETS.$(1).META_LIC:=0p)),\
$(if $(_dep),\
$(if $(filter-out $(_dep),$(_dmeta)),$(error cannot copy target from multiple modules: $(1) from $(_dep) and $(_dmeta))),
$(eval _dep:=$(_dmeta))))))
$(strip $(if $(strip $(_dep)),,$(error cannot copy target from unknown module: $(1) from $(ALL_COPIED_TARGETS.$(1).SOURCES))))
ifneq (0p,$(ALL_TARGETS.$(1).META_LIC))
$(_meta): PRIVATE_DEST_TARGET := $(1)
$(_meta): PRIVATE_SOURCE_TARGETS := $(ALL_COPIED_TARGETS.$(1).SOURCES)
$(_meta): PRIVATE_SOURCE_METADATA := $(_dep)
$(_meta): PRIVATE_ARGUMENT_FILE := $(call intermediates-dir-for,PACKAGING,copynotice)/$(_meta)/arguments
$(_meta) : $(_dep)
rm -f $$@
mkdir -p $$(dir $$@)
mkdir -p $$(dir $$(PRIVATE_ARGUMENT_FILE))
$$(call dump-words-to-file,\
$$(addprefix -i ,$$(PRIVATE_DEST_TARGET))\
$$(addprefix -s ,$$(PRIVATE_SOURCE_TARGETS))\
$$(addprefix -d ,$$(PRIVATE_SOURCE_METADATA)),\
$$(PRIVATE_ARGUMENT_FILE))
OUT_DIR=$(OUT_DIR) $(COPY_LICENSE_METADATA) \
@$$(PRIVATE_ARGUMENT_FILE) \
-o $$@
endif
endef
###########################################################
## Declare the license metadata for non-module target $(1).
##
@ -919,6 +982,8 @@ $(strip \
) \
$(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)))) \
$(foreach t,$(sort $(ALL_COPIED_TARGETS)),$(eval $(call copied-target-license-metadata-rule,$(t)))) \
$(foreach t,$(sort $(ALL_NON_MODULES)),$(call record-missing-non-module-dependencies,$(t))) \
$(eval $(call report-missing-licenses-rule)) \
$(eval $(call report-all-notice-library-names-rule)) \
$(eval $(call build-all-license-metadata-rule)))
@ -3402,11 +3467,11 @@ endef
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))),\
$$(foreach f,$$(my_compat_dist_$(suite)),$$(call declare-copy-target-license-metadata,$$(call word-colon,2,$$(f)),$$(call word-colon,1,$$(f)))),\
$$(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))),\
$$(foreach f,$$(my_compat_dist_config_$(suite)),$$(call declare-copy-target-license-metadata,$$(call word-colon,2,$$(f)),$$(call word-colon,1,$$(f)))),\
$$(eval my_test_config += $$(foreach f,$$(my_compat_dist_config_$(suite)), $$(call word-colon,2,$$(f)))) \
)) \
$(if $(filter $(suite),$(ALL_COMPATIBILITY_SUITES)),,\

View file

@ -935,7 +935,7 @@ $(foreach suite,general-tests device-tests vts tvts art-host-tests host-unit-tes
$(eval my_testcases := $(HOST_OUT_TESTCASES)),\
$(eval my_testcases := $$(COMPATIBILITY_TESTCASES_OUT_$(suite))))\
$(eval target := $(my_testcases)/$(lastword $(subst /, ,$(dir $(f))))/$(notdir $(f)))\
$(if $(strip $(ALL_TARGETS.$(target).META_LIC)),,$(eval ALL_TARGETS.$(target).META_LIC:=$(module_license_metadata)))\
$(if $(strip $(ALL_TARGETS.$(target).META_LIC)),,$(call declare-copy-target-license-metadata,$(target),$(f)))\
$(eval COMPATIBILITY.$(suite).HOST_SHARED_LIBRARY.FILES := \
$$(COMPATIBILITY.$(suite).HOST_SHARED_LIBRARY.FILES) $(f):$(target))\
$(eval COMPATIBILITY.$(suite).HOST_SHARED_LIBRARY.FILES := \

View file

@ -127,7 +127,8 @@ 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) $(my_test_data) $(my_test_config),\
$(foreach target,$(ALL_MODULES.$(my_register_name).BUILT) $(ALL_MODULES.$(my_register_name).INSTALLED) $(foreach bi,$(LOCAL_SOONG_BUILT_INSTALLED),$(call word-colon,1,$(bi))) \
$(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))

View file

@ -29,6 +29,6 @@ $(foreach m,$(1),\
$(eval my_copy_dest := $(patsubst data/%,DATA/%,\
$(patsubst system/%,DATA/%,\
$(patsubst $(PRODUCT_OUT)/%,%,$(ins)))))\
$(eval ALL_TARGETS.$(2)/$(my_copy_dest).META_LIC := $(if $(strip $(ALL_MODULES.$(m).META_LIC)),$(ALL_MODULES.$(m).META_LIC),$(ALL_MODULES.$(m).DELAYED_META_LIC)))\
$(call declare-copy-target-license-metadata,$(2)/$(my_copy_dest),$(bui))\
$(bui):$(2)/$(my_copy_dest))))
endef