diff options
author | Simon Glass <sjg@chromium.org> | 2016-03-12 18:50:32 -0700 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2016-03-17 21:27:39 -0600 |
commit | 17bce66cbfb3610a8e341fdb0766cd5586b0f4e9 (patch) | |
tree | e3294b88678dadf78522bc80d262edff23af1cf0 /tools/buildman/toolchain.py | |
parent | d4c8572b7187cc21ca39d185fd19813e69fbd515 (diff) | |
download | u-boot-17bce66cbfb3610a8e341fdb0766cd5586b0f4e9.tar.gz |
buildman: Add a way to specific a full toolchain prefix
At present buildman allows you to specify the directory containing the
toolchain, but not the actual toolchain prefix. If there are multiple
toolchains in a single directory, this can be inconvenient.
Add a new 'toolchain-prefix' setting to the settings file, which allows
the full prefix (or path to the C compiler) to be specified.
Update the documentation to match.
Suggested-by: Stephen Warren <swarren@wwwdotorg.org>
Reviewed-by: Joe Hershberger <joe.hershberger@ni.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Stephen Warren <swarren@nvidia.com>
Diffstat (limited to 'tools/buildman/toolchain.py')
-rw-r--r-- | tools/buildman/toolchain.py | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/tools/buildman/toolchain.py b/tools/buildman/toolchain.py index 7bcc0af3e9..3993db3a8d 100644 --- a/tools/buildman/toolchain.py +++ b/tools/buildman/toolchain.py @@ -14,7 +14,8 @@ import urllib2 import bsettings import command -PRIORITY_CALC = 0 +(PRIORITY_FULL_PREFIX, PRIORITY_PREFIX_GCC, PRIORITY_PREFIX_GCC_PATH, + PRIORITY_CALC) = range(4) # Simple class to collect links from a page class MyHTMLParser(HTMLParser): @@ -152,11 +153,17 @@ class Toolchains: Public members: toolchains: Dict of Toolchain objects, keyed by architecture name + prefixes: Dict of prefixes to check, keyed by architecture. This can + be a full path and toolchain prefix, for example + {'x86', 'opt/i386-linux/bin/i386-linux-'}, or the name of + something on the search path, for example + {'arm', 'arm-linux-gnueabihf-'}. Wildcards are not supported. paths: List of paths to check for toolchains (may contain wildcards) """ def __init__(self): self.toolchains = {} + self.prefixes = {} self.paths = [] self._make_flags = dict(bsettings.GetItems('make-flags')) @@ -182,6 +189,7 @@ class Toolchains: return paths def GetSettings(self): + self.prefixes = bsettings.GetItems('toolchain-prefix') self.paths += self.GetPathList() def Add(self, fname, test=True, verbose=False, priority=PRIORITY_CALC, @@ -228,6 +236,21 @@ class Toolchains: fnames.append(fname) return fnames + def ScanPathEnv(self, fname): + """Scan the PATH environment variable for a given filename. + + Args: + fname: Filename to scan for + Returns: + List of matching pathanames, or [] if none + """ + pathname_list = [] + for path in os.environ["PATH"].split(os.pathsep): + path = path.strip('"') + pathname = os.path.join(path, fname) + if os.path.exists(pathname): + pathname_list.append(pathname) + return pathname_list def Scan(self, verbose): """Scan for available toolchains and select the best for each arch. @@ -240,6 +263,21 @@ class Toolchains: verbose: True to print out progress information """ if verbose: print 'Scanning for tool chains' + for name, value in self.prefixes: + if verbose: print " - scanning prefix '%s'" % value + if os.path.exists(value): + self.Add(value, True, verbose, PRIORITY_FULL_PREFIX, name) + continue + fname = value + 'gcc' + if os.path.exists(fname): + self.Add(fname, True, verbose, PRIORITY_PREFIX_GCC, name) + continue + fname_list = self.ScanPathEnv(fname) + for f in fname_list: + self.Add(f, True, verbose, PRIORITY_PREFIX_GCC_PATH, name) + if not fname_list: + raise ValueError, ("No tool chain found for prefix '%s'" % + value) for path in self.paths: if verbose: print " - scanning path '%s'" % path fnames = self.ScanPath(path, verbose) |