diff options
author | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2013-02-22 19:07:13 +0000 |
---|---|---|
committer | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2013-03-13 15:20:02 +0000 |
commit | ece7f823de6bd61a0676edf71a9525697848824e (patch) | |
tree | 98c408d5960915f0cb5b98a941e2dc6508047f8b /morphlib/buildenvironment.py | |
parent | 6a61dd9cc1fe8a3ccd2128fb628ed929fd496ad0 (diff) | |
download | morph-ece7f823de6bd61a0676edf71a9525697848824e.tar.gz |
Refactor build process
Reorganise the build_artifact() and build_artifacts() functions to
allow more complex work when setting up chunk builds in
build_artifact().
The staging area now holds the BuildEnvironment object (the
environment variables that should be set during build). This makes sense
because all build commands should be run inside the staging area and
therefore through the StagingArea object.
The BuildEnvironment object is now considered immutable after it is
created. The environment is used in cache key computation when
computing what artifacts are required; if it changes after that point
we risk either computing different artifact keys for the same artifact
or missing data in the cache key that should be included in the hash.
Better to force changes into a separate 'extra_env' variable.
Diffstat (limited to 'morphlib/buildenvironment.py')
-rw-r--r-- | morphlib/buildenvironment.py | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/morphlib/buildenvironment.py b/morphlib/buildenvironment.py index 57270414..fce98da4 100644 --- a/morphlib/buildenvironment.py +++ b/morphlib/buildenvironment.py @@ -21,17 +21,18 @@ import morphlib class BuildEnvironment(): def __init__(self, settings, arch=None): + self.extra_path = [] + self.arch = morphlib.util.arch() if arch is None else arch self.env = self._clean_env(settings) _osenv = os.environ - _default_path = '/sbin:/usr/sbin:/bin:/usr/bin' - _override_term = 'dumb' + _ccache_path = '/usr/lib/ccache' + _override_home = '/tmp' + _override_locale = 'C' _override_shell = '/bin/sh' + _override_term = 'dumb' _override_username = 'tomjon' - _override_locale = 'C' - _override_home = '/tmp' - _ccache_path = '/usr/lib/ccache' def _clean_env(self, settings): '''Create a fresh set of environment variables for a clean build. @@ -40,8 +41,6 @@ class BuildEnvironment(): ''' - path = self._osenv['PATH'] - # copy a set of white-listed variables from the original env copied_vars = dict.fromkeys([ 'DISTCC_HOSTS', @@ -69,14 +68,11 @@ class BuildEnvironment(): env['LC_ALL'] = self._override_locale env['HOME'] = self._override_home - env['PATH'] = self._default_path - - env['TOOLCHAIN_TARGET'] = settings['toolchain-target'] - env['CFLAGS'] = settings['target-cflags'] env['PREFIX'] = settings['prefix'] env['BOOTSTRAP'] = 'false' if not settings['no-ccache']: - env['PATH'] = ('%s:%s' % (self._ccache_path, env['PATH'])) + self.extra_path.append(self._ccache_path) + # FIXME: we should set CCACHE_BASEDIR so any objects that refer to their # current directory get corrected. This improve the cache hit rate # env['CCACHE_BASEDIR'] = self.tempdir.dirname |