2018-09-07 02:26:07 +08:00
|
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
DT_DOC_CHECKER ?= dt-doc-validate
|
|
|
|
DT_EXTRACT_EX ?= dt-extract-example
|
|
|
|
DT_MK_SCHEMA ?= dt-mk-schema
|
|
|
|
|
2022-03-16 04:25:43 +08:00
|
|
|
DT_SCHEMA_LINT = $(shell which yamllint || \
|
2022-03-04 01:45:14 +08:00
|
|
|
echo "warning: python package 'yamllint' not installed, skipping" >&2)
|
2020-10-10 01:05:57 +08:00
|
|
|
|
2022-03-11 00:05:12 +08:00
|
|
|
DT_SCHEMA_MIN_VERSION = 2022.3
|
2020-03-06 06:37:48 +08:00
|
|
|
|
|
|
|
PHONY += check_dtschema_version
|
|
|
|
check_dtschema_version:
|
2021-10-26 23:11:17 +08:00
|
|
|
@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; }
|
2020-03-06 06:37:48 +08:00
|
|
|
@{ echo $(DT_SCHEMA_MIN_VERSION); \
|
2021-02-02 00:58:28 +08:00
|
|
|
$(DT_DOC_CHECKER) --version 2>/dev/null || echo 0; } | sort -Vc >/dev/null || \
|
2020-03-06 06:37:48 +08:00
|
|
|
{ echo "ERROR: dtschema minimum version is v$(DT_SCHEMA_MIN_VERSION)" >&2; false; }
|
|
|
|
|
2020-08-07 06:50:09 +08:00
|
|
|
quiet_cmd_extract_ex = DTEX $@
|
|
|
|
cmd_extract_ex = $(DT_EXTRACT_EX) $< > $@
|
2018-09-07 02:26:07 +08:00
|
|
|
|
2020-03-06 06:37:48 +08:00
|
|
|
$(obj)/%.example.dts: $(src)/%.yaml check_dtschema_version FORCE
|
2020-08-07 06:50:09 +08:00
|
|
|
$(call if_changed,extract_ex)
|
2018-09-07 02:26:07 +08:00
|
|
|
|
2021-10-18 18:54:48 +08:00
|
|
|
find_all_cmd = find $(srctree)/$(src) \( -name '*.yaml' ! \
|
2022-03-11 00:05:13 +08:00
|
|
|
-name 'processed-schema*' \)
|
2020-04-22 04:42:02 +08:00
|
|
|
|
2023-02-10 03:37:35 +08:00
|
|
|
find_cmd = $(find_all_cmd) | grep -F -e "$(subst :," -e ",$(DT_SCHEMA_FILES))"
|
2022-03-01 04:10:05 +08:00
|
|
|
CHK_DT_DOCS := $(shell $(find_cmd))
|
2021-10-18 18:54:48 +08:00
|
|
|
|
2020-10-10 01:05:57 +08:00
|
|
|
quiet_cmd_yamllint = LINT $(src)
|
2020-11-21 05:37:44 +08:00
|
|
|
cmd_yamllint = ($(find_cmd) | \
|
2021-10-18 18:54:48 +08:00
|
|
|
xargs -n200 -P$$(nproc) \
|
|
|
|
$(DT_SCHEMA_LINT) -f parsable -c $(srctree)/$(src)/.yamllint >&2) || true
|
2020-10-10 01:05:57 +08:00
|
|
|
|
2020-08-07 06:50:09 +08:00
|
|
|
quiet_cmd_chk_bindings = CHKDT $@
|
2020-11-21 05:37:44 +08:00
|
|
|
cmd_chk_bindings = ($(find_cmd) | \
|
|
|
|
xargs -n200 -P$$(nproc) $(DT_DOC_CHECKER) -u $(srctree)/$(src)) || true
|
2020-08-07 06:50:09 +08:00
|
|
|
|
2018-09-07 02:26:07 +08:00
|
|
|
quiet_cmd_mk_schema = SCHEMA $@
|
2020-08-13 21:26:11 +08:00
|
|
|
cmd_mk_schema = f=$$(mktemp) ; \
|
2022-07-28 05:10:59 +08:00
|
|
|
$(find_all_cmd) > $$f ; \
|
2020-08-13 21:26:11 +08:00
|
|
|
$(DT_MK_SCHEMA) -j $(DT_MK_SCHEMA_FLAGS) @$$f > $@ ; \
|
|
|
|
rm -f $$f
|
2018-09-07 02:26:07 +08:00
|
|
|
|
2020-08-07 06:50:09 +08:00
|
|
|
define rule_chkdt
|
2020-10-10 01:05:57 +08:00
|
|
|
$(if $(DT_SCHEMA_LINT),$(call cmd,yamllint),)
|
2020-08-07 06:50:09 +08:00
|
|
|
$(call cmd,chk_bindings)
|
|
|
|
$(call cmd,mk_schema)
|
|
|
|
endef
|
|
|
|
|
2021-10-18 18:54:48 +08:00
|
|
|
DT_DOCS = $(patsubst $(srctree)/%,%,$(shell $(find_all_cmd)))
|
2019-01-22 23:10:10 +08:00
|
|
|
|
2020-02-29 08:37:31 +08:00
|
|
|
override DTC_FLAGS := \
|
|
|
|
-Wno-avoid_unnecessary_addr_size \
|
2020-06-30 02:15:13 +08:00
|
|
|
-Wno-graph_child_address \
|
2021-12-04 02:35:17 +08:00
|
|
|
-Wno-interrupt_provider \
|
|
|
|
-Wno-unique_unit_address \
|
|
|
|
-Wunique_unit_address_if_enabled
|
2020-02-29 08:37:31 +08:00
|
|
|
|
2021-03-12 07:36:40 +08:00
|
|
|
# Disable undocumented compatible checks until warning free
|
|
|
|
override DT_CHECKER_FLAGS ?=
|
|
|
|
|
2022-03-11 00:05:12 +08:00
|
|
|
$(obj)/processed-schema.json: $(DT_DOCS) $(src)/.yamllint check_dtschema_version FORCE
|
2020-08-07 06:50:09 +08:00
|
|
|
$(call if_changed_rule,chkdt)
|
2018-09-07 02:26:07 +08:00
|
|
|
|
2022-03-11 00:05:12 +08:00
|
|
|
always-y += processed-schema.json
|
2022-03-01 04:10:05 +08:00
|
|
|
always-$(CHECK_DT_BINDING) += $(patsubst $(srctree)/$(src)/%.yaml,%.example.dts, $(CHK_DT_DOCS))
|
2022-03-11 00:05:13 +08:00
|
|
|
always-$(CHECK_DT_BINDING) += $(patsubst $(srctree)/$(src)/%.yaml,%.example.dtb, $(CHK_DT_DOCS))
|
2020-06-26 01:04:31 +08:00
|
|
|
|
|
|
|
# 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 \
|
2022-03-11 00:05:13 +08:00
|
|
|
-name '*.example.dtb' \) -delete 2>/dev/null)
|
2022-07-01 05:37:22 +08:00
|
|
|
|
|
|
|
dt_compatible_check: $(obj)/processed-schema.json
|
|
|
|
$(Q)$(srctree)/scripts/dtc/dt-extract-compatibles $(srctree) | xargs dt-check-compatible -v -s $<
|