diff mbox

[U-Boot,08/17] buildman: Try to avoid hard-coded string parsing

Message ID 1417480447-5763-9-git-send-email-sjg@chromium.org
State Accepted
Delegated to: Simon Glass
Headers show

Commit Message

Simon Glass Dec. 2, 2014, 12:33 a.m. UTC
The assumption that the compiler name will always end in gcc is incorrect
for clang and apparently on BSD.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 tools/buildman/toolchain.py | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/tools/buildman/toolchain.py b/tools/buildman/toolchain.py
index 27dc318..e2a851e 100644
--- a/tools/buildman/toolchain.py
+++ b/tools/buildman/toolchain.py
@@ -30,7 +30,14 @@  class Toolchain:
         """
         self.gcc = fname
         self.path = os.path.dirname(fname)
-        self.cross = os.path.basename(fname)[:-3]
+
+        # Find the CROSS_COMPILE prefix to use for U-Boot. For example,
+        # 'arm-linux-gnueabihf-gcc' turns into 'arm-linux-gnueabihf-'.
+        basename = os.path.basename(fname)
+        pos = basename.rfind('-')
+        self.cross = basename[:pos + 1] if pos != -1 else ''
+
+        # The architecture is the first part of the name
         pos = self.cross.find('-')
         self.arch = self.cross[:pos] if pos != -1 else 'sandbox'