Skip to contentSkip to conversation

dt-bindings: Add a minimum version check for dtschema

PATCH Superseded Rob Herring 2 participants 2 messages Apr 17, 2020 Device tree bindings

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Rob Herring

author maintainer
#0 lore raw

PATCH v2 1/1 dt-bindings: Add a minimum version check for dtschema

The dtschema package must be somewhat up to date as the tools and meta-schema checks are still evolving. Implement a version check, so this can be enforced. This will help ensure new schema submissions get checked against the latest meta-schemas.

Cc Masahiro Yamada <[email protected]>

---
v2:
- Use a build rule for the version check instead

 Documentation/devicetree/bindings/Makefile | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/Makefile +11 -3
index 1df680d07461..daf0dda45a78 100644
@@ -3,11 +3,19 @@ DT_DOC_CHECKER ?= dt-doc-validate
 DT_EXTRACT_EX ?= dt-extract-example
 DT_MK_SCHEMA ?= dt-mk-schema
 
+DT_SCHEMA_MIN_VERSION = 2020.04
+
+PHONY += check_dtschema_version
+check_dtschema_version:
+	@printf "%s\n" $(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)"; exit 1) 1>&2
+
 quiet_cmd_chk_binding = CHKDT   $(patsubst $(srctree)/%,%,$<)
       cmd_chk_binding = $(DT_DOC_CHECKER) -u $(srctree)/$(src) $< ; \
                         $(DT_EXTRACT_EX) $< > $@
 
-$(obj)/%.example.dts: $(src)/%.yaml FORCE
+$(obj)/%.example.dts: $(src)/%.yaml check_dtschema_version FORCE
 	$(call if_changed,chk_binding)
 
 # Use full schemas when checking %.example.dts
@@ -34,11 +42,11 @@ override DTC_FLAGS := \
 	-Wno-avoid_unnecessary_addr_size \
 	-Wno-graph_child_address
 
-$(obj)/processed-schema-examples.yaml: $(DT_DOCS) FORCE
+$(obj)/processed-schema-examples.yaml: $(DT_DOCS) check_dtschema_version FORCE
 	$(call if_changed,mk_schema)
 
 $(obj)/processed-schema.yaml: DT_MK_SCHEMA_FLAGS := -u
-$(obj)/processed-schema.yaml: $(DT_SCHEMA_FILES) FORCE
+$(obj)/processed-schema.yaml: $(DT_SCHEMA_FILES) check_dtschema_version FORCE
 	$(call if_changed,mk_schema)
 
 extra-y += processed-schema.yaml
Signature · 1 line
2.20.1
#1 lore raw
Quoted 20 lines · Rob Herring

The dtschema package must be somewhat up to date as the tools and meta-schema checks are still evolving. Implement a version check, so this can be enforced. This will help ensure new schema submissions get checked against the latest meta-schemas.

Cc Masahiro Yamada <[email protected]>

---
v2:
- Use a build rule for the version check instead

 Documentation/devicetree/bindings/Makefile | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
Documentation/devicetree/bindings/Makefile +0 -0
index 1df680d07461..daf0dda45a78 100644

Documentation/devicetree/bindings/Makefile DT_DOC_CHECKER ?= dt-doc-validate · line 6

Quoted 4 lines
Documentation/devicetree/bindings/Makefile +1 -0
@@ -3,11 +3,19 @@ DT_DOC_CHECKER ?= dt-doc-validate
 DT_EXTRACT_EX ?= dt-extract-example
 DT_MK_SCHEMA ?= dt-mk-schema
 
+DT_SCHEMA_MIN_VERSION = 2020.04

Just a nit:

You can use 2020.4 if you want to be consistent with the output from 'dt-doc-validate --version'

This is not a big deal, though.
It is up to you.

$ dt-doc-validate  --version
2020.4

Documentation/devicetree/bindings/Makefile DT_DOC_CHECKER ?= dt-doc-validate · line 13

Quoted 7 lines
Documentation/devicetree/bindings/Makefile +7 -0
+
+PHONY += check_dtschema_version
+check_dtschema_version:
+       @printf "%s\n" $(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)"; exit 1) 1>&2
+

The ( ... ) run the given command in a sub-shell. { ... } does not spawn a sub-shell, so it is a bit more efficient if you do not have a good reason
to run it in a sub-shell.

I prefer 'false' instead of 'exit 1' because we do not need to specify the exit code explicitly. 'false' is used in the top Makefile to stop the build.

I want to place the '1>&2' close to the error message, and you can omit the redundant '1'.

How about this?

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; }

Signature · 2 lines
Best Regards
Masahiro Yamada