Append built and installed when copying metadata.

Soong doesn't always have the built and installed available.

Bug: 239638693

Test: m droid dist

Change-Id: Id18201da488e3b16d60957c9a298a52345595c5b
This commit is contained in:
Bob Badour 2022-07-29 15:31:21 -07:00
parent 193de78dfd
commit 04fbe29669
2 changed files with 25 additions and 1 deletions

View file

@ -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

View file

@ -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.