mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-08-09 06:14:34 +02:00
Run dt-check-style as part of dt_binding_check_one. The recipe wraps the tool with scripts/jobserver-exec so worker count follows the GNU make jobserver -- `make -j N dt_binding_check` constrains the checker to N workers rather than spawning one per CPU. Default mode (relaxed) is zero-violation on the current tree, so this does not introduce new warnings into make dt_binding_check. Stricter rules are available via --mode=strict (eg. for use by checkpatch.pl in a future series). Signed-off-by: Daniel Golle <daniel@makrotopia.org> Link: https://patch.msgid.link/a14fdbded0acdc4fef1c1278100f2f4c6a93a488.1779908995.git.daniel@makrotopia.org Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
104 lines
3.8 KiB
Makefile
104 lines
3.8 KiB
Makefile
# SPDX-License-Identifier: GPL-2.0
|
|
DT_DOC_CHECKER ?= dt-doc-validate
|
|
DT_EXTRACT_EX ?= dt-extract-example
|
|
DT_MK_SCHEMA ?= dt-mk-schema
|
|
|
|
DT_SCHEMA_LINT = $(shell which yamllint || \
|
|
echo "warning: python package 'yamllint' not installed, skipping" >&2)
|
|
|
|
DT_SCHEMA_MIN_VERSION = 2023.9
|
|
|
|
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_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) | xargs grep -l '^examples:'))
|
|
|
|
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_CHK_STYLE = $(srctree)/scripts/dtc/dt-check-style
|
|
|
|
# Feed the file list to the checker via @argfile in a single Python
|
|
# process so the ruamel.yaml import is paid once. scripts/jobserver-exec
|
|
# claims slots from the GNU make jobserver and exposes the count via
|
|
# $PARALLELISM, which dt-check-style picks up to size its worker pool.
|
|
quiet_cmd_chk_style = STYLE $(src)
|
|
cmd_chk_style = f=$$(mktemp) && $(find_cmd) > $$f && \
|
|
$(PYTHON3) $(srctree)/scripts/jobserver-exec \
|
|
$(PYTHON3) $(DT_CHK_STYLE) @$$f \
|
|
&& touch $@ || true; rm -f $$f
|
|
|
|
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_DOCS = $(patsubst $(srctree)/%,%,$(shell $(find_all_cmd)))
|
|
|
|
override DTC_FLAGS := \
|
|
-Wno-avoid_unnecessary_addr_size \
|
|
-Wno-unique_unit_address \
|
|
-Wunique_unit_address_if_enabled
|
|
|
|
$(obj)/processed-schema.json: $(DT_DOCS) check_dtschema_version FORCE
|
|
$(call if_changed,mk_schema)
|
|
|
|
targets += .dt-binding.checked .yamllint.checked .dt-style.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)
|
|
|
|
$(obj)/.dt-style.checked: $(DT_DOCS) FORCE
|
|
$(call if_changed,chk_style)
|
|
|
|
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_one
|
|
dt_binding_check_one: $(obj)/.dt-binding.checked $(obj)/.yamllint.checked $(obj)/.dt-style.checked
|
|
|
|
PHONY += dt_binding_check
|
|
dt_binding_check: dt_binding_check_one $(CHK_DT_EXAMPLES)
|