Tom Rini | 53633a8 | 2024-02-29 12:33:36 -0500 | [diff] [blame] | 1 | # SPDX-License-Identifier: GPL-2.0 |
| 2 | DT_DOC_CHECKER ?= dt-doc-validate |
| 3 | DT_EXTRACT_EX ?= dt-extract-example |
| 4 | DT_MK_SCHEMA ?= dt-mk-schema |
| 5 | |
| 6 | DT_SCHEMA_LINT = $(shell which yamllint || \ |
| 7 | echo "warning: python package 'yamllint' not installed, skipping" >&2) |
| 8 | |
| 9 | DT_SCHEMA_MIN_VERSION = 2023.9 |
| 10 | |
| 11 | PHONY += check_dtschema_version |
| 12 | check_dtschema_version: |
| 13 | @which $(DT_DOC_CHECKER) >/dev/null || \ |
| 14 | { echo "Error: '$(DT_DOC_CHECKER)' not found!" >&2; \ |
| 15 | echo "Ensure dtschema python package is installed and in your PATH." >&2; \ |
| 16 | echo "Current PATH is:" >&2; \ |
| 17 | echo "$$PATH" >&2; false; } |
| 18 | @{ echo $(DT_SCHEMA_MIN_VERSION); \ |
| 19 | $(DT_DOC_CHECKER) --version 2>/dev/null || echo 0; } | sort -Vc >/dev/null || \ |
| 20 | { echo "ERROR: dtschema minimum version is v$(DT_SCHEMA_MIN_VERSION)" >&2; false; } |
| 21 | |
| 22 | quiet_cmd_extract_ex = DTEX $@ |
| 23 | cmd_extract_ex = $(DT_EXTRACT_EX) $< > $@ |
| 24 | |
| 25 | $(obj)/%.example.dts: $(src)/%.yaml check_dtschema_version FORCE |
| 26 | $(call if_changed,extract_ex) |
| 27 | |
| 28 | find_all_cmd = find $(srctree)/$(src) \( -name '*.yaml' ! \ |
| 29 | -name 'processed-schema*' \) |
| 30 | |
Tom Rini | 668ad57 | 2024-04-01 09:08:13 -0400 | [diff] [blame^] | 31 | find_cmd = $(find_all_cmd) | \ |
| 32 | sed 's|^$(srctree)/||' | \ |
| 33 | grep -F -e "$(subst :," -e ",$(DT_SCHEMA_FILES))" | \ |
| 34 | sed 's|^|$(srctree)/|' |
Tom Rini | 53633a8 | 2024-02-29 12:33:36 -0500 | [diff] [blame] | 35 | CHK_DT_DOCS := $(shell $(find_cmd)) |
| 36 | |
| 37 | quiet_cmd_yamllint = LINT $(src) |
| 38 | cmd_yamllint = ($(find_cmd) | \ |
| 39 | xargs -n200 -P$$(nproc) \ |
| 40 | $(DT_SCHEMA_LINT) -f parsable -c $(srctree)/$(src)/.yamllint >&2) || true |
| 41 | |
| 42 | quiet_cmd_chk_bindings = CHKDT $@ |
| 43 | cmd_chk_bindings = ($(find_cmd) | \ |
| 44 | xargs -n200 -P$$(nproc) $(DT_DOC_CHECKER) -u $(srctree)/$(src)) || true |
| 45 | |
| 46 | quiet_cmd_mk_schema = SCHEMA $@ |
| 47 | cmd_mk_schema = f=$$(mktemp) ; \ |
| 48 | $(find_all_cmd) > $$f ; \ |
| 49 | $(DT_MK_SCHEMA) -j $(DT_MK_SCHEMA_FLAGS) @$$f > $@ ; \ |
| 50 | rm -f $$f |
| 51 | |
| 52 | define rule_chkdt |
Sumit Garg | e02230c | 2024-02-22 15:05:58 +0530 | [diff] [blame] | 53 | $(if $(DT_SCHEMA_LINT),$(call echo-cmd,yamllint) $(cmd_yamllint),); \ |
| 54 | $(call echo-cmd,chk_bindings) $(cmd_chk_bindings); \ |
| 55 | $(call echo-cmd,mk_schema) $(cmd_mk_schema) |
Tom Rini | 53633a8 | 2024-02-29 12:33:36 -0500 | [diff] [blame] | 56 | endef |
| 57 | |
| 58 | DT_DOCS = $(patsubst $(srctree)/%,%,$(shell $(find_all_cmd))) |
| 59 | |
| 60 | override DTC_FLAGS := \ |
| 61 | -Wno-avoid_unnecessary_addr_size \ |
| 62 | -Wno-graph_child_address \ |
| 63 | -Wno-interrupt_provider \ |
| 64 | -Wno-unique_unit_address \ |
| 65 | -Wunique_unit_address_if_enabled |
| 66 | |
| 67 | # Disable undocumented compatible checks until warning free |
| 68 | override DT_CHECKER_FLAGS ?= |
| 69 | |
| 70 | $(obj)/processed-schema.json: $(DT_DOCS) $(src)/.yamllint check_dtschema_version FORCE |
| 71 | $(call if_changed_rule,chkdt) |
| 72 | |
| 73 | always-y += processed-schema.json |
| 74 | always-$(CHECK_DT_BINDING) += $(patsubst $(srctree)/$(src)/%.yaml,%.example.dts, $(CHK_DT_DOCS)) |
| 75 | always-$(CHECK_DT_BINDING) += $(patsubst $(srctree)/$(src)/%.yaml,%.example.dtb, $(CHK_DT_DOCS)) |
| 76 | |
| 77 | # Hack: avoid 'Argument list too long' error for 'make clean'. Remove most of |
| 78 | # build artifacts here before they are processed by scripts/Makefile.clean |
| 79 | clean-files = $(shell find $(obj) \( -name '*.example.dts' -o \ |
| 80 | -name '*.example.dtb' \) -delete 2>/dev/null) |
| 81 | |
| 82 | dt_compatible_check: $(obj)/processed-schema.json |
| 83 | $(Q)$(srctree)/scripts/dtc/dt-extract-compatibles $(srctree) | xargs dt-check-compatible -v -s $< |