Re: [PATCH v2 2/2] binman: Use less hard coded magic when inserting new PATH

2021-12-02 Thread Simon Glass
Hi Andy,

On Tue, 30 Nov 2021 at 12:04, Andy Shevchenko
 wrote:
>
> Instead of joining hard coded '..' to the run-time path of the executable,
> take just a dirname out of it. Besides that, use $(srctree) where it makes
> sense.
>
> Signed-off-by: Andy Shevchenko 
> ---
> v2: new patch
>  tools/binman/main.py | 12 +++-
>  1 file changed, 7 insertions(+), 5 deletions(-)

Looks good, apart from my comment on the previous patch, which applies here too.

Regards,
Simon


[PATCH v2 2/2] binman: Use less hard coded magic when inserting new PATH

2021-11-30 Thread Andy Shevchenko
Instead of joining hard coded '..' to the run-time path of the executable,
take just a dirname out of it. Besides that, use $(srctree) where it makes
sense.

Signed-off-by: Andy Shevchenko 
---
v2: new patch
 tools/binman/main.py | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/tools/binman/main.py b/tools/binman/main.py
index 4d8b124c7468..2b3e58d1aabd 100755
--- a/tools/binman/main.py
+++ b/tools/binman/main.py
@@ -19,24 +19,26 @@ import unittest
 # Get the absolute path to this file at run-time
 our_path = os.path.dirname(sys.argv[0])
 
+# Extract $(srctree)  from Kbuild environment
+srctree = os.environ['srctree']
+
 #
 # Do not pollute source tree with cache files:
 # https://stackoverflow.com/a/60024195/2511795
 # https://bugs.python.org/issue33499
 #
-sys.pycache_prefix = os.path.relpath(our_path, os.environ['srctree'])
+sys.pycache_prefix = os.path.relpath(our_path, srctree)
 
 # Bring in the patman and dtoc libraries (but don't override the first path
 # in PYTHONPATH)
-sys.path.insert(2, os.path.join(our_path, '..'))
+sys.path.insert(2, os.path.dirname(our_path))
 
 from patman import test_util
 
 # Bring in the libfdt module
 sys.path.insert(2, 'scripts/dtc/pylibfdt')
-sys.path.insert(2, os.path.join(our_path, '../../scripts/dtc/pylibfdt'))
-sys.path.insert(2, os.path.join(our_path,
-'../../build-sandbox_spl/scripts/dtc/pylibfdt'))
+sys.path.insert(2, os.path.join(srctree, 'scripts/dtc/pylibfdt'))
+sys.path.insert(2, os.path.join(srctree, 
'build-sandbox_spl/scripts/dtc/pylibfdt'))
 
 # When running under python-coverage on Ubuntu 16.04, the dist-packages
 # directories are dropped from the python path. Add them in so that we can find
-- 
2.33.0