public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	u-boot@lists.denx.de
Cc: Simon Glass <sjg@chromium.org>, Tom Rini <trini@konsulko.com>
Subject: [PATCH v3 2/2] binman: Use less hard coded magic when inserting new PATH
Date: Mon,  6 Dec 2021 14:44:13 +0300	[thread overview]
Message-ID: <20211206114413.71047-2-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20211206114413.71047-1-andriy.shevchenko@linux.intel.com>

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 <andriy.shevchenko@linux.intel.com>
---
v3: avoided crash (Simon), reused one level up folder variable
 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 d19ded491af7..6f5ee4e21db7 100755
--- a/tools/binman/main.py
+++ b/tools/binman/main.py
@@ -21,24 +21,26 @@ our_path = os.path.dirname(os.path.realpath(__file__))
 our1_path = os.path.dirname(our_path)
 our2_path = os.path.dirname(our1_path)
 
+# Extract $(srctree) from Kbuild environment, or use relative paths below
+srctree = os.environ.get('srctree', our2_path)
+
 #
 # 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.get('srctree', our2_path))
+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, our1_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


  reply	other threads:[~2021-12-06 11:44 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-06 11:44 [PATCH v3 1/2] binman: Do not pollute source tree when build with `make O=...` Andy Shevchenko
2021-12-06 11:44 ` Andy Shevchenko [this message]
2021-12-15  0:33   ` [PATCH v3 2/2] binman: Use less hard coded magic when inserting new PATH Simon Glass
2021-12-15  0:33 ` [PATCH v3 1/2] binman: Do not pollute source tree when build with `make O=...` Simon Glass
2021-12-23  5:07   ` Simon Glass
2021-12-23  9:06     ` Andy Shevchenko
2021-12-28  8:34       ` Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211206114413.71047-2-andriy.shevchenko@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox