Skip to contentSkip to conversation

buildtools: remove assumption about current work dir

PATCH Applied Bruce Richardson 3 participants 3 messages Jun 14, 2023 – Jun 27, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 buildtools: remove assumption about current work dir

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

---
 buildtools/list-dir-globs.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
buildtools/list-dir-globs.py +1 -1
index d824360d39..fb8619db64 100755
@@ -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('\\', '/'))
Signature · 1 line
2.39.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · 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.

Quoted 4 lines

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

---

#2 lore raw

15/06/2023 22:24, Tyler Retzlaff:

Quoted 12 lines · Bruce Richardson
Quoted 11 lines

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.

Quoted 5 lines
Quoted 4 lines

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

---

Applied, thanks.