[PATCH 12/23] scripts/nsdeps: use VPATH as src_prefix

Masahiro Yamada posted 23 patches 2 months, 1 week ago
There is a newer version of this series
[PATCH 12/23] scripts/nsdeps: use VPATH as src_prefix
Posted by Masahiro Yamada 2 months, 1 week ago
This change allows it to work not only for in-tree modules but also for
external modules, even if they are built in a separate build directory.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 scripts/nsdeps | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/nsdeps b/scripts/nsdeps
index f1718cc0d700..8b4db63838ce 100644
--- a/scripts/nsdeps
+++ b/scripts/nsdeps
@@ -19,10 +19,10 @@ if ! { echo "$SPATCH_REQ_VERSION"; echo "$SPATCH_VERSION"; } | sort -CV ; then
 	exit 1
 fi
 
-if [ "$KBUILD_EXTMOD" ]; then
+if [ "${VPATH+set}" ]; then
 	src_prefix=
 else
-	src_prefix=$srctree/
+	src_prefix=$VPATH/
 fi
 
 generate_deps_for_ns() {
-- 
2.43.0
Re: [PATCH 12/23] scripts/nsdeps: use VPATH as src_prefix
Posted by Nicolas Schier 2 months ago
On Tue, Sep 17, 2024 at 11:16:40PM +0900, Masahiro Yamada wrote:
> This change allows it to work not only for in-tree modules but also for
> external modules, even if they are built in a separate build directory.
> 
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
> 
>  scripts/nsdeps | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/scripts/nsdeps b/scripts/nsdeps
> index f1718cc0d700..8b4db63838ce 100644
> --- a/scripts/nsdeps
> +++ b/scripts/nsdeps
> @@ -19,10 +19,10 @@ if ! { echo "$SPATCH_REQ_VERSION"; echo "$SPATCH_VERSION"; } | sort -CV ; then
>  	exit 1
>  fi
>  
> -if [ "$KBUILD_EXTMOD" ]; then
> +if [ "${VPATH+set}" ]; then
>  	src_prefix=
>  else
> -	src_prefix=$srctree/
> +	src_prefix=$VPATH/

In kbuild, we expect VPATH to be empty or hold one single directory,
while make itself allows VPATH to be a list of directories.  Might it
make sense to mention this at some place?

Reviewed-by: Nicolas Schier <n.schier@avm.de>

>  fi
>  
>  generate_deps_for_ns() {
> -- 
> 2.43.0
>
Re: [PATCH 12/23] scripts/nsdeps: use VPATH as src_prefix
Posted by Nicolas Schier 2 months ago
On Wed, Sep 25, 2024 at 04:18:56PM +0200, Nicolas Schier wrote:
> On Tue, Sep 17, 2024 at 11:16:40PM +0900, Masahiro Yamada wrote:
> > This change allows it to work not only for in-tree modules but also for
> > external modules, even if they are built in a separate build directory.
> > 
> > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> > ---
> > 
> >  scripts/nsdeps | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/scripts/nsdeps b/scripts/nsdeps
> > index f1718cc0d700..8b4db63838ce 100644
> > --- a/scripts/nsdeps
> > +++ b/scripts/nsdeps
> > @@ -19,10 +19,10 @@ if ! { echo "$SPATCH_REQ_VERSION"; echo "$SPATCH_VERSION"; } | sort -CV ; then
> >  	exit 1
> >  fi
> >  
> > -if [ "$KBUILD_EXTMOD" ]; then
> > +if [ "${VPATH+set}" ]; then
> >  	src_prefix=
> >  else
> > -	src_prefix=$srctree/
> > +	src_prefix=$VPATH/
> 
> In kbuild, we expect VPATH to be empty or hold one single directory,
> while make itself allows VPATH to be a list of directories.  Might it
> make sense to mention this at some place?

I'd like to withdraw that question.  VPATH usage is an implementation
detail and it's probably not helpful to put too much effort into keeping
such things documentated.