diff options
author | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2013-03-13 16:24:59 +0000 |
---|---|---|
committer | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2013-03-15 11:04:55 +0000 |
commit | f1cdf64cd5fa4271403286271ead511989ce15a1 (patch) | |
tree | 4b02dc53e10770da9aca05fb6e166bf020a55e26 /morphlib/buildenvironment.py | |
parent | 89c0777fa1c8918f8402b64484b16b6c715c441b (diff) | |
download | morph-f1cdf64cd5fa4271403286271ead511989ce15a1.tar.gz |
One 'arch' to rule them all
Define a specific set of 4 architectures that Morph supports, and only
expose that value to morphologies.
Since GNU triplets are very common we also expose a GNU triplet. Other
morphologies should work out their configuration based on MORPH_ARCH.
This commit also removes the morphlib.util.arch() function, which
detected the machine Morph is running on via 'uname -m'. Morph's
architecture names do not necessarily map to the output of 'uname -m'
so we should not rely on it anywhere.
Diffstat (limited to 'morphlib/buildenvironment.py')
-rw-r--r-- | morphlib/buildenvironment.py | 50 |
1 files changed, 33 insertions, 17 deletions
diff --git a/morphlib/buildenvironment.py b/morphlib/buildenvironment.py index e6dccb04..68e7e756 100644 --- a/morphlib/buildenvironment.py +++ b/morphlib/buildenvironment.py @@ -32,13 +32,14 @@ class BuildEnvironment(): ''' - def __init__(self, settings, target, arch=None): + def __init__(self, settings, arch): '''Create a new BuildEnvironment object''' self.extra_path = [] - self.target = target - self.arch = morphlib.util.arch() if arch is None else arch + self.env = self._clean_env(settings) + self.env.update(self._env_for_arch(arch)) + _osenv = os.environ _ccache_path = '/usr/lib/ccache' @@ -48,15 +49,6 @@ class BuildEnvironment(): _override_term = 'dumb' _override_username = 'tomjon' - def get_bootstrap_target(self, target): - '''Set 'vendor' field of the given machine triplet as 'bootstrap' ''' - - parts = target.split('-') - if len(parts) < 2: - raise morphlib.Error('Failed to parse machine triplet returned by ' - 'host compiler: %s' % target) - return '-'.join([parts[0], 'bootstrap'] + parts[2:]) - def _clean_env(self, settings): '''Create a fresh set of environment variables for a clean build. @@ -91,11 +83,6 @@ class BuildEnvironment(): env['LC_ALL'] = self._override_locale env['HOME'] = self._override_home - env['BUILD'] = self.target - env['TARGET'] = self.target - env['TARGET_STAGE1'] = self.get_bootstrap_target(self.target) - env['TARGET_GCC_CONFIG'] = '' - if not settings['no-ccache']: self.extra_path.append(self._ccache_path) # FIXME: we should set CCACHE_BASEDIR so any objects that refer to their @@ -111,3 +98,32 @@ class BuildEnvironment(): env['CCACHE_PREFIX'] = 'distcc' return env + + def _env_for_arch(self, arch): + '''Set build environment variables specific to the target machine + + These are entirely controlled by the 'arch' field in the system + morphology, which is passed to the morphologies as MORPH_ARCH to + do what they like with. + + ''' + + env = {} + env['MORPH_ARCH'] = arch + + # GNU triplets are widely used, so we handle these in Morph rather + # than leaving it up to individual morphologies. + if arch == 'x86_32': + cpu = 'i686' + else: + cpu = arch + + if arch.startswith('arm'): + abi = 'eabi' + else: + abi = '' + + env['TARGET'] = cpu + '-baserock-linux-gnu' + abi + env['TARGET_STAGE1'] = cpu + '-bootstrap-linux-gnu' + abi + + return env |