From 9e35ea90a1f2c41c3808633e76930f86da6336e5 Mon Sep 17 00:00:00 2001 From: Adam Coldrick Date: Fri, 8 Aug 2014 07:59:02 +0000 Subject: 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. --- morphlib/builder2.py | 2 +- morphlib/cachekeycomputer.py | 2 +- morphlib/morphloader.py | 11 +++++++++++ morphlib/plugins/cross-bootstrap_plugin.py | 2 +- 4 files changed, 14 insertions(+), 3 deletions(-) (limited to 'morphlib') 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..d06c06dc 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,13 @@ 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': + for key in self._static_defaults['chunk']: + if 'commands' not in key: continue + if key not 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: -- cgit v1.2.1