Re: [PATCH RFC 01/12] kbuild: create destination directory for _shipped handling

2024-02-27 Thread Masahiro Yamada
On Mon, Feb 26, 2024 at 8:01 PM Dmitry Baryshkov
 wrote:
>
> On Mon, 26 Feb 2024 at 08:33, Masahiro Yamada  wrote:
> >
> > On Mon, Feb 26, 2024 at 11:11 AM Dmitry Baryshkov
> >  wrote:
> > >
> > > The driver might decide to put the _shipped files to the subdir.
> >
> >
> >
> > Please stop this sentence.
> >
> > This sounds like we are not learning.
> >
> > https://lore.kernel.org/all/CAHk-=wgSEi_ZrHdqr=20xv+d6dr5G895CbOAi8ok+7-CQUN=f...@mail.gmail.com/
> >
> >
> >
> >
> > > In such
> > > case the cmd_copy might fail because the destination directory is not
> > > present. Call mkdir -p to make sure that the destination directory is
> > > present.
> >
> >
> > There is no justification for this.
> >
> > If you need a single generated directory
> > (drivers/gpu/drm/msm/registers/, divers/gpu/drm/msm/generated/ or whatever)
> > that should be super simple.
> >
> > Why does scripts/Makefile.lib need the modification?
>
> Could you please tell me how I should handle this?
> I was looking for a way to generate
> drivers/gpu/drm/msm/registers/foo.xml.h and then use it during
> compilation.
> In drivers/gpu/drm/msm/Makefile I added $(obj)/registers/foo.xml.h as
> a dependency to the corresponding object files and then added
> drivers/gpu/drm/msm/registers/foo.xml.h_shipped file.
> This way Kbuild/make will attempt to call cmd_copy to generate target
> file, which thanks to VPATH expansion boils down to `cat
> $(srctree)/$(src)/registers/foo.xml.h_shopped >
> $(obj)/registers/foo.xml.h`. However this breaks as there is no
> $(obj)/registers.
>



One simple solution is to use $(shell mkdir -p ...)
to create the output directory.

scripts/Makefile.build does a similar thing.



You can add the following to drivers/gpu/drm/msm/Makefile.



# Create output directory when CONFIG_DRM_MSM is defined.
# This avoids creating the output directory during 'make clean'
ifdef CONFIG_DRM_MSM
$(shell mkdir -p $(obj)/registers)
endif











-- 
Best Regards
Masahiro Yamada


Re: [PATCH RFC 01/12] kbuild: create destination directory for _shipped handling

2024-02-26 Thread Dmitry Baryshkov
On Mon, 26 Feb 2024 at 08:33, Masahiro Yamada  wrote:
>
> On Mon, Feb 26, 2024 at 11:11 AM Dmitry Baryshkov
>  wrote:
> >
> > The driver might decide to put the _shipped files to the subdir.
>
>
>
> Please stop this sentence.
>
> This sounds like we are not learning.
>
> https://lore.kernel.org/all/CAHk-=wgSEi_ZrHdqr=20xv+d6dr5G895CbOAi8ok+7-CQUN=f...@mail.gmail.com/
>
>
>
>
> > In such
> > case the cmd_copy might fail because the destination directory is not
> > present. Call mkdir -p to make sure that the destination directory is
> > present.
>
>
> There is no justification for this.
>
> If you need a single generated directory
> (drivers/gpu/drm/msm/registers/, divers/gpu/drm/msm/generated/ or whatever)
> that should be super simple.
>
> Why does scripts/Makefile.lib need the modification?

Could you please tell me how I should handle this?
I was looking for a way to generate
drivers/gpu/drm/msm/registers/foo.xml.h and then use it during
compilation.
In drivers/gpu/drm/msm/Makefile I added $(obj)/registers/foo.xml.h as
a dependency to the corresponding object files and then added
drivers/gpu/drm/msm/registers/foo.xml.h_shipped file.
This way Kbuild/make will attempt to call cmd_copy to generate target
file, which thanks to VPATH expansion boils down to `cat
$(srctree)/$(src)/registers/foo.xml.h_shopped >
$(obj)/registers/foo.xml.h`. However this breaks as there is no
$(obj)/registers.


> >
> > Signed-off-by: Dmitry Baryshkov 
> > ---
> >  scripts/Makefile.lib | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> > index cd5b181060f1..94373eeac420 100644
> > --- a/scripts/Makefile.lib
> > +++ b/scripts/Makefile.lib
> > @@ -297,7 +297,7 @@ endef
> >  # the copy would be read-only as well, leading to an error when executing 
> > the
> >  # rule next time. Use 'cat' instead in order to generate a writable file.
> >  quiet_cmd_copy = COPY$@
> > -  cmd_copy = cat $< > $@
> > +  cmd_copy = mkdir -p $(shell dirname $@) && cat $< > $@
> >
> >  $(obj)/%: $(src)/%_shipped
> > $(call cmd,copy)


-- 
With best wishes
Dmitry


Re: [PATCH RFC 01/12] kbuild: create destination directory for _shipped handling

2024-02-25 Thread Masahiro Yamada
On Mon, Feb 26, 2024 at 11:11 AM Dmitry Baryshkov
 wrote:
>
> The driver might decide to put the _shipped files to the subdir.



Please stop this sentence.

This sounds like we are not learning.

https://lore.kernel.org/all/CAHk-=wgSEi_ZrHdqr=20xv+d6dr5G895CbOAi8ok+7-CQUN=f...@mail.gmail.com/




> In such
> case the cmd_copy might fail because the destination directory is not
> present. Call mkdir -p to make sure that the destination directory is
> present.


There is no justification for this.

If you need a single generated directory
(drivers/gpu/drm/msm/registers/, divers/gpu/drm/msm/generated/ or whatever)
that should be super simple.

Why does scripts/Makefile.lib need the modification?









>
> Signed-off-by: Dmitry Baryshkov 
> ---
>  scripts/Makefile.lib | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> index cd5b181060f1..94373eeac420 100644
> --- a/scripts/Makefile.lib
> +++ b/scripts/Makefile.lib
> @@ -297,7 +297,7 @@ endef
>  # the copy would be read-only as well, leading to an error when executing the
>  # rule next time. Use 'cat' instead in order to generate a writable file.
>  quiet_cmd_copy = COPY$@
> -  cmd_copy = cat $< > $@
> +  cmd_copy = mkdir -p $(shell dirname $@) && cat $< > $@
>
>  $(obj)/%: $(src)/%_shipped
> $(call cmd,copy)
>
> --
> 2.39.2
>


--
Best Regards

Masahiro Yamada


[PATCH RFC 01/12] kbuild: create destination directory for _shipped handling

2024-02-25 Thread Dmitry Baryshkov
The driver might decide to put the _shipped files to the subdir. In such
case the cmd_copy might fail because the destination directory is not
present. Call mkdir -p to make sure that the destination directory is
present.

Signed-off-by: Dmitry Baryshkov 
---
 scripts/Makefile.lib | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index cd5b181060f1..94373eeac420 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -297,7 +297,7 @@ endef
 # the copy would be read-only as well, leading to an error when executing the
 # rule next time. Use 'cat' instead in order to generate a writable file.
 quiet_cmd_copy = COPY$@
-  cmd_copy = cat $< > $@
+  cmd_copy = mkdir -p $(shell dirname $@) && cat $< > $@
 
 $(obj)/%: $(src)/%_shipped
$(call cmd,copy)

-- 
2.39.2