Merge changes from topic "tproto"
* changes: Convert .meta_lic files to textproto Add macros for non-module license metadata and deps
This commit is contained in:
@@ -87,6 +87,24 @@ define word-colon
|
||||
$(word $(1),$(subst :,$(space),$(2)))
|
||||
endef
|
||||
|
||||
###########################################################
|
||||
## Read a colon-separated sublist out of a colon-separated
|
||||
## list of words.
|
||||
## This has similar behavior to the built-in function
|
||||
## $(wordlist s,e,str) except both the input and output
|
||||
## word lists are colon-separated.
|
||||
##
|
||||
## The individual words may not contain spaces.
|
||||
##
|
||||
## $(1): 1 based index start
|
||||
## $(2): 1 based index end (can be 0)
|
||||
## $(3): value of the form a:b:c...
|
||||
###########################################################
|
||||
|
||||
define wordlist-colon
|
||||
$(subst $(space),:,$(wordlist $(1),$(2),$(subst :,$(space),$(3))))
|
||||
endef
|
||||
|
||||
###########################################################
|
||||
## Convert "a=b c= d e = f = g h=" into "a=b c=d e= f=g h="
|
||||
##
|
||||
|
@@ -1291,6 +1291,9 @@ $(target_notice_file_html_gz): $(target_notice_file_html) | $(MINIGZIP)
|
||||
$(hide) $(MINIGZIP) -9 < $< > $@
|
||||
$(installed_notice_html_or_xml_gz): $(target_notice_file_html_gz)
|
||||
$(copy-file-to-target)
|
||||
|
||||
$(call declare-0p-target,$(target_notice_file_html_gz))
|
||||
$(call declare-0p-target,$(installed_notice_html_or_xml_gz))
|
||||
else
|
||||
target_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml
|
||||
target_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml.gz
|
||||
@@ -1474,6 +1477,28 @@ $(installed_vendor_dlkm_notice_xml_gz): $(target_vendor_dlkm_notice_file_xml_gz)
|
||||
$(installed_odm_dlkm_notice_xml_gz): $(target_odm_dlkm_notice_file_xml_gz)
|
||||
$(copy-file-to-target)
|
||||
|
||||
$(call declare-0p-target,$(target_notice_file_xml))
|
||||
$(call declare-0p-target,$(target_notice_file_xml_gz))
|
||||
$(call declare-0p-target,$(target_vendor_notice_file_xml))
|
||||
$(call declare-0p-target,$(target_vendor_notice_file_xml_gz))
|
||||
$(call declare-0p-target,$(target_product_notice_file_xml))
|
||||
$(call declare-0p-target,$(target_product_notice_file_xml_gz))
|
||||
$(call declare-0p-target,$(target_system_ext_notice_file_xml))
|
||||
$(call declare-0p-target,$(target_system_ext_notice_file_xml_gz))
|
||||
$(call declare-0p-target,$(target_odm_notice_file_xml))
|
||||
$(call declare-0p-target,$(target_odm_notice_file_xml_gz))
|
||||
$(call declare-0p-target,$(target_vendor_dlkm_notice_file_xml))
|
||||
$(call declare-0p-target,$(target_vendor_dlkm_notice_file_xml_gz))
|
||||
$(call declare-0p-target,$(target_odm_dlkm_notice_file_xml))
|
||||
$(call declare-0p-target,$(target_odm_dlkm_notice_file_xml_gz))
|
||||
$(call declare-0p-target,$(installed_notice_html_or_xml_gz))
|
||||
$(call declare-0p-target,$(installed_vendor_notice_xml_gz))
|
||||
$(call declare-0p-target,$(installed_product_notice_xml_gz))
|
||||
$(call declare-0p-target,$(installed_system_ext_notice_xml_gz))
|
||||
$(call declare-0p-target,$(installed_odm_notice_xml_gz))
|
||||
$(call declare-0p-target,$(installed_vendor_dlkm_notice_xml_gz))
|
||||
$(call declare-0p-target,$(installed_odm_dlkm_notice_xml_gz))
|
||||
|
||||
ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_or_xml_gz)
|
||||
ALL_DEFAULT_INSTALLED_MODULES += $(installed_vendor_notice_xml_gz)
|
||||
ALL_DEFAULT_INSTALLED_MODULES += $(installed_product_notice_xml_gz)
|
||||
@@ -2751,6 +2776,9 @@ endif
|
||||
$(BUILT_SYSTEMIMAGE): $(FULL_SYSTEMIMAGE_DEPS) $(INSTALLED_FILES_FILE)
|
||||
$(call build-systemimage-target,$@)
|
||||
|
||||
$(call declare-1p-container,$(BUILT_SYSTEMIMAGE),system/extras)
|
||||
$(call declare-container-license-deps,$(BUILT_SYSTEMIMAGE),$(FULL_SYSTEMIMAGE_DEPS),$(PRODUCT_OUT)/:)
|
||||
|
||||
INSTALLED_SYSTEMIMAGE_TARGET := $(PRODUCT_OUT)/system.img
|
||||
SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT)
|
||||
|
||||
@@ -2792,8 +2820,14 @@ $(INSTALLED_SYSTEMIMAGE_TARGET): $(BUILT_SYSTEMIMAGE)
|
||||
$(copy-file-to-target)
|
||||
$(hide) $(call assert-max-image-size,$@,$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
|
||||
|
||||
$(call declare-1p-container,$(INSTALLED_SYSTEMIMAGE_TARGET),)
|
||||
$(call declare-container-license-deps,$(INSTALLED_SYSTEMIMAGE_TARGET),$(BUILT_SYSTEMIMAGE),$(BUILT_SYSTEMIMAGE):/)
|
||||
|
||||
systemimage: $(INSTALLED_SYSTEMIMAGE_TARGET)
|
||||
|
||||
.PHONY: systemlicense
|
||||
systemlicense: $(call license-metadata-dir)/$(INSTALLED_SYSTEMIMAGE_TARGET).meta_lic reportmissinglicenses
|
||||
|
||||
.PHONY: systemimage-nodeps snod
|
||||
systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \
|
||||
| $(INTERNAL_USERIMAGES_DEPS)
|
||||
|
@@ -542,7 +542,8 @@ else ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
|
||||
# Rule to install the module's companion symlinks
|
||||
my_installed_symlinks := $(addprefix $(my_module_path)/,$(LOCAL_MODULE_SYMLINKS) $(LOCAL_MODULE_SYMLINKS_$(my_32_64_bit_suffix)))
|
||||
$(foreach symlink,$(my_installed_symlinks),\
|
||||
$(call symlink-file,$(LOCAL_INSTALLED_MODULE),$(my_installed_module_stem),$(symlink)))
|
||||
$(call symlink-file,$(LOCAL_INSTALLED_MODULE),$(my_installed_module_stem),$(symlink))\
|
||||
$(call declare-0p-target,$(symlink)))
|
||||
|
||||
$(my_all_targets) : | $(my_installed_symlinks)
|
||||
|
||||
|
@@ -187,6 +187,7 @@ LOCAL_MODULE_SYMLINKS:=
|
||||
LOCAL_MODULE_TAGS:=
|
||||
LOCAL_MODULE_TARGET_ARCH:=
|
||||
LOCAL_MODULE_TARGET_ARCH_WARN:=
|
||||
LOCAL_MODULE_TYPE:=
|
||||
LOCAL_MODULE_UNSUPPORTED_HOST_ARCH:=
|
||||
LOCAL_MODULE_UNSUPPORTED_HOST_ARCH_WARN:=
|
||||
LOCAL_MODULE_UNSUPPORTED_TARGET_ARCH:=
|
||||
|
@@ -37,6 +37,10 @@ ALL_DOCS:=
|
||||
# sub-variables.
|
||||
ALL_MODULES:=
|
||||
|
||||
# The relative paths of the non-module targets in the system.
|
||||
ALL_NON_MODULES:=
|
||||
NON_MODULES_WITHOUT_LICENSE_METADATA:=
|
||||
|
||||
# Full paths to targets that should be added to the "make droid"
|
||||
# set of installed targets.
|
||||
ALL_DEFAULT_INSTALLED_MODULES:=
|
||||
@@ -539,7 +543,7 @@ $(strip \
|
||||
$(eval _all_module_refs := \
|
||||
$(sort \
|
||||
$(foreach m,$(sort $(ALL_MODULES)), \
|
||||
$(ALL_MODULES.$(m).NOTICE_DEPS) \
|
||||
$(call word-colon,1,$(ALL_MODULES.$(m).NOTICE_DEPS)) \
|
||||
) \
|
||||
) \
|
||||
) \
|
||||
@@ -557,7 +561,7 @@ $(strip \
|
||||
$(eval ALL_MODULES.$(m).NOTICE_DEPS := \
|
||||
$(sort \
|
||||
$(foreach d,$(sort $(ALL_MODULES.$(m).NOTICE_DEPS)), \
|
||||
$(_lookup.$(d)) \
|
||||
$(foreach n,$(_lookup.$(call word-colon,1,$(d))),$(n):$(call wordlist-colon,2,9999,$(d))) \
|
||||
) \
|
||||
) \
|
||||
) \
|
||||
@@ -573,35 +577,56 @@ $(call generated-sources-dir-for,META,lic,)
|
||||
endef
|
||||
|
||||
###########################################################
|
||||
## License metadata build rule for my_register_name $1
|
||||
## License metadata build rule for my_register_name $(1)
|
||||
###########################################################
|
||||
define license-metadata-rule
|
||||
$(strip $(eval _dir := $(call license-metadata-dir)))
|
||||
$(strip $(eval _deps := $(sort $(filter-out $(_dir)/$(1).meta_lic,$(foreach d,$(ALL_MODULES.$(1).NOTICE_DEPS), $(_dir)/$(d).meta_lic)))))
|
||||
$(strip $(eval _srcs := $(strip $(foreach d,$(ALL_MODULES.$(1).NOTICE_DEPS),$(if $(strip $(ALL_MODULES.$(call word-colon,1,$(d)).INSTALLED)), $(ALL_MODULES.$(call word-colon,1,$(d)).INSTALLED),$(if $(strip $(ALL_MODULES.$(call word-colon,1,$(d)).BUILT)), $(ALL_MODULES.$(call word-colon,1,$(d)).BUILT), $(call word-colon,1,$d)))))))
|
||||
$(strip $(eval _deps := $(sort $(filter-out $(_dir)/$(1).meta_lic%,$(foreach d,$(ALL_MODULES.$(1).NOTICE_DEPS), $(_dir)/$(call word-colon,1,$(d)).meta_lic:$(call wordlist-colon,2,9999,$d))))))
|
||||
$(strip $(eval _notices := $(sort $(ALL_MODULES.$(1).NOTICES))))
|
||||
$(strip $(eval _tgts := $(sort $(ALL_MODULES.$(1).BUILT) $(ALL_MODULES.$(1).INSTALLED))))
|
||||
$(foreach b,$(_tgts),
|
||||
$(_dir)/$(b).meta_module ::
|
||||
mkdir -p $$(dir $$@)
|
||||
echo $(_dir)/$(1).meta_lic >> $$@
|
||||
sort -u $$@ -o $$@
|
||||
$(strip $(eval _tgts := $(sort $(ALL_MODULES.$(1).BUILT))))
|
||||
$(strip $(eval _inst := $(sort $(ALL_MODULES.$(1).INSTALLED))))
|
||||
$(strip $(eval _path := $(sort $(ALL_MODULES.$(1).PATH))))
|
||||
$(strip $(eval _map := $(strip $(foreach _m,$(sort $(ALL_MODULES.$(1).LICENSE_INSTALL_MAP)), \
|
||||
$(eval _s := $(call word-colon,1,$(_m))) \
|
||||
$(eval _d := $(call word-colon,2,$(_m))) \
|
||||
$(eval _ns := $(if $(strip $(ALL_MODULES.$(_s).INSTALLED)),$(ALL_MODULES.$(_s).INSTALLED),$(if $(strip $(ALL_MODULES.$(_s).BUILT)),$(ALL_MODULES.$(_s).BUILT),$(_s)))) \
|
||||
$(foreach ns,$(_ns),$(ns):$(_d) ) \
|
||||
))))
|
||||
|
||||
)
|
||||
$(_dir)/$(1).meta_lic: PRIVATE_KINDS := $(sort $(ALL_MODULES.$(1).LICENSE_KINDS))
|
||||
$(_dir)/$(1).meta_lic: PRIVATE_CONDITIONS := $(sort $(ALL_MODULES.$(1).LICENSE_CONDITIONS))
|
||||
$(_dir)/$(1).meta_lic: PRIVATE_NOTICES := $(_notices)
|
||||
$(_dir)/$(1).meta_lic: PRIVATE_NOTICE_DEPS := $(_deps)
|
||||
$(_dir)/$(1).meta_lic: PRIVATE_SOURCES := $(_srcs)
|
||||
$(_dir)/$(1).meta_lic: PRIVATE_TARGETS := $(_tgts)
|
||||
$(_dir)/$(1).meta_lic: PRIVATE_INSTALLED := $(_inst)
|
||||
$(_dir)/$(1).meta_lic: PRIVATE_PATH := $(_path)
|
||||
$(_dir)/$(1).meta_lic: PRIVATE_IS_CONTAINER := $(ALL_MODULES.$(1).IS_CONTAINER)
|
||||
$(_dir)/$(1).meta_lic: PRIVATE_PACKAGE_NAME := $(strip $(ALL_MODULES.$(1).LICENSE_PACKAGE_NAME))
|
||||
$(_dir)/$(1).meta_lic: PRIVATE_INSTALL_MAP := $(sort $(ALL_MODULES.$(1).LICENSE_INSTALL_MAP))
|
||||
$(_dir)/$(1).meta_lic : $(_deps) $(_notices) $(foreach b,$(_tgts), $(_dir)/$(b).meta_module) build/make/tools/build-license-metadata.sh
|
||||
$(_dir)/$(1).meta_lic: PRIVATE_INSTALL_MAP := $(_map)
|
||||
$(_dir)/$(1).meta_lic: PRIVATE_MODULE_TYPE := $(ALL_MODULES.$(1).MODULE_TYPE)
|
||||
$(_dir)/$(1).meta_lic: PRIVATE_MODULE_CLASS := $(ALL_MODULES.$(1).MODULE_CLASS)
|
||||
$(_dir)/$(1).meta_lic: PRIVATE_INSTALL_MAP := $(_map)
|
||||
$(_dir)/$(1).meta_lic: $(BUILD_LICENSE_METADATA)
|
||||
$(_dir)/$(1).meta_lic : $(foreach d,$(_deps),$(call word-colon,1,$(d))) $(foreach n,$(_notices),$(call word-colon,1,$(n)) )
|
||||
rm -f $$@
|
||||
mkdir -p $$(dir $$@)
|
||||
build/make/tools/build-license-metadata.sh -k $$(PRIVATE_KINDS) -c $$(PRIVATE_CONDITIONS) -n $$(PRIVATE_NOTICES) -d $$(PRIVATE_NOTICE_DEPS) -m $$(PRIVATE_INSTALL_MAP) -t $$(PRIVATE_TARGETS) $$(if $$(PRIVATE_IS_CONTAINER),-is_container) -p '$$(PRIVATE_PACKAGE_NAME)' -o $$@
|
||||
|
||||
.PHONY: $(1).meta_lic
|
||||
$(1).meta_lic : $(_dir)/$(1).meta_lic
|
||||
$(BUILD_LICENSE_METADATA) \
|
||||
$$(addprefix -mt ,$$(PRIVATE_MODULE_TYPE)) \
|
||||
$$(addprefix -mc ,$$(PRIVATE_MODULE_CLASS)) \
|
||||
$$(addprefix -k ,$$(PRIVATE_KINDS)) \
|
||||
$$(addprefix -c ,$$(PRIVATE_CONDITIONS)) \
|
||||
$$(addprefix -n ,$$(PRIVATE_NOTICES)) \
|
||||
$$(addprefix -d ,$$(PRIVATE_NOTICE_DEPS)) \
|
||||
$$(addprefix -s ,$$(PRIVATE_SOURCES)) \
|
||||
$$(addprefix -m ,$$(PRIVATE_INSTALL_MAP)) \
|
||||
$$(addprefix -t ,$$(PRIVATE_TARGETS)) \
|
||||
$$(addprefix -i ,$$(PRIVATE_INSTALLED)) \
|
||||
$$(if $$(PRIVATE_IS_CONTAINER),-is_container) \
|
||||
-p '$$(PRIVATE_PACKAGE_NAME)' \
|
||||
$$(addprefix -r ,$$(PRIVATE_PATH)) \
|
||||
-o $$@
|
||||
|
||||
$(strip $(eval _mifs := $(sort $(ALL_MODULES.$(1).MODULE_INSTALLED_FILENAMES))))
|
||||
$(strip $(eval _infs := $(sort $(ALL_MODULES.$(1).INSTALLED_NOTICE_FILE))))
|
||||
@@ -613,9 +638,9 @@ $(strip $(eval _mif := $(firstword $(foreach m,$(_mifs),$(if $(filter %/src/$(m)
|
||||
|
||||
$(inf) : $(_dir)/$(1).meta_lic
|
||||
$(inf): PRIVATE_INSTALLED_MODULE := $(_mif)
|
||||
$(inf) : PRIVATE_NOTICES := $(_notices)
|
||||
$(inf) : PRIVATE_NOTICES := $(sort $(foreach n,$(_notices),$(call word-colon,1,$(n) )))
|
||||
|
||||
$(inf): $(_notices)
|
||||
$(inf): $(foreach n,$(_notices),$(call word-colon,1,$(n)) )
|
||||
@echo Notice file: $$< -- $$@
|
||||
mkdir -p $$(dir $$@)
|
||||
awk 'FNR==1 && NR > 1 {print "\n"} {print}' $$(PRIVATE_NOTICES) > $$@
|
||||
@@ -624,11 +649,196 @@ $(inf): $(_notices)
|
||||
|
||||
endef
|
||||
|
||||
###########################################################
|
||||
## License metadata build rule for non-module target $(1)
|
||||
###########################################################
|
||||
define non-module-license-metadata-rule
|
||||
$(strip $(eval _dir := $(call license-metadata-dir)))
|
||||
$(strip $(eval _tgt := $(strip $(1))))
|
||||
$(strip $(eval _deps := $(sort $(filter-out 0p: :,$(foreach d,$(strip $(ALL_NON_MODULES.$(_tgt).DEPENDENCIES)),$(ALL_TARGETS.$(call word-colon,1,$(d)).META_LIC):$(call wordlist-colon,2,9999,$(d)))))))
|
||||
$(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)), \
|
||||
, \
|
||||
$(eval NON_MODULES_WITHOUT_LICENSE_METADATA += $(d))) \
|
||||
) \
|
||||
)
|
||||
|
||||
$(_dir)/$(_tgt).meta_lic: PRIVATE_KINDS := $(sort $(ALL_NON_MODULES.$(_tgt).LICENSE_KINDS))
|
||||
$(_dir)/$(_tgt).meta_lic: PRIVATE_CONDITIONS := $(sort $(ALL_NON_MODULES.$(_tgt).LICENSE_CONDITIONS))
|
||||
$(_dir)/$(_tgt).meta_lic: PRIVATE_NOTICES := $(_notices)
|
||||
$(_dir)/$(_tgt).meta_lic: PRIVATE_NOTICE_DEPS := $(_deps)
|
||||
$(_dir)/$(_tgt).meta_lic: PRIVATE_SOURCES := $(ALL_NON_MODULES.$(_tgt).DEPENDENCIES)
|
||||
$(_dir)/$(_tgt).meta_lic: PRIVATE_TARGETS := $(_tgt)
|
||||
$(_dir)/$(_tgt).meta_lic: PRIVATE_PATH := $(_path)
|
||||
$(_dir)/$(_tgt).meta_lic: PRIVATE_IS_CONTAINER := $(ALL_NON_MODULES.$(_tgt).IS_CONTAINER)
|
||||
$(_dir)/$(_tgt).meta_lic: PRIVATE_PACKAGE_NAME := $(strip $(ALL_NON_MODULES.$(_tgt).LICENSE_PACKAGE_NAME))
|
||||
$(_dir)/$(_tgt).meta_lic: PRIVATE_INSTALL_MAP := $(strip $(_install_map))
|
||||
$(_dir)/$(_tgt).meta_lic: $(BUILD_LICENSE_METADATA)
|
||||
$(_dir)/$(_tgt).meta_lic : $(foreach d,$(_deps),$(call word-colon,1,$(d))) $(foreach n,$(_notices),$(call word-colon,1,$(n)) )
|
||||
rm -f $$@
|
||||
mkdir -p $$(dir $$@)
|
||||
$(BUILD_LICENSE_METADATA) \
|
||||
-mt raw -mc unknown \
|
||||
$$(addprefix -k ,$$(PRIVATE_KINDS)) \
|
||||
$$(addprefix -c ,$$(PRIVATE_CONDITIONS)) \
|
||||
$$(addprefix -n ,$$(PRIVATE_NOTICES)) \
|
||||
$$(addprefix -d ,$$(PRIVATE_NOTICE_DEPS)) \
|
||||
$$(addprefix -s ,$$(PRIVATE_SOURCES)) \
|
||||
$$(addprefix -m ,$$(PRIVATE_INSTALL_MAP)) \
|
||||
$$(addprefix -t ,$$(PRIVATE_TARGETS)) \
|
||||
$$(if $$(PRIVATE_IS_CONTAINER),-is_container) \
|
||||
-p '$$(PRIVATE_PACKAGE_NAME)' \
|
||||
$$(addprefix -r ,$$(PRIVATE_PATH)) \
|
||||
-o $$@
|
||||
|
||||
endef
|
||||
|
||||
###########################################################
|
||||
## Declare the license metadata for non-module target $(1).
|
||||
##
|
||||
## $(2) -- license kinds e.g. SPDX-license-identifier-Apache-2.0
|
||||
## $(3) -- license conditions e.g. notice by_exception_only
|
||||
## $(4) -- license text filenames (notices)
|
||||
## $(5) -- package name
|
||||
## $(6) -- project path
|
||||
###########################################################
|
||||
define declare-license-metadata
|
||||
$(strip \
|
||||
$(eval _tgt := $(strip $(1))) \
|
||||
$(eval ALL_NON_MODULES += $(_tgt)) \
|
||||
$(eval ALL_NON_MODULES.$(_tgt).LICENSE_KINDS := $(strip $(2))) \
|
||||
$(eval ALL_NON_MODULES.$(_tgt).LICENSE_CONDITIONS := $(strip $(3))) \
|
||||
$(eval ALL_NON_MODULES.$(_tgt).NOTICES := $(strip $(4))) \
|
||||
$(eval ALL_NON_MODULES.$(_tgt).LICENSE_PACKAGE_NAME := $(strip $(5))) \
|
||||
$(eval ALL_NON_MODULES.$(_tgt).PATH := $(strip $(6))) \
|
||||
)
|
||||
endef
|
||||
|
||||
###########################################################
|
||||
## Declare the license metadata for non-module container-type target $(1).
|
||||
##
|
||||
## Container-type targets are targets like .zip files that
|
||||
## merely aggregate other files.
|
||||
##
|
||||
## $(2) -- license kinds e.g. SPDX-license-identifier-Apache-2.0
|
||||
## $(3) -- license conditions e.g. notice by_exception_only
|
||||
## $(4) -- license text filenames (notices)
|
||||
## $(5) -- package name
|
||||
## $(6) -- project path
|
||||
###########################################################
|
||||
define declare-container-license-metadata
|
||||
$(strip \
|
||||
$(eval _tgt := $(strip $(1))) \
|
||||
$(eval ALL_NON_MODULES += $(_tgt)) \
|
||||
$(eval ALL_NON_MODULES.$(_tgt).LICENSE_KINDS := $(strip $(2))) \
|
||||
$(eval ALL_NON_MODULES.$(_tgt).LICENSE_CONDITIONS := $(strip $(3))) \
|
||||
$(eval ALL_NON_MODULES.$(_tgt).NOTICES := $(strip $(4))) \
|
||||
$(eval ALL_NON_MODULES.$(_tgt).LICENSE_PACKAGE_NAME := $(strip $(5))) \
|
||||
$(eval ALL_NON_MODULES.$(_tgt).PATH := $(strip $(6))) \
|
||||
$(eval ALL_NON_MODULES.$(_tgt).IS_CONTAINER := true) \
|
||||
)
|
||||
endef
|
||||
|
||||
###########################################################
|
||||
## Declare that non-module target $(1) is a non-copyrightable file.
|
||||
##
|
||||
## e.g. an information-only file merely listing other files.
|
||||
###########################################################
|
||||
define declare-0p-target
|
||||
$(strip \
|
||||
$(eval _tgt := $(strip $(1))) \
|
||||
$(eval ALL_0P_TARGETS += $(_tgt)) \
|
||||
)
|
||||
endef
|
||||
|
||||
###########################################################
|
||||
## Declare non-module target $(1) to have a first-party license
|
||||
## (Android Apache 2.0)
|
||||
##
|
||||
## $(2) -- project path
|
||||
###########################################################
|
||||
define declare-1p-target
|
||||
$(call declare-license-metadata,$(1),SPDX-license-identifier-Apache-2.0,notice,build/soong/licenses/LICENSE,Android,$(2))
|
||||
endef
|
||||
|
||||
###########################################################
|
||||
## Declare non-module container-type target $(1) to have a
|
||||
## first-party license (Android Apache 2.0).
|
||||
##
|
||||
## Container-type targets are targets like .zip files that
|
||||
## merely aggregate other files.
|
||||
##
|
||||
## $92) -- project path
|
||||
###########################################################
|
||||
define declare-1p-container
|
||||
$(call declare-container-license-metadata,$(1),SPDX-license-identifier-Apache-2.0,notice,build/soong/licenses/LICENSE,Android,$(2))
|
||||
endef
|
||||
|
||||
###########################################################
|
||||
## Declare license dependencies $(2) for non-module target $(1)
|
||||
###########################################################
|
||||
define declare-license-deps
|
||||
$(strip \
|
||||
$(eval _tgt := $(strip $(1))) \
|
||||
$(eval ALL_NON_MODULES += $(_tgt)) \
|
||||
$(eval ALL_NON_MODULES.$(_tgt).DEPENDENCIES := $(strip $(ALL_NON_MODULES.$(_tgt).DEPENDENCIES) $(2))) \
|
||||
)
|
||||
endef
|
||||
|
||||
###########################################################
|
||||
## Declare license dependencies $(2) for non-module container-type target $(1)
|
||||
##
|
||||
## Container-type targets are targets like .zip files that
|
||||
## merely aggregate other files.
|
||||
##
|
||||
## $(3) -- root mappings space-separated source:target
|
||||
###########################################################
|
||||
define declare-container-license-deps
|
||||
$(strip \
|
||||
$(eval _tgt := $(strip $(1))) \
|
||||
$(eval ALL_NON_MODULES += $(_tgt)) \
|
||||
$(eval ALL_NON_MODULES.$(_tgt).DEPENDENCIES := $(strip $(ALL_NON_MODULES.$(_tgt).DEPENDENCIES) $(2))) \
|
||||
$(eval ALL_NON_MODULES.$(_tgt).IS_CONTAINER := true) \
|
||||
$(eval ALL_NON_MODULES.$(_tgt).ROOT_MAPPINGS := $(strip $(ALL_NON_MODULES.$(_tgt).ROOT_MAPPINGS) $(3))) \
|
||||
)
|
||||
endef
|
||||
|
||||
###########################################################
|
||||
## Declares the rule to report targets with no license metadata.
|
||||
###########################################################
|
||||
define report-missing-licenses-rule
|
||||
.PHONY: reportmissinglicenses
|
||||
reportmissinglicenses: PRIVATE_NON_MODULES:=$(sort $(NON_MODULES_WITHOUT_LICENSE_METADATA))
|
||||
reportmissinglicenses:
|
||||
@echo Reporting $$(words $$(PRIVATE_NON_MODULES)) targets without license metadata
|
||||
$$(foreach t,$$(PRIVATE_NON_MODULES),if ! [ -h $$(t) ]; then echo No license metadata for $$(t) >&2; fi;)
|
||||
|
||||
endef
|
||||
|
||||
###########################################################
|
||||
## Declares a license metadata build rule for ALL_MODULES
|
||||
###########################################################
|
||||
define build-license-metadata
|
||||
$(foreach m,$(sort $(ALL_MODULES)),$(eval $(call license-metadata-rule,$(m))))
|
||||
$(strip \
|
||||
$(strip $(eval _dir := $(call license-metadata-dir))) \
|
||||
$(foreach t,$(sort $(ALL_0P_TARGETS)), \
|
||||
$(eval ALL_TARGETS.$(t).META_LIC := 0p) \
|
||||
) \
|
||||
$(foreach t,$(sort $(ALL_NON_MODULES)), \
|
||||
$(eval ALL_TARGETS.$(t).META_LIC := $(_dir)/$(t).meta_lic) \
|
||||
) \
|
||||
$(foreach m,$(sort $(ALL_MODULES)), \
|
||||
$(foreach d,$(sort $(ALL_MODULES.$(m).BUILT) $(ALL_MODULES.$(m).INSTALLED)), \
|
||||
$(eval ALL_TARGETS.$(d).META_LIC := $(_dir)/$(m).meta_lic) \
|
||||
) \
|
||||
) \
|
||||
)$(foreach t,$(sort $(ALL_NON_MODULES)),$(eval $(call non-module-license-metadata-rule,$(t))))$(strip \
|
||||
)$(foreach m,$(sort $(ALL_MODULES)),$(eval $(call license-metadata-rule,$(m))))$(strip \
|
||||
)$(eval $(call report-missing-licenses-rule))
|
||||
endef
|
||||
|
||||
###########################################################
|
||||
|
@@ -81,43 +81,60 @@ ifeq (true,$(is_container))
|
||||
# Include shared libraries' notices for "container" types, but not for binaries etc.
|
||||
notice_deps := \
|
||||
$(strip \
|
||||
$(LOCAL_REQUIRED_MODULES) \
|
||||
$(LOCAL_STATIC_LIBRARIES) \
|
||||
$(LOCAL_WHOLE_STATIC_LIBRARIES) \
|
||||
$(LOCAL_SHARED_LIBRARIES) \
|
||||
$(LOCAL_DYLIB_LIBRARIES) \
|
||||
$(LOCAL_RLIB_LIBRARIES) \
|
||||
$(LOCAL_PROC_MACRO_LIBRARIES) \
|
||||
$(LOCAL_HEADER_LIBRARIES) \
|
||||
$(LOCAL_STATIC_JAVA_LIBRARIES) \
|
||||
$(LOCAL_JAVA_LIBRARIES) \
|
||||
$(LOCAL_JNI_SHARED_LIBRARIES) \
|
||||
$(foreach d, \
|
||||
$(LOCAL_REQUIRED_MODULES) \
|
||||
$(LOCAL_STATIC_LIBRARIES) \
|
||||
$(LOCAL_WHOLE_STATIC_LIBRARIES) \
|
||||
$(LOCAL_SHARED_LIBRARIES) \
|
||||
$(LOCAL_DYLIB_LIBRARIES) \
|
||||
$(LOCAL_RLIB_LIBRARIES) \
|
||||
$(LOCAL_PROC_MACRO_LIBRARIES) \
|
||||
$(LOCAL_HEADER_LIBRARIES) \
|
||||
$(LOCAL_STATIC_JAVA_LIBRARIES) \
|
||||
$(LOCAL_JAVA_LIBRARIES) \
|
||||
$(LOCAL_JNI_SHARED_LIBRARIES) \
|
||||
,$(subst :,_,$(d)):static \
|
||||
) \
|
||||
)
|
||||
else
|
||||
notice_deps := \
|
||||
$(strip \
|
||||
$(LOCAL_REQUIRED_MODULES) \
|
||||
$(LOCAL_STATIC_LIBRARIES) \
|
||||
$(LOCAL_WHOLE_STATIC_LIBRARIES) \
|
||||
$(LOCAL_RLIB_LIBRARIES) \
|
||||
$(LOCAL_PROC_MACRO_LIBRARIES) \
|
||||
$(LOCAL_HEADER_LIBRARIES) \
|
||||
$(LOCAL_STATIC_JAVA_LIBRARIES) \
|
||||
$(foreach d, \
|
||||
$(LOCAL_REQUIRED_MODULES) \
|
||||
$(LOCAL_STATIC_LIBRARIES) \
|
||||
$(LOCAL_WHOLE_STATIC_LIBRARIES) \
|
||||
$(LOCAL_RLIB_LIBRARIES) \
|
||||
$(LOCAL_PROC_MACRO_LIBRARIES) \
|
||||
$(LOCAL_HEADER_LIBRARIES) \
|
||||
$(LOCAL_STATIC_JAVA_LIBRARIES) \
|
||||
,$(subst :,_,$(d)):static \
|
||||
)$(foreach d, \
|
||||
$(LOCAL_SHARED_LIBRARIES) \
|
||||
$(LOCAL_DYLIB_LIBRARIES) \
|
||||
$(LOCAL_JAVA_LIBRARIES) \
|
||||
$(LOCAL_JNI_SHARED_LIBRARIES) \
|
||||
,$(subst :,_,$(d)):dynamic \
|
||||
) \
|
||||
)
|
||||
endif
|
||||
ifeq ($(LOCAL_IS_HOST_MODULE),true)
|
||||
notice_deps := $(strip $(notice_deps) $(LOCAL_HOST_REQUIRED_MODULES))
|
||||
notice_deps := $(strip $(notice_deps) $(foreach d,$(LOCAL_HOST_REQUIRED_MODULES),$(subst :,_,$(d)):static))
|
||||
else
|
||||
notice_deps := $(strip $(notice_deps) $(LOCAL_TARGET_REQUIRED_MODULES))
|
||||
notice_deps := $(strip $(notice_deps) $(foreach d,$(LOCAL_TARGET_REQUIRED_MODULES),$(subst :,_,$(d)):static))
|
||||
endif
|
||||
|
||||
local_path := $(LOCAL_PATH)
|
||||
|
||||
ifdef my_register_name
|
||||
ALL_MODULES.$(my_register_name).LICENSE_PACKAGE_NAME := $(strip $(license_package_name))
|
||||
ALL_MODULES.$(my_register_name).MODULE_TYPE := $(strip $(ALL_MODULES.$(my_register_name).MODULE_TYPE) $(LOCAL_MODULE_TYPE))
|
||||
ALL_MODULES.$(my_register_name).MODULE_CLASS := $(strip $(ALL_MODULES.$(my_register_name).MODULE_CLASS) $(LOCAL_MODULE_CLASS))
|
||||
ALL_MODULES.$(my_register_name).LICENSE_KINDS := $(ALL_MODULES.$(my_register_name).LICENSE_KINDS) $(license_kinds)
|
||||
ALL_MODULES.$(my_register_name).LICENSE_CONDITIONS := $(ALL_MODULES.$(my_register_name).LICENSE_CONDITIONS) $(license_conditions)
|
||||
ALL_MODULES.$(my_register_name).LICENSE_INSTALL_MAP := $(ALL_MODULES.$(my_register_name).LICENSE_INSTALL_MAP) $(install_map)
|
||||
ALL_MODULES.$(my_register_name).NOTICE_DEPS := $(ALL_MODULES.$(my_register_name).NOTICE_DEPS) $(notice_deps)
|
||||
ALL_MODULES.$(my_register_name).IS_CONTAINER := $(strip $(filter-out false,$(ALL_MODULES.$(my_register_name).IS_CONTAINER) $(is_container)))
|
||||
ALL_MODULES.$(my_register_name).PATH := $(strip $(ALL_MODULES.$(my_register_name).PATH) $(local_path))
|
||||
endif
|
||||
|
||||
ifdef notice_file
|
||||
@@ -185,9 +202,9 @@ ALL_MODULES.$(my_register_name).MODULE_INSTALLED_FILENAMES := $(ALL_MODULES.$(my
|
||||
INSTALLED_NOTICE_FILES.$(installed_notice_file).MODULE := $(my_register_name)
|
||||
else
|
||||
$(installed_notice_file): PRIVATE_INSTALLED_MODULE := $(module_installed_filename)
|
||||
$(installed_notice_file) : PRIVATE_NOTICES := $(notice_file)
|
||||
$(installed_notice_file) : PRIVATE_NOTICES := $(sort $(foreach n,$(notice_file),$(if $(filter %:%,$(n)), $(call word-colon,1,$(n)), $(n))))
|
||||
|
||||
$(installed_notice_file): $(notice_file)
|
||||
$(installed_notice_file): $(foreach n,$(notice_file),$(if $(filter %:%,$(n)), $(call word-colon,1,$(n)), $(n)))
|
||||
@echo Notice file: $< -- $@
|
||||
$(hide) mkdir -p $(dir $@)
|
||||
$(hide) awk 'FNR==1 && NR > 1 {print "\n"} {print}' $(PRIVATE_NOTICES) > $@
|
||||
|
@@ -1,313 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -u
|
||||
|
||||
ME=$(basename $0)
|
||||
|
||||
USAGE="Usage: ${ME} {options}
|
||||
|
||||
Builds a license metadata specification and outputs it to stdout or {outfile}.
|
||||
|
||||
The available options are:
|
||||
|
||||
-k kind... license kinds
|
||||
-c condition... license conditions
|
||||
-p package... license package name
|
||||
-n notice... license notice file
|
||||
-d dependency... license metadata file dependency
|
||||
-t target... targets
|
||||
-m target:installed... map dependent targets to their installed names
|
||||
-is_container preserved dependent target name when given
|
||||
-o outfile output file
|
||||
"
|
||||
|
||||
# Global flag variables
|
||||
license_kinds=
|
||||
license_conditions=
|
||||
license_package_name=
|
||||
license_notice=
|
||||
license_deps=
|
||||
targets=
|
||||
installmap=
|
||||
is_container=false
|
||||
ofile=
|
||||
|
||||
# Global variables
|
||||
depfiles=" "
|
||||
effective_conditions=
|
||||
|
||||
|
||||
# Exits with a message.
|
||||
#
|
||||
# When the exit status is 2, assumes a usage error and outputs the usage message
|
||||
# to stderr before outputting the specific error message to stderr.
|
||||
#
|
||||
# Parameters:
|
||||
# Optional numeric exit status (defaults to 2, i.e. a usage error.)
|
||||
# Remaining args treated as an error message sent to stderr.
|
||||
die() {
|
||||
lstatus=2
|
||||
case "${1:-}" in *[^0-9]*) ;; *) lstatus="$1"; shift ;; esac
|
||||
case "${lstatus}" in 2) echo "${USAGE}" >&2; echo >&2 ;; esac
|
||||
if [ -n "$*" ]; then
|
||||
echo -e "$*\n" >&2
|
||||
fi
|
||||
exit $lstatus
|
||||
}
|
||||
|
||||
|
||||
# Sets the flag variables based on the command-line.
|
||||
#
|
||||
# invoke with: process_args "$@"
|
||||
process_args() {
|
||||
lcurr_flag=
|
||||
while [ "$#" -gt '0' ]; do
|
||||
case "${1}" in
|
||||
-h)
|
||||
echo "${USAGE}"
|
||||
exit 0
|
||||
;;
|
||||
-k)
|
||||
lcurr_flag=kind
|
||||
;;
|
||||
-c)
|
||||
lcurr_flag=condition
|
||||
;;
|
||||
-p)
|
||||
lcurr_flag=package
|
||||
;;
|
||||
-n)
|
||||
lcurr_flag=notice
|
||||
;;
|
||||
-d)
|
||||
lcurr_flag=dependency
|
||||
;;
|
||||
-t)
|
||||
lcurr_flag=target
|
||||
;;
|
||||
-m)
|
||||
lcurr_flag=installmap
|
||||
;;
|
||||
-o)
|
||||
lcurr_flag=ofile
|
||||
;;
|
||||
-is_container)
|
||||
lcurr_flag=
|
||||
is_container=true
|
||||
;;
|
||||
-*)
|
||||
die "Unknown flag: \"${1}\""
|
||||
;;
|
||||
*)
|
||||
case "${lcurr_flag}" in
|
||||
kind)
|
||||
license_kinds="${license_kinds}${license_kinds:+ }${1}"
|
||||
;;
|
||||
condition)
|
||||
license_conditions="${license_conditions}${license_conditions:+ }${1}"
|
||||
;;
|
||||
package)
|
||||
license_package_name="${license_package_name}${license_package_name:+ }${1}"
|
||||
;;
|
||||
notice)
|
||||
license_notice="${license_notice}${license_notice:+ }${1}"
|
||||
;;
|
||||
dependency)
|
||||
license_deps="${license_deps}${license_deps:+ }${1}"
|
||||
;;
|
||||
target)
|
||||
targets="${targets}${targets:+ }${1}"
|
||||
;;
|
||||
installmap)
|
||||
installmap="${installmap}${installmap:+ }${1}"
|
||||
;;
|
||||
ofile)
|
||||
if [ -n "${ofile}" ]; then
|
||||
die "Output file -o appears twice as \"${ofile}\" and \"${1}\""
|
||||
fi
|
||||
ofile="${1}"
|
||||
;;
|
||||
*)
|
||||
die "Must precede argument \"${1}\" with type flag."
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
}
|
||||
|
||||
# Reads a license metadata file from stdin, and outputs the named dependencies.
|
||||
#
|
||||
# No parameters.
|
||||
extract_deps() {
|
||||
awk '$1 == "dep_name:" { sub(/^"/, "", $2); sub(/"$/, "", $2); print $2; }'
|
||||
}
|
||||
|
||||
# Populates the depfiles variable identifying dependency files.
|
||||
#
|
||||
# Starting with the dependencies enumerated in license_deps, calculates the
|
||||
# transitive closure of all dependencies.
|
||||
#
|
||||
# Dependency names ending in .meta_module indirectly reference license
|
||||
# metadata with 1 license metadata filename per line.
|
||||
#
|
||||
# No parameters; no output.
|
||||
read_deps() {
|
||||
lnewdeps=
|
||||
for d in ${license_deps}; do
|
||||
case "${d}" in
|
||||
*.meta_module)
|
||||
lnewdeps="${lnewdeps}${lnewdeps:+ }"$(cat "${d}") ;;
|
||||
*)
|
||||
lnewdeps="${lnewdeps}${lnewdeps:+ }${d}" ;;
|
||||
esac
|
||||
done
|
||||
lnewdeps=$(echo "${lnewdeps}" | tr ' ' '\n' | sort -u)
|
||||
lalldeps=
|
||||
ldeps=
|
||||
lmod=
|
||||
ldep=
|
||||
while [ "${#lnewdeps}" -gt '0' ]; do
|
||||
ldeps="${lnewdeps}"
|
||||
lnewdeps=
|
||||
for ldep in ${ldeps}; do
|
||||
depfiles="${depfiles}${ldep} "
|
||||
lalldeps="${lalldeps}${lalldeps:+ }"$(cat "${ldep}" | extract_deps)
|
||||
done
|
||||
lalldeps=$(for d in ${lalldeps}; do echo "${d}"; done | sort -u)
|
||||
for d in ${lalldeps}; do
|
||||
ldeps="${d}"
|
||||
case "${d}" in *.meta_module) ldeps=$(cat "${d}") ;; esac
|
||||
for lmod in ${ldeps}; do
|
||||
if ! expr "${depfiles}" : ".* ${lmod} .*" >/dev/null 2>&1; then
|
||||
lnewdeps="${lnewdeps}${lnewdeps:+ }${lmod}"
|
||||
fi
|
||||
done
|
||||
done
|
||||
lalldeps=
|
||||
done
|
||||
}
|
||||
|
||||
# Returns the effective license conditions for the current license metadata.
|
||||
#
|
||||
# If a module is restricted or links in a restricted module, the effective
|
||||
# license has a restricted condition.
|
||||
calculate_effective_conditions() {
|
||||
lconditions="${license_conditions}"
|
||||
case "${license_conditions}" in
|
||||
*restricted*) : do nothing ;;
|
||||
*)
|
||||
for d in ${depfiles}; do
|
||||
if cat "${d}" | egrep -q 'effective_condition\s*:.*restricted' ; then
|
||||
lconditions="${lconditions}${lconditions:+ }restricted"
|
||||
break
|
||||
fi
|
||||
done
|
||||
;;
|
||||
esac
|
||||
echo "${lconditions}"
|
||||
}
|
||||
|
||||
|
||||
process_args "$@"
|
||||
|
||||
if [ -n "${ofile}" ]; then
|
||||
# truncate the output file before appending results
|
||||
: >"${ofile}"
|
||||
else
|
||||
ofile=/dev/stdout
|
||||
fi
|
||||
|
||||
# spit out the license metadata file content
|
||||
(
|
||||
echo 'license_package_name: "'${license_package_name}'"'
|
||||
for kind in ${license_kinds}; do
|
||||
echo 'license_kind: "'${kind}'"'
|
||||
done
|
||||
for condition in ${license_conditions}; do
|
||||
echo 'license_condition: "'${condition}'"'
|
||||
done
|
||||
for f in ${license_notice}; do
|
||||
echo 'license_text: "'${f}'"'
|
||||
done
|
||||
echo "is_container: ${is_container}"
|
||||
for t in ${targets}; do
|
||||
echo 'target: "'${t}'"'
|
||||
done
|
||||
for m in ${installmap}; do
|
||||
echo 'install_map: "'${m}'"'
|
||||
done
|
||||
) >>"${ofile}"
|
||||
read_deps
|
||||
effective_conditions=$(calculate_effective_conditions)
|
||||
for condition in ${effective_conditions}; do
|
||||
echo 'effective_condition: "'${condition}'"'
|
||||
done >>"${ofile}"
|
||||
for dep in ${depfiles}; do
|
||||
echo 'dep {'
|
||||
cat "${dep}" | \
|
||||
awk -v name="${dep}" '
|
||||
function strip_type() {
|
||||
$1 = ""
|
||||
sub(/^\s*/, "")
|
||||
}
|
||||
BEGIN {
|
||||
print " dep_name: " name
|
||||
}
|
||||
$1 == "license_package_name:" {
|
||||
strip_type()
|
||||
print " dep_package_name: "$0
|
||||
}
|
||||
$1 == "dep_name:" {
|
||||
print " dep_sub_dep: "$2
|
||||
}
|
||||
$1 == "license_kind:" {
|
||||
print " dep_license_kind: "$2
|
||||
}
|
||||
$1 == "license_condition:" {
|
||||
print " dep_license_condition: "$2
|
||||
}
|
||||
$1 == "is_container:" {
|
||||
print " dep_is_container: "$2
|
||||
}
|
||||
$1 == "license_text:" {
|
||||
strip_type()
|
||||
print " dep_license_text: "$0
|
||||
}
|
||||
$1 == "target:" {
|
||||
print " dep_target: "$2
|
||||
}
|
||||
$1 == "install_map:" {
|
||||
print " dep_install_map: "$2
|
||||
}
|
||||
'
|
||||
# The restricted license kind is contagious to all linked dependencies.
|
||||
dep_conditions=$(echo $(
|
||||
cat "${dep}" | awk '
|
||||
$1 == "effective_condition:" {
|
||||
$1 = ""
|
||||
sub(/^\s*/, "")
|
||||
gsub(/"/, "")
|
||||
print
|
||||
}
|
||||
'
|
||||
))
|
||||
for condition in ${dep_conditions}; do
|
||||
echo ' dep_effective_condition: "'${condition}'"'
|
||||
done
|
||||
if ! ${is_container}; then
|
||||
case "${dep_conditions}" in
|
||||
*restricted*) : already restricted -- nothing to inherit ;;
|
||||
*)
|
||||
case "${effective_conditions}" in
|
||||
*restricted*)
|
||||
# "contagious" restricted infects everything linked to restricted
|
||||
echo ' dep_effective_condition: "restricted"'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
echo '}'
|
||||
done >>"${ofile}"
|
Reference in New Issue
Block a user