|
@@ -54,9 +54,11 @@ class Toolchain:
|
|
|
arch: Architecture of toolchain as determined from the first
|
|
|
component of the filename. E.g. arm-linux-gcc becomes arm
|
|
|
priority: Toolchain priority (0=highest, 20=lowest)
|
|
|
+ override_toolchain: Toolchain to use for sandbox, overriding the normal
|
|
|
+ one
|
|
|
"""
|
|
|
def __init__(self, fname, test, verbose=False, priority=PRIORITY_CALC,
|
|
|
- arch=None):
|
|
|
+ arch=None, override_toolchain=None):
|
|
|
"""Create a new toolchain object.
|
|
|
|
|
|
Args:
|
|
@@ -68,6 +70,7 @@ class Toolchain:
|
|
|
"""
|
|
|
self.gcc = fname
|
|
|
self.path = os.path.dirname(fname)
|
|
|
+ self.override_toolchain = override_toolchain
|
|
|
|
|
|
# Find the CROSS_COMPILE prefix to use for U-Boot. For example,
|
|
|
# 'arm-linux-gnueabihf-gcc' turns into 'arm-linux-gnueabihf-'.
|
|
@@ -81,6 +84,8 @@ class Toolchain:
|
|
|
self.arch = arch
|
|
|
else:
|
|
|
self.arch = self.cross[:pos] if pos != -1 else 'sandbox'
|
|
|
+ if self.arch == 'sandbox' and override_toolchain:
|
|
|
+ self.gcc = override_toolchain
|
|
|
|
|
|
env = self.MakeEnvironment(False)
|
|
|
|
|
@@ -130,8 +135,8 @@ class Toolchain:
|
|
|
def GetWrapper(self, show_warning=True):
|
|
|
"""Get toolchain wrapper from the setting file.
|
|
|
"""
|
|
|
- value = ''
|
|
|
- for name, value in bsettings.GetItems('toolchain-wrapper'):
|
|
|
+ value = ''
|
|
|
+ for name, value in bsettings.GetItems('toolchain-wrapper'):
|
|
|
if not value:
|
|
|
print "Warning: Wrapper not found"
|
|
|
if value:
|
|
@@ -150,11 +155,18 @@ class Toolchain:
|
|
|
Args:
|
|
|
full_path: Return the full path in CROSS_COMPILE and don't set
|
|
|
PATH
|
|
|
+ Returns:
|
|
|
+ Dict containing the environemnt to use. This is based on the current
|
|
|
+ environment, with changes as needed to CROSS_COMPILE, PATH and
|
|
|
+ LC_ALL.
|
|
|
"""
|
|
|
env = dict(os.environ)
|
|
|
wrapper = self.GetWrapper()
|
|
|
|
|
|
- if full_path:
|
|
|
+ if self.override_toolchain:
|
|
|
+ # We'll use MakeArgs() to provide this
|
|
|
+ pass
|
|
|
+ elif full_path:
|
|
|
env['CROSS_COMPILE'] = wrapper + os.path.join(self.path, self.cross)
|
|
|
else:
|
|
|
env['CROSS_COMPILE'] = wrapper + self.cross
|
|
@@ -164,6 +176,22 @@ class Toolchain:
|
|
|
|
|
|
return env
|
|
|
|
|
|
+ def MakeArgs(self):
|
|
|
+ """Create the 'make' arguments for a toolchain
|
|
|
+
|
|
|
+ This is only used when the toolchain is being overridden. Since the
|
|
|
+ U-Boot Makefile sets CC and HOSTCC explicitly we cannot rely on the
|
|
|
+ environment (and MakeEnvironment()) to override these values. This
|
|
|
+ function returns the arguments to accomplish this.
|
|
|
+
|
|
|
+ Returns:
|
|
|
+ List of arguments to pass to 'make'
|
|
|
+ """
|
|
|
+ if self.override_toolchain:
|
|
|
+ return ['HOSTCC=%s' % self.override_toolchain,
|
|
|
+ 'CC=%s' % self.override_toolchain]
|
|
|
+ return []
|
|
|
+
|
|
|
|
|
|
class Toolchains:
|
|
|
"""Manage a list of toolchains for building U-Boot
|
|
@@ -180,10 +208,11 @@ class Toolchains:
|
|
|
paths: List of paths to check for toolchains (may contain wildcards)
|
|
|
"""
|
|
|
|
|
|
- def __init__(self):
|
|
|
+ def __init__(self, override_toolchain=None):
|
|
|
self.toolchains = {}
|
|
|
self.prefixes = {}
|
|
|
self.paths = []
|
|
|
+ self.override_toolchain = override_toolchain
|
|
|
self._make_flags = dict(bsettings.GetItems('make-flags'))
|
|
|
|
|
|
def GetPathList(self, show_warning=True):
|
|
@@ -234,7 +263,8 @@ class Toolchains:
|
|
|
priority: Priority to use for this toolchain
|
|
|
arch: Toolchain architecture, or None if not known
|
|
|
"""
|
|
|
- toolchain = Toolchain(fname, test, verbose, priority, arch)
|
|
|
+ toolchain = Toolchain(fname, test, verbose, priority, arch,
|
|
|
+ self.override_toolchain)
|
|
|
add_it = toolchain.ok
|
|
|
if toolchain.arch in self.toolchains:
|
|
|
add_it = (toolchain.priority <
|