diff options
Diffstat (limited to 'Documentation/devicetree/bindings/Makefile')
-rw-r--r-- | Documentation/devicetree/bindings/Makefile | 93 |
1 files changed, 71 insertions, 22 deletions
diff --git a/Documentation/devicetree/bindings/Makefile b/Documentation/devicetree/bindings/Makefile index 646cb3525373..8390d6c00030 100644 --- a/Documentation/devicetree/bindings/Makefile +++ b/Documentation/devicetree/bindings/Makefile @@ -2,35 +2,84 @@ DT_DOC_CHECKER ?= dt-doc-validate DT_EXTRACT_EX ?= dt-extract-example DT_MK_SCHEMA ?= dt-mk-schema -DT_MK_SCHEMA_FLAGS := $(if $(DT_SCHEMA_FILES), -u) -quiet_cmd_chk_binding = CHKDT $(patsubst $(srctree)/%,%,$<) - cmd_chk_binding = $(DT_DOC_CHECKER) -u $(srctree)/$(src) $< ; \ - $(DT_EXTRACT_EX) $< > $@ +DT_SCHEMA_LINT = $(shell which yamllint || \ + echo "warning: python package 'yamllint' not installed, skipping" >&2) -$(obj)/%.example.dts: $(src)/%.yaml FORCE - $(call if_changed,chk_binding) +DT_SCHEMA_MIN_VERSION = 2023.9 -DT_TMP_SCHEMA := processed-schema.yaml +PHONY += check_dtschema_version +check_dtschema_version: + @which $(DT_DOC_CHECKER) >/dev/null || \ + { echo "Error: '$(DT_DOC_CHECKER)' not found!" >&2; \ + echo "Ensure dtschema python package is installed and in your PATH." >&2; \ + echo "Current PATH is:" >&2; \ + echo "$$PATH" >&2; false; } + @{ echo $(DT_SCHEMA_MIN_VERSION); \ + $(DT_DOC_CHECKER) --version 2>/dev/null || echo 0; } | sort -Vc >/dev/null || \ + { echo "ERROR: dtschema minimum version is v$(DT_SCHEMA_MIN_VERSION)" >&2; false; } -quiet_cmd_mk_schema = SCHEMA $@ - cmd_mk_schema = $(DT_MK_SCHEMA) $(DT_MK_SCHEMA_FLAGS) -o $@ $(real-prereqs) +quiet_cmd_extract_ex = DTEX $@ + cmd_extract_ex = $(DT_EXTRACT_EX) $< > $@ + +$(obj)/%.example.dts: $(src)/%.yaml check_dtschema_version FORCE + $(call if_changed,extract_ex) + +find_all_cmd = find $(src) \( -name '*.yaml' ! \ + -name 'processed-schema*' \) + +find_cmd = $(find_all_cmd) | \ + sed 's|^$(srctree)/||' | \ + grep -F -e "$(subst :," -e ",$(DT_SCHEMA_FILES))" | \ + sed 's|^|$(srctree)/|' +CHK_DT_EXAMPLES := $(patsubst $(srctree)/%.yaml,%.example.dtb, $(shell $(find_cmd))) + +quiet_cmd_yamllint = LINT $(src) + cmd_yamllint = ($(find_cmd) | \ + xargs -n200 -P$$(nproc) \ + $(DT_SCHEMA_LINT) -f parsable -c $(src)/.yamllint >&2) \ + && touch $@ || true + +quiet_cmd_chk_bindings = CHKDT $(src) + cmd_chk_bindings = ($(find_cmd) | \ + xargs -n200 -P$$(nproc) $(DT_DOC_CHECKER) -u $(src)) \ + && touch $@ || true -DT_DOCS = $(shell \ - cd $(srctree)/$(src) && \ - find * \( -name '*.yaml' ! \ - -name $(DT_TMP_SCHEMA) ! \ - -name '*.example.dt.yaml' \) \ - ) +quiet_cmd_mk_schema = SCHEMA $@ + cmd_mk_schema = f=$$(mktemp) ; \ + $(find_all_cmd) > $$f ; \ + $(DT_MK_SCHEMA) -j $(DT_MK_SCHEMA_FLAGS) @$$f > $@ ; \ + rm -f $$f -DT_SCHEMA_FILES ?= $(addprefix $(src)/,$(DT_DOCS)) +DT_DOCS = $(patsubst $(srctree)/%,%,$(shell $(find_all_cmd))) -ifeq ($(CHECK_DTBS),) -extra-y += $(patsubst $(src)/%.yaml,%.example.dts, $(DT_SCHEMA_FILES)) -extra-y += $(patsubst $(src)/%.yaml,%.example.dt.yaml, $(DT_SCHEMA_FILES)) -endif +override DTC_FLAGS := \ + -Wno-avoid_unnecessary_addr_size \ + -Wno-graph_child_address \ + -Wno-unique_unit_address \ + -Wunique_unit_address_if_enabled -$(obj)/$(DT_TMP_SCHEMA): $(DT_SCHEMA_FILES) FORCE +$(obj)/processed-schema.json: $(DT_DOCS) check_dtschema_version FORCE $(call if_changed,mk_schema) -extra-y += $(DT_TMP_SCHEMA) +targets += .dt-binding.checked .yamllint.checked +$(obj)/.yamllint.checked: $(DT_DOCS) $(src)/.yamllint FORCE + $(if $(DT_SCHEMA_LINT),$(call if_changed,yamllint),) + +$(obj)/.dt-binding.checked: $(DT_DOCS) FORCE + $(call if_changed,chk_bindings) + +always-y += processed-schema.json +targets += $(patsubst $(obj)/%,%, $(CHK_DT_EXAMPLES)) +targets += $(patsubst $(obj)/%.dtb,%.dts, $(CHK_DT_EXAMPLES)) + +# Hack: avoid 'Argument list too long' error for 'make clean'. Remove most of +# build artifacts here before they are processed by scripts/Makefile.clean +clean-files = $(shell find $(obj) \( -name '*.example.dts' -o \ + -name '*.example.dtb' \) -delete 2>/dev/null) + +dt_compatible_check: $(obj)/processed-schema.json + $(Q)$(srctree)/scripts/dtc/dt-extract-compatibles $(srctree) | xargs dt-check-compatible -v -s $< + +PHONY += dt_binding_check +dt_binding_check: $(obj)/.dt-binding.checked $(obj)/.yamllint.checked $(CHK_DT_EXAMPLES) |