diff --git a/core/definitions.mk b/core/definitions.mk index a9d5733e11..cbb1613a61 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -2976,6 +2976,19 @@ $(2): $(1) $$(copy-file-to-target) endef +# Define a rule to copy a license metadata file. For use via $(eval). +# $(1): source license metadata file +# $(2): destination license metadata file +# $(3): built targets +# $(4): installed targets +define copy-one-license-metadata-file +$(2): PRIVATE_BUILT=$(3) +$(2): PRIVATE_INSTALLED=$(4) +$(2): $(1) + @echo "Copy: $$@" + $$(call copy-license-metadata-file-to-target,$$(PRIVATE_BUILT),$$(PRIVATE_INSTALLED)) +endef + define copy-and-uncompress-dexs $(2): $(1) $(ZIPALIGN) $(ZIP2ZIP) @echo "Uncompress dexs in: $$@" @@ -3163,6 +3176,17 @@ $(hide) rm -f $@ $(hide) cp "$<" "$@" endef +# Same as copy-file-to-target, but assume file is a licenes metadata file, +# and append built from $(1) and installed from $(2). +define copy-license-metadata-file-to-target +@mkdir -p $(dir $@) +$(hide) rm -f $@ +$(hide) cp "$<" "$@" $(strip \ + $(foreach b,$(1), && (grep -F 'built: "'"$(b)"'"' "$@" >/dev/null || echo 'built: "'"$(b)"'"' >>"$@")) \ + $(foreach i,$(2), && (grep -F 'installed: "'"$(i)"'"' "$@" >/dev/null || echo 'installed: "'"$(i)"'"' >>"$@")) \ +) +endef + # The same as copy-file-to-target, but use the local # cp command instead of acp. define copy-file-to-target-with-cp diff --git a/core/notice_files.mk b/core/notice_files.mk index cbfcaa4f7a..efc17511c0 100644 --- a/core/notice_files.mk +++ b/core/notice_files.mk @@ -135,7 +135,7 @@ ifdef my_register_name ifdef LOCAL_SOONG_LICENSE_METADATA # Soong modules have already produced a license metadata file, copy it to where Make expects it. - $(eval $(call copy-one-file, $(LOCAL_SOONG_LICENSE_METADATA), $(module_license_metadata))) + $(eval $(call copy-one-license-metadata-file, $(LOCAL_SOONG_LICENSE_METADATA), $(module_license_metadata),$(ALL_MODULES.$(my_register_name).BUILT),$(ALL_MODUES.$(my_register_name).INSTALLED))) else # Make modules don't have enough information to produce a license metadata rule until after fix-notice-deps # has been called, store the necessary information until later.