diff options
author | Raoul Hidalgo Charman <raoul.hidalgocharman@codethink.co.uk> | 2019-01-23 15:59:04 +0000 |
---|---|---|
committer | Jürg Billeter <j@bitron.ch> | 2019-02-19 17:05:17 +0000 |
commit | c7f76268cc6f35209587749df85f3af9cfbaabf1 (patch) | |
tree | 5743ab0d84c47ba28fb5659acd266fadca7d82fd /buildstream | |
parent | 52c0c185d964bf696e320be97663c412e020b427 (diff) | |
download | buildstream-c7f76268cc6f35209587749df85f3af9cfbaabf1.tar.gz |
cachedir: add new dir option that's default root to other dirs
Makes artifactdir and builddir obsolete.
Fixes #870
Diffstat (limited to 'buildstream')
-rw-r--r-- | buildstream/_context.py | 33 | ||||
-rw-r--r-- | buildstream/data/userconfig.yaml | 7 | ||||
-rw-r--r-- | buildstream/plugintestutils/runcli.py | 24 |
3 files changed, 47 insertions, 17 deletions
diff --git a/buildstream/_context.py b/buildstream/_context.py index 2fbf415fb..cb537cf60 100644 --- a/buildstream/_context.py +++ b/buildstream/_context.py @@ -58,12 +58,21 @@ class Context(): # Filename indicating which configuration file was used, or None for the defaults self.config_origin = None + # The directory under which other directories are based + self.cachedir = None + # The directory where various sources are stored self.sourcedir = None # The directory where build sandboxes will be created self.builddir = None + # The directory for CAS + self.casdir = None + + # The directory for temporary files + self.tmpdir = None + # Default root location for workspaces self.workspacedir = None @@ -179,13 +188,24 @@ class Context(): user_config = _yaml.load(config) _yaml.composite(defaults, user_config) + # Give obsoletion warnings + if defaults.get('builddir'): + raise LoadError(LoadErrorReason.INVALID_DATA, + "builddir is obsolete, use cachedir") + + if defaults.get('artifactdir'): + print("artifactdir is deprecated, use cachedir") + else: + defaults['artifactdir'] = os.path.join(defaults['cachedir'], 'artifacts') + _yaml.node_validate(defaults, [ - 'sourcedir', 'builddir', 'artifactdir', 'logdir', + 'cachedir', 'sourcedir', 'builddir', 'artifactdir', 'logdir', 'scheduler', 'artifacts', 'logging', 'projects', - 'cache', 'prompt', 'workspacedir', 'remote-execution' + 'cache', 'prompt', 'workspacedir', 'remote-execution', ]) - for directory in ['sourcedir', 'builddir', 'artifactdir', 'logdir', 'workspacedir']: + for directory in ['cachedir', 'sourcedir', 'artifactdir', 'logdir', + 'workspacedir']: # Allow the ~ tilde expansion and any environment variables in # path specification in the config files. # @@ -195,6 +215,11 @@ class Context(): path = os.path.normpath(path) setattr(self, directory, path) + # add directories not set by users + self.tmpdir = os.path.join(self.cachedir, 'tmp') + self.casdir = os.path.join(self.cachedir, 'cas') + self.builddir = os.path.join(self.cachedir, 'build') + # Load quota configuration # We need to find the first existing directory in the path of # our artifactdir - the artifactdir may not have been created @@ -640,7 +665,7 @@ class Context(): def get_cascache(self): if self._cascache is None: - self._cascache = CASCache(self.artifactdir) + self._cascache = CASCache(self.cachedir) return self._cascache diff --git a/buildstream/data/userconfig.yaml b/buildstream/data/userconfig.yaml index f17dac88c..d27e56ef2 100644 --- a/buildstream/data/userconfig.yaml +++ b/buildstream/data/userconfig.yaml @@ -13,11 +13,8 @@ # Location to store sources sourcedir: ${XDG_CACHE_HOME}/buildstream/sources -# Location to perform builds -builddir: ${XDG_CACHE_HOME}/buildstream/build - -# Location to store local binary artifacts -artifactdir: ${XDG_CACHE_HOME}/buildstream/artifacts +# Root location for other directories in the cache +cachedir: ${XDG_CACHE_HOME}/buildstream # Location to store build logs logdir: ${XDG_CACHE_HOME}/buildstream/logs diff --git a/buildstream/plugintestutils/runcli.py b/buildstream/plugintestutils/runcli.py index fb7c23c6c..83fdff721 100644 --- a/buildstream/plugintestutils/runcli.py +++ b/buildstream/plugintestutils/runcli.py @@ -277,10 +277,10 @@ class Cli(): *, cache_dir=None): # Read configuration to figure out where artifacts are stored if not cache_dir: - default = os.path.join(project, 'cache', 'artifacts') + default = os.path.join(project, 'cache') if self.config is not None: - cache_dir = self.config.get('artifactdir', default) + cache_dir = self.config.get('cachedir', default) else: cache_dir = default @@ -582,11 +582,21 @@ def cli_integration(tmpdir, integration_cache): # We want to cache sources for integration tests more permanently, # to avoid downloading the huge base-sdk repeatedly fixture.configure({ + 'cachedir': integration_cache.cachedir, 'sourcedir': integration_cache.sources, - 'artifactdir': integration_cache.artifacts }) - return fixture + yield fixture + + # remove following folders if necessary + try: + shutil.rmtree(os.path.join(integration_cache.cachedir, 'build')) + except FileNotFoundError: + pass + try: + shutil.rmtree(os.path.join(integration_cache.cachedir, 'tmp')) + except FileNotFoundError: + pass @contextmanager @@ -626,10 +636,8 @@ def configured(directory, config=None): if not config.get('sourcedir', False): config['sourcedir'] = os.path.join(directory, 'sources') - if not config.get('builddir', False): - config['builddir'] = os.path.join(directory, 'build') - if not config.get('artifactdir', False): - config['artifactdir'] = os.path.join(directory, 'artifacts') + if not config.get('cachedir', False): + config['cachedir'] = directory if not config.get('logdir', False): config['logdir'] = os.path.join(directory, 'logs') |