2020-03-04 03:21:40

by Masahiro Yamada

[permalink] [raw]
Subject: [PATCH 0/3] kbuild: improve DT build rules


This series is applicable on
Linus' tree + the following two patches:
https://patchwork.kernel.org/patch/11413625/
https://patchwork.kernel.org/patch/11413623/



Masahiro Yamada (3):
kbuild: avoid concurrency issue in parallel building dtbs and
dtbs_check
kbuild: allow to run dt_binding_check and dtbs_check in a single
command
kbuild: allow to run dt_binding_check without kernel configuration

Documentation/devicetree/bindings/Makefile | 8 +++-----
Documentation/devicetree/writing-schema.rst | 4 ++++
Makefile | 16 ++++++++++++----
scripts/dtc/Makefile | 5 +++--
4 files changed, 22 insertions(+), 11 deletions(-)

--
2.17.1


2020-03-04 03:22:08

by Masahiro Yamada

[permalink] [raw]
Subject: [PATCH 3/3] kbuild: allow to run dt_binding_check without kernel configuration

The dt_binding_check target is located outside of the
'ifneq ($(dtstree),) ... endif' block.

Hence, you can run 'make dt_binding_check' on any architecture.
This makes a perfect sense because the dt-schema is arch-agnostic.

The only one problem I see is that scripts/dtc/dtc is not always built.
For example, ARCH=x86 defconfig does not define CONFIG_DTC. Kbuild
descends into scripts/dtc/, but does nothing. Then, it fails to build
*.example.dt.yaml files.

Let's build scripts/dtc/dtc forcibly when running dt_binding_check.

The dt-schema does not depend on any CONFIG option either, so you
should be able to run dt_binding_check without the .config file.

Going forward, you can directly run 'make dt_binding_check' in a
pristine source tree.

Signed-off-by: Masahiro Yamada <[email protected]>
---

Makefile | 2 +-
scripts/dtc/Makefile | 5 +++--
2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index 7dec7b343842..190f595c7bfc 100644
--- a/Makefile
+++ b/Makefile
@@ -255,7 +255,7 @@ clean-targets := %clean mrproper cleandocs
no-dot-config-targets := $(clean-targets) \
cscope gtags TAGS tags help% %docs check% coccicheck \
$(version_h) headers headers_% archheaders archscripts \
- %asm-generic kernelversion %src-pkg
+ %asm-generic kernelversion %src-pkg dt_binding_check
no-sync-config-targets := $(no-dot-config-targets) install %install \
kernelrelease
single-targets := %.a %.i %.ko %.lds %.ll %.lst %.mod %.o %.s %.symtypes %/
diff --git a/scripts/dtc/Makefile b/scripts/dtc/Makefile
index 3acbb410904c..2f3c3a7e1620 100644
--- a/scripts/dtc/Makefile
+++ b/scripts/dtc/Makefile
@@ -1,8 +1,9 @@
# SPDX-License-Identifier: GPL-2.0
# scripts/dtc makefile

-hostprogs := dtc
-always-$(CONFIG_DTC) := $(hostprogs)
+hostprogs := dtc
+always-$(CONFIG_DTC) += $(hostprogs)
+always-$(CHECK_DT_BINDING) += $(hostprogs)

dtc-objs := dtc.o flattree.o fstree.o data.o livetree.o treesource.o \
srcpos.o checks.o util.o
--
2.17.1

2020-03-04 15:27:12

by Rob Herring

[permalink] [raw]
Subject: Re: [PATCH 3/3] kbuild: allow to run dt_binding_check without kernel configuration

On Tue, Mar 3, 2020 at 9:21 PM Masahiro Yamada <[email protected]> wrote:
>
> The dt_binding_check target is located outside of the
> 'ifneq ($(dtstree),) ... endif' block.
>
> Hence, you can run 'make dt_binding_check' on any architecture.
> This makes a perfect sense because the dt-schema is arch-agnostic.
>
> The only one problem I see is that scripts/dtc/dtc is not always built.
> For example, ARCH=x86 defconfig does not define CONFIG_DTC. Kbuild
> descends into scripts/dtc/, but does nothing. Then, it fails to build
> *.example.dt.yaml files.

Yeah, I've just worked around this by doing 'make CONFIG_DTC=y
dt_binding_check'.

The only thing I'd come up with was just always building dtc, but I
didn't want to do that.

> Let's build scripts/dtc/dtc forcibly when running dt_binding_check.
>
> The dt-schema does not depend on any CONFIG option either, so you
> should be able to run dt_binding_check without the .config file.
>
> Going forward, you can directly run 'make dt_binding_check' in a
> pristine source tree.
>
> Signed-off-by: Masahiro Yamada <[email protected]>
> ---
>
> Makefile | 2 +-
> scripts/dtc/Makefile | 5 +++--
> 2 files changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index 7dec7b343842..190f595c7bfc 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -255,7 +255,7 @@ clean-targets := %clean mrproper cleandocs
> no-dot-config-targets := $(clean-targets) \
> cscope gtags TAGS tags help% %docs check% coccicheck \
> $(version_h) headers headers_% archheaders archscripts \
> - %asm-generic kernelversion %src-pkg
> + %asm-generic kernelversion %src-pkg dt_binding_check
> no-sync-config-targets := $(no-dot-config-targets) install %install \
> kernelrelease
> single-targets := %.a %.i %.ko %.lds %.ll %.lst %.mod %.o %.s %.symtypes %/
> diff --git a/scripts/dtc/Makefile b/scripts/dtc/Makefile
> index 3acbb410904c..2f3c3a7e1620 100644
> --- a/scripts/dtc/Makefile
> +++ b/scripts/dtc/Makefile
> @@ -1,8 +1,9 @@
> # SPDX-License-Identifier: GPL-2.0
> # scripts/dtc makefile
>
> -hostprogs := dtc
> -always-$(CONFIG_DTC) := $(hostprogs)
> +hostprogs := dtc
> +always-$(CONFIG_DTC) += $(hostprogs)
> +always-$(CHECK_DT_BINDING) += $(hostprogs)

This looks like a good solution.

Reviewed-by: Rob Herring <[email protected]>