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
|
|
|
|
|
2020-10-10 01:05:57 +08:00
|
|
|
DT_SCHEMA_LINT = $(shell which yamllint)
|
|
|
|
|
2020-08-14 03:34:14 +08:00
|
|
|
DT_SCHEMA_MIN_VERSION = 2020.8.1
|
2020-03-06 06:37:48 +08:00
|
|
|
|
|
|
|
PHONY += check_dtschema_version
|
|
|
|
check_dtschema_version:
|
|
|
|
@{ echo $(DT_SCHEMA_MIN_VERSION); \
|
|
|
|
$(DT_DOC_CHECKER) --version 2>/dev/null || echo 0; } | sort -VC || \
|
|
|
|
{ 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
|
|
|
|
2020-02-29 08:37:30 +08:00
|
|
|
# Use full schemas when checking %.example.dts
|
2020-08-13 21:26:11 +08:00
|
|
|
DT_TMP_SCHEMA := $(obj)/processed-schema-examples.json
|
2018-09-07 02:26:07 +08:00
|
|
|
|
2020-04-22 04:42:02 +08:00
|
|
|
find_cmd = find $(srctree)/$(src) \( -name '*.yaml' ! \
|
|
|
|
-name 'processed-schema*' ! \
|
|
|
|
-name '*.example.dt.yaml' \)
|
|
|
|
|
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) | \
|
|
|
|
xargs $(DT_SCHEMA_LINT) -f parsable -c $(srctree)/$(src)/.yamllint) || 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) ; \
|
2020-04-22 04:42:02 +08:00
|
|
|
$(if $(DT_MK_SCHEMA_FLAGS), \
|
|
|
|
echo $(real-prereqs), \
|
2020-08-13 21:26:11 +08:00
|
|
|
$(find_cmd)) > $$f ; \
|
|
|
|
$(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
|
|
|
|
|
2020-04-22 04:42:02 +08:00
|
|
|
DT_DOCS = $(shell $(find_cmd) | sed -e 's|^$(srctree)/||')
|
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 \
|
|
|
|
-Wno-interrupt_provider
|
2020-02-29 08:37:31 +08:00
|
|
|
|
2020-10-10 01:05:57 +08:00
|
|
|
$(obj)/processed-schema-examples.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
|
|
|
|
2020-06-26 01:04:33 +08:00
|
|
|
ifeq ($(DT_SCHEMA_FILES),)
|
|
|
|
|
|
|
|
# Unless DT_SCHEMA_FILES is specified, use the full schema for dtbs_check too.
|
2020-08-13 21:26:11 +08:00
|
|
|
# Just copy processed-schema-examples.json
|
2020-06-26 01:04:33 +08:00
|
|
|
|
2020-08-13 21:26:11 +08:00
|
|
|
$(obj)/processed-schema.json: $(obj)/processed-schema-examples.json FORCE
|
2020-06-26 01:04:33 +08:00
|
|
|
$(call if_changed,copy)
|
|
|
|
|
|
|
|
DT_SCHEMA_FILES = $(DT_DOCS)
|
|
|
|
|
|
|
|
else
|
|
|
|
|
2020-08-13 21:26:11 +08:00
|
|
|
# If DT_SCHEMA_FILES is specified, use it for processed-schema.json
|
2020-06-26 01:04:33 +08:00
|
|
|
|
2020-08-13 21:26:11 +08:00
|
|
|
$(obj)/processed-schema.json: DT_MK_SCHEMA_FLAGS := -u
|
|
|
|
$(obj)/processed-schema.json: $(DT_SCHEMA_FILES) check_dtschema_version FORCE
|
2018-09-07 02:26:07 +08:00
|
|
|
$(call if_changed,mk_schema)
|
2019-11-13 23:46:19 +08:00
|
|
|
|
2020-06-26 01:04:33 +08:00
|
|
|
endif
|
|
|
|
|
2020-08-13 21:26:11 +08:00
|
|
|
extra-$(CHECK_DT_BINDING) += processed-schema-examples.json
|
|
|
|
extra-$(CHECK_DTBS) += processed-schema.json
|
2020-08-07 06:50:09 +08:00
|
|
|
extra-$(CHECK_DT_BINDING) += $(patsubst $(src)/%.yaml,%.example.dts, $(DT_SCHEMA_FILES))
|
|
|
|
extra-$(CHECK_DT_BINDING) += $(patsubst $(src)/%.yaml,%.example.dt.yaml, $(DT_SCHEMA_FILES))
|
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 \
|
|
|
|
-name '*.example.dt.yaml' \) -delete 2>/dev/null)
|