Commit b8a49399 authored by Andrei Ziureaev's avatar Andrei Ziureaev Committed by Rob Herring

dt-bindings: Use json for processed-schema*

Change the format of processed-schema* from yaml to json to speed up
validation. With json output, using xargs and appending the output won't
work since json has explicit list begin and end characters. Instead,
we pass the schema files as a list in a temp file.

The parsing time for the processed schema goes down from ~2sec to 70ms.
Also, 'make dtbs_check' becomes 33% faster.

Some error messages are affected by this change. For example, "True was
expected" becomes "... is not of type 'boolean'". The order of messages
is also changed.
Signed-off-by: default avatarAndrei Ziureaev <andrei.ziureaev@arm.com>
Signed-off-by: default avatarRob Herring <robh@kernel.org>
parent 3e6ae243
# SPDX-License-Identifier: GPL-2.0-only # SPDX-License-Identifier: GPL-2.0-only
*.example.dts *.example.dts
processed-schema*.yaml processed-schema*.yaml
processed-schema*.json
...@@ -19,18 +19,19 @@ $(obj)/%.example.dts: $(src)/%.yaml check_dtschema_version FORCE ...@@ -19,18 +19,19 @@ $(obj)/%.example.dts: $(src)/%.yaml check_dtschema_version FORCE
$(call if_changed,chk_binding) $(call if_changed,chk_binding)
# Use full schemas when checking %.example.dts # Use full schemas when checking %.example.dts
DT_TMP_SCHEMA := $(obj)/processed-schema-examples.yaml DT_TMP_SCHEMA := $(obj)/processed-schema-examples.json
find_cmd = find $(srctree)/$(src) \( -name '*.yaml' ! \ find_cmd = find $(srctree)/$(src) \( -name '*.yaml' ! \
-name 'processed-schema*' ! \ -name 'processed-schema*' ! \
-name '*.example.dt.yaml' \) -name '*.example.dt.yaml' \)
quiet_cmd_mk_schema = SCHEMA $@ quiet_cmd_mk_schema = SCHEMA $@
cmd_mk_schema = rm -f $@ ; \ cmd_mk_schema = f=$$(mktemp) ; \
$(if $(DT_MK_SCHEMA_FLAGS), \ $(if $(DT_MK_SCHEMA_FLAGS), \
echo $(real-prereqs), \ echo $(real-prereqs), \
$(find_cmd)) | \ $(find_cmd)) > $$f ; \
xargs $(DT_MK_SCHEMA) $(DT_MK_SCHEMA_FLAGS) >> $@ $(DT_MK_SCHEMA) -j $(DT_MK_SCHEMA_FLAGS) @$$f > $@ ; \
rm -f $$f
DT_DOCS = $(shell $(find_cmd) | sed -e 's|^$(srctree)/||') DT_DOCS = $(shell $(find_cmd) | sed -e 's|^$(srctree)/||')
...@@ -39,33 +40,33 @@ override DTC_FLAGS := \ ...@@ -39,33 +40,33 @@ override DTC_FLAGS := \
-Wno-graph_child_address \ -Wno-graph_child_address \
-Wno-interrupt_provider -Wno-interrupt_provider
$(obj)/processed-schema-examples.yaml: $(DT_DOCS) check_dtschema_version FORCE $(obj)/processed-schema-examples.json: $(DT_DOCS) check_dtschema_version FORCE
$(call if_changed,mk_schema) $(call if_changed,mk_schema)
ifeq ($(DT_SCHEMA_FILES),) ifeq ($(DT_SCHEMA_FILES),)
# Unless DT_SCHEMA_FILES is specified, use the full schema for dtbs_check too. # Unless DT_SCHEMA_FILES is specified, use the full schema for dtbs_check too.
# Just copy processed-schema-examples.yaml # Just copy processed-schema-examples.json
$(obj)/processed-schema.yaml: $(obj)/processed-schema-examples.yaml FORCE $(obj)/processed-schema.json: $(obj)/processed-schema-examples.json FORCE
$(call if_changed,copy) $(call if_changed,copy)
DT_SCHEMA_FILES = $(DT_DOCS) DT_SCHEMA_FILES = $(DT_DOCS)
else else
# If DT_SCHEMA_FILES is specified, use it for processed-schema.yaml # If DT_SCHEMA_FILES is specified, use it for processed-schema.json
$(obj)/processed-schema.yaml: DT_MK_SCHEMA_FLAGS := -u $(obj)/processed-schema.json: DT_MK_SCHEMA_FLAGS := -u
$(obj)/processed-schema.yaml: $(DT_SCHEMA_FILES) check_dtschema_version FORCE $(obj)/processed-schema.json: $(DT_SCHEMA_FILES) check_dtschema_version FORCE
$(call if_changed,mk_schema) $(call if_changed,mk_schema)
endif endif
extra-$(CHECK_DT_BINDING) += $(patsubst $(src)/%.yaml,%.example.dts, $(DT_SCHEMA_FILES)) 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)) extra-$(CHECK_DT_BINDING) += $(patsubst $(src)/%.yaml,%.example.dt.yaml, $(DT_SCHEMA_FILES))
extra-$(CHECK_DT_BINDING) += processed-schema-examples.yaml extra-$(CHECK_DT_BINDING) += processed-schema-examples.json
extra-$(CHECK_DTBS) += processed-schema.yaml extra-$(CHECK_DTBS) += processed-schema.json
# Hack: avoid 'Argument list too long' error for 'make clean'. Remove most of # Hack: avoid 'Argument list too long' error for 'make clean'. Remove most of
# build artifacts here before they are processed by scripts/Makefile.clean # build artifacts here before they are processed by scripts/Makefile.clean
......
...@@ -328,7 +328,7 @@ $(obj)/%.dtb: $(src)/%.dts $(DTC) FORCE ...@@ -328,7 +328,7 @@ $(obj)/%.dtb: $(src)/%.dts $(DTC) FORCE
DT_CHECKER ?= dt-validate DT_CHECKER ?= dt-validate
DT_BINDING_DIR := Documentation/devicetree/bindings DT_BINDING_DIR := Documentation/devicetree/bindings
# DT_TMP_SCHEMA may be overridden from Documentation/devicetree/bindings/Makefile # DT_TMP_SCHEMA may be overridden from Documentation/devicetree/bindings/Makefile
DT_TMP_SCHEMA ?= $(objtree)/$(DT_BINDING_DIR)/processed-schema.yaml DT_TMP_SCHEMA ?= $(objtree)/$(DT_BINDING_DIR)/processed-schema.json
quiet_cmd_dtb_check = CHECK $@ quiet_cmd_dtb_check = CHECK $@
cmd_dtb_check = $(DT_CHECKER) -u $(srctree)/$(DT_BINDING_DIR) -p $(DT_TMP_SCHEMA) $@ cmd_dtb_check = $(DT_CHECKER) -u $(srctree)/$(DT_BINDING_DIR) -p $(DT_TMP_SCHEMA) $@
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment