devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] dt-bindings: kbuild: Support partial matches with DT_SCHEMA_FILES
@ 2022-02-28 20:10 Rob Herring
  2022-03-03  8:51 ` Krzysztof Kozlowski
  0 siblings, 1 reply; 2+ messages in thread
From: Rob Herring @ 2022-02-28 20:10 UTC (permalink / raw)
  To: Krzysztof Kozlowski; +Cc: Masahiro Yamada, devicetree, linux-kernel

DT_SCHEMA_FILES is currently restricted to a list of exact files with
the full source tree path (i.e. Documentation/devicetree/bindings/...).
Loosen this requirement and let DT_SCHEMA_FILES be a partial match.

With this, checking all schema files in a directory is possible:

$ make DT_SCHEMA_FILES=/gpio/ dt_binding_check

Or all schema files with 'qcom' in the path or filename:

$ make DT_SCHEMA_FILES=qcom dt_binding_check

Cc: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Rob Herring <robh@kernel.org>
---
 Documentation/devicetree/bindings/Makefile        | 15 +++++----------
 .../devicetree/bindings/writing-schema.rst        |  9 +++++----
 2 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/Documentation/devicetree/bindings/Makefile b/Documentation/devicetree/bindings/Makefile
index 41c555181b6f..5138d10e0601 100644
--- a/Documentation/devicetree/bindings/Makefile
+++ b/Documentation/devicetree/bindings/Makefile
@@ -31,11 +31,8 @@ find_all_cmd = find $(srctree)/$(src) \( -name '*.yaml' ! \
 		-name 'processed-schema*' ! \
 		-name '*.example.dt.yaml' \)
 
-ifeq ($(DT_SCHEMA_FILES),)
-find_cmd = $(find_all_cmd)
-else
-find_cmd = echo $(addprefix $(srctree)/, $(DT_SCHEMA_FILES))
-endif
+find_cmd = $(find_all_cmd) | grep -F "$(DT_SCHEMA_FILES)"
+CHK_DT_DOCS := $(shell $(find_cmd))
 
 quiet_cmd_yamllint = LINT    $(src)
       cmd_yamllint = ($(find_cmd) | \
@@ -83,22 +80,20 @@ ifeq ($(DT_SCHEMA_FILES),)
 $(obj)/processed-schema.json: $(obj)/processed-schema-examples.json FORCE
 	$(call if_changed,copy)
 
-DT_SCHEMA_FILES = $(DT_DOCS)
-
 else
 
 # If DT_SCHEMA_FILES is specified, use it for processed-schema.json
 
 $(obj)/processed-schema.json: DT_MK_SCHEMA_FLAGS := -u
-$(obj)/processed-schema.json: $(DT_SCHEMA_FILES) check_dtschema_version FORCE
+$(obj)/processed-schema.json: $(CHK_DT_DOCS) check_dtschema_version FORCE
 	$(call if_changed,mk_schema)
 
 endif
 
 always-$(CHECK_DT_BINDING) += processed-schema-examples.json
 always-$(CHECK_DTBS)       += processed-schema.json
-always-$(CHECK_DT_BINDING) += $(patsubst $(src)/%.yaml,%.example.dts, $(DT_SCHEMA_FILES))
-always-$(CHECK_DT_BINDING) += $(patsubst $(src)/%.yaml,%.example.dt.yaml, $(DT_SCHEMA_FILES))
+always-$(CHECK_DT_BINDING) += $(patsubst $(srctree)/$(src)/%.yaml,%.example.dts, $(CHK_DT_DOCS))
+always-$(CHECK_DT_BINDING) += $(patsubst $(srctree)/$(src)/%.yaml,%.example.dt.yaml, $(CHK_DT_DOCS))
 
 # Hack: avoid 'Argument list too long' error for 'make clean'. Remove most of
 # build artifacts here before they are processed by scripts/Makefile.clean
diff --git a/Documentation/devicetree/bindings/writing-schema.rst b/Documentation/devicetree/bindings/writing-schema.rst
index 4004dd9209a6..3b00fe981494 100644
--- a/Documentation/devicetree/bindings/writing-schema.rst
+++ b/Documentation/devicetree/bindings/writing-schema.rst
@@ -157,13 +157,14 @@ It is possible to run both in a single command::
 
     make dt_binding_check dtbs_check
 
-It is also possible to run checks with a single schema file by setting the
-``DT_SCHEMA_FILES`` variable to a specific schema file.
+It is also possible to run checks with a subset of matching schema files by
+setting the ``DT_SCHEMA_FILES`` variable to a specific schema file or pattern.
 
 ::
 
-    make dt_binding_check DT_SCHEMA_FILES=Documentation/devicetree/bindings/trivial-devices.yaml
-    make dtbs_check DT_SCHEMA_FILES=Documentation/devicetree/bindings/trivial-devices.yaml
+    make dt_binding_check DT_SCHEMA_FILES=trivial-devices.yaml
+    make dt_binding_check DT_SCHEMA_FILES=/gpio/
+    make dtbs_check DT_SCHEMA_FILES=trivial-devices.yaml
 
 
 json-schema Resources
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] dt-bindings: kbuild: Support partial matches with DT_SCHEMA_FILES
  2022-02-28 20:10 [PATCH] dt-bindings: kbuild: Support partial matches with DT_SCHEMA_FILES Rob Herring
@ 2022-03-03  8:51 ` Krzysztof Kozlowski
  0 siblings, 0 replies; 2+ messages in thread
From: Krzysztof Kozlowski @ 2022-03-03  8:51 UTC (permalink / raw)
  To: Rob Herring; +Cc: Masahiro Yamada, devicetree, linux-kernel

On 28/02/2022 21:10, Rob Herring wrote:
> DT_SCHEMA_FILES is currently restricted to a list of exact files with
> the full source tree path (i.e. Documentation/devicetree/bindings/...).
> Loosen this requirement and let DT_SCHEMA_FILES be a partial match.
> 
> With this, checking all schema files in a directory is possible:
> 
> $ make DT_SCHEMA_FILES=/gpio/ dt_binding_check
> 
> Or all schema files with 'qcom' in the path or filename:
> 
> $ make DT_SCHEMA_FILES=qcom dt_binding_check
> 
> Cc: Masahiro Yamada <masahiroy@kernel.org>
> Signed-off-by: Rob Herring <robh@kernel.org>
> ---
>  Documentation/devicetree/bindings/Makefile        | 15 +++++----------
>  .../devicetree/bindings/writing-schema.rst        |  9 +++++----
>  2 files changed, 10 insertions(+), 14 deletions(-)
> 


Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>


Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-03-03  8:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-28 20:10 [PATCH] dt-bindings: kbuild: Support partial matches with DT_SCHEMA_FILES Rob Herring
2022-03-03  8:51 ` Krzysztof Kozlowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).