]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
buildman: Try to avoid hard-coded string parsing
authorSimon Glass <sjg@chromium.org>
Tue, 2 Dec 2014 00:33:58 +0000 (17:33 -0700)
committerSimon Glass <sjg@chromium.org>
Thu, 15 Jan 2015 05:16:53 +0000 (21:16 -0800)
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

index 27dc31889b8021c64d0af0d9bdf2898253e0b993..e2a851ebd6fb24cd37f368753f9183301953f8a1 100644 (file)
@@ -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'