diff options
author | Adam Coldrick <adam.coldrick@codethink.co.uk> | 2014-08-08 07:59:02 +0000 |
---|---|---|
committer | Adam Coldrick <adam.coldrick@codethink.co.uk> | 2014-08-14 07:43:49 +0000 |
commit | 0f6374de1a2476e5c58d610ff2f0f5a346b47b27 (patch) | |
tree | d2655b9256fbb98cbace2b8ccde3fd00adc21a93 | |
parent | 045b86c9de4ad37067a5882e9c14ece43eb0c834 (diff) | |
download | morph-0f6374de1a2476e5c58d610ff2f0f5a346b47b27.tar.gz |
morphloader: Get commands when loading morphology
Rather than having a `get_commands` method to obtain missing commands
from the build system when they are needed, get the commands when
loading a morphology.
-rw-r--r-- | morphlib/builder2.py | 2 | ||||
-rw-r--r-- | morphlib/cachekeycomputer.py | 2 | ||||
-rw-r--r-- | morphlib/morphloader.py | 13 | ||||
-rw-r--r-- | morphlib/plugins/cross-bootstrap_plugin.py | 2 |
4 files changed, 16 insertions, 3 deletions
diff --git a/morphlib/builder2.py b/morphlib/builder2.py index d739dc13..c1a49221 100644 --- a/morphlib/builder2.py +++ b/morphlib/builder2.py @@ -405,7 +405,7 @@ class ChunkBuilder(BuilderBase): for step, in_parallel in steps: with self.build_watch(step): key = '%s-commands' % step - cmds = m.get_commands(key) + cmds = m[key] if cmds: with open(logfilepath, 'a') as log: self.app.status(msg='Running %(key)s', key=key) diff --git a/morphlib/cachekeycomputer.py b/morphlib/cachekeycomputer.py index b124b789..7cbce730 100644 --- a/morphlib/cachekeycomputer.py +++ b/morphlib/cachekeycomputer.py @@ -114,7 +114,7 @@ class CacheKeyComputer(object): for prefix in ('pre-', '', 'post-'): for cmdtype in ('configure', 'build', 'test', 'install'): cmd_field = prefix + cmdtype + '-commands' - keys[cmd_field] = morphology.get_commands(cmd_field) + keys[cmd_field] = morphology[cmd_field] keys['devices'] = morphology.get('devices') keys['max-jobs'] = morphology.get('max-jobs') keys['system-integration'] = morphology.get('system-integration', diff --git a/morphlib/morphloader.py b/morphlib/morphloader.py index 0249bbae..10f331b5 100644 --- a/morphlib/morphloader.py +++ b/morphlib/morphloader.py @@ -406,6 +406,7 @@ class MorphologyLoader(object): m = self.parse_morphology_text(string, filename) m.filename = filename self.validate(m) + self.set_commands(m) self.set_defaults(m) return m @@ -754,3 +755,15 @@ class MorphologyLoader(object): if morph['max-jobs'] is not None: morph['max-jobs'] = int(morph['max-jobs']) + def set_commands(self, morph): + if morph['kind'] == 'chunk': + steps = [key for key, value in + self._static_defaults['chunk'].iteritems() + if 'commands' in key] + for key in steps: + if not key in morph: + attr = '_'.join(key.split('-')) + default = self._static_defaults['chunk']['build-system'] + bs = morphlib.buildsystem.lookup_build_system( + morph.get('build-system', default)) + morph[key] = getattr(bs, attr) diff --git a/morphlib/plugins/cross-bootstrap_plugin.py b/morphlib/plugins/cross-bootstrap_plugin.py index cd8e355e..0c3e3a4a 100644 --- a/morphlib/plugins/cross-bootstrap_plugin.py +++ b/morphlib/plugins/cross-bootstrap_plugin.py @@ -182,7 +182,7 @@ class BootstrapSystemBuilder(morphlib.builder2.BuilderBase): for step, in_parallel in steps: key = '%s-commands' % step - cmds = m.get_commands(key) + cmds = m[key] for cmd in cmds: f.write('(') if in_parallel: |