Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dt-bindings: Improve validation build error handling

Schema errors can cause make to exit before useful information is
printed. This leaves developers wondering what's wrong. It can be
overcome passing '-k' to make, but that's not an obvious solution.
There's 2 scenarios where this happens.

When using DT_SCHEMA_FILES to validate with a single schema, any error
in the schema results in processed-schema.yaml being empty causing a
make error. The result is the specific errors in the schema are never
shown because processed-schema.yaml is the first target built. Simply
making processed-schema.yaml last in extra-y ensures the full schema
validation with detailed error messages happen first.

The 2nd problem is while schema errors are ignored for
processed-schema.yaml, full validation of the schema still runs in
parallel and any schema validation errors will still stop the build when
running validation of dts files. The fix is to not add the schema
examples to extra-y in this case. This means 'dtbs_check' is no longer a
superset of 'dt_binding_check'. Update the documentation to make this
clear.

Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Tested-by: Jeffrey Hugo <jhugo@codeaurora.org>
Signed-off-by: Rob Herring <robh@kernel.org>

+8 -3
+4 -1
Documentation/devicetree/bindings/Makefile
··· 12 12 $(call if_changed,chk_binding) 13 13 14 14 DT_TMP_SCHEMA := processed-schema.yaml 15 - extra-y += $(DT_TMP_SCHEMA) 16 15 17 16 quiet_cmd_mk_schema = SCHEMA $@ 18 17 cmd_mk_schema = $(DT_MK_SCHEMA) $(DT_MK_SCHEMA_FLAGS) -o $@ $(real-prereqs) ··· 25 26 26 27 DT_SCHEMA_FILES ?= $(addprefix $(src)/,$(DT_DOCS)) 27 28 29 + ifeq ($(CHECK_DTBS),) 28 30 extra-y += $(patsubst $(src)/%.yaml,%.example.dts, $(DT_SCHEMA_FILES)) 29 31 extra-y += $(patsubst $(src)/%.yaml,%.example.dt.yaml, $(DT_SCHEMA_FILES)) 32 + endif 30 33 31 34 $(obj)/$(DT_TMP_SCHEMA): $(DT_SCHEMA_FILES) FORCE 32 35 $(call if_changed,mk_schema) 36 + 37 + extra-y += $(DT_TMP_SCHEMA)
+4 -2
Documentation/devicetree/writing-schema.rst
··· 133 133 134 134 make dt_binding_check 135 135 136 - In order to perform validation of DT source files, use the `dtbs_check` target:: 136 + In order to perform validation of DT source files, use the ``dtbs_check`` target:: 137 137 138 138 make dtbs_check 139 139 140 - This will first run the `dt_binding_check` which generates the processed schema. 140 + Note that ``dtbs_check`` will skip any binding schema files with errors. It is 141 + necessary to use ``dt_binding_check`` to get all the validation errors in the 142 + binding schema files. 141 143 142 144 It is also possible to run checks with a single schema file by setting the 143 145 ``DT_SCHEMA_FILES`` variable to a specific schema file.