DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] buildtools: remove assumption about current work dir
@ 2023-06-14 14:47 Bruce Richardson
  2023-06-15 20:24 ` Tyler Retzlaff
  0 siblings, 1 reply; 3+ messages in thread
From: Bruce Richardson @ 2023-06-14 14:47 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson

According to meson documentation, we should not make any assumptions as
to what directory a script is called from[1]. The use of "relpath" when
processing the output of directory globbing is therefore unsafe, as it
was stripping off paths relative to the current directory - which just
happened to be the same as the root directory we were processing.

To improve safety, and support meson clones (like muon)  which
don't always run things from the currently processed path, we need to
explicitly specify that the start parameter for relpath() should be
"root" value.

[1] https://mesonbuild.com/Reference-manual_functions.html#run_command

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 buildtools/list-dir-globs.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/buildtools/list-dir-globs.py b/buildtools/list-dir-globs.py
index d824360d39..fb8619db64 100755
--- a/buildtools/list-dir-globs.py
+++ b/buildtools/list-dir-globs.py
@@ -17,4 +17,4 @@
     if path:
         for p in iglob(os.path.join(root, path)):
             if os.path.isdir(p):
-                print(os.path.relpath(p).replace('\\', '/'))
+                print(os.path.relpath(p, start=root).replace('\\', '/'))
-- 
2.39.2


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

* Re: [PATCH] buildtools: remove assumption about current work dir
  2023-06-14 14:47 [PATCH] buildtools: remove assumption about current work dir Bruce Richardson
@ 2023-06-15 20:24 ` Tyler Retzlaff
  2023-06-27 13:07   ` Thomas Monjalon
  0 siblings, 1 reply; 3+ messages in thread
From: Tyler Retzlaff @ 2023-06-15 20:24 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev

On Wed, Jun 14, 2023 at 03:47:28PM +0100, Bruce Richardson wrote:
> According to meson documentation, we should not make any assumptions as
> to what directory a script is called from[1]. The use of "relpath" when
> processing the output of directory globbing is therefore unsafe, as it
> was stripping off paths relative to the current directory - which just
> happened to be the same as the root directory we were processing.
> 
> To improve safety, and support meson clones (like muon)  which
> don't always run things from the currently processed path, we need to
> explicitly specify that the start parameter for relpath() should be
> "root" value.
> 
> [1] https://mesonbuild.com/Reference-manual_functions.html#run_command
> 
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
Reviewed-by: Tyler Retzlaff <roretzla@linux.microsoft.com>


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

* Re: [PATCH] buildtools: remove assumption about current work dir
  2023-06-15 20:24 ` Tyler Retzlaff
@ 2023-06-27 13:07   ` Thomas Monjalon
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Monjalon @ 2023-06-27 13:07 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev, Tyler Retzlaff

15/06/2023 22:24, Tyler Retzlaff:
> On Wed, Jun 14, 2023 at 03:47:28PM +0100, Bruce Richardson wrote:
> > According to meson documentation, we should not make any assumptions as
> > to what directory a script is called from[1]. The use of "relpath" when
> > processing the output of directory globbing is therefore unsafe, as it
> > was stripping off paths relative to the current directory - which just
> > happened to be the same as the root directory we were processing.
> > 
> > To improve safety, and support meson clones (like muon)  which
> > don't always run things from the currently processed path, we need to
> > explicitly specify that the start parameter for relpath() should be
> > "root" value.
> > 
> > [1] https://mesonbuild.com/Reference-manual_functions.html#run_command
> > 
> > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> > ---
> Reviewed-by: Tyler Retzlaff <roretzla@linux.microsoft.com>

Applied, thanks.



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

end of thread, other threads:[~2023-06-27 13:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-14 14:47 [PATCH] buildtools: remove assumption about current work dir Bruce Richardson
2023-06-15 20:24 ` Tyler Retzlaff
2023-06-27 13:07   ` Thomas Monjalon

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).