diff options
author | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2012-02-15 12:35:57 +0000 |
---|---|---|
committer | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2012-02-15 12:35:57 +0000 |
commit | 0485577e859e07ae05c81a4214a2a5a37761832f (patch) | |
tree | c5396c5ca2b9265d14c3979cb272ecd9e2fb5d07 /morphlib/builder.py | |
parent | befe6cfd78171e2a10b34163423b08845a23fb43 (diff) | |
download | morph-0485577e859e07ae05c81a4214a2a5a37761832f.tar.gz |
Allow *-commands to override commands provided by build system
This allows us to do this:
"build-system": "autotools",
"configure-commands": [
"./configure --prefix=$PREFIX --disable-nls --enable-foo"
]
The explicit command is used for configure, but the commands provided
by the autotools build-system will be used for build-commands,
test-commands, and install-commands.
Diffstat (limited to 'morphlib/builder.py')
-rw-r--r-- | morphlib/builder.py | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/morphlib/builder.py b/morphlib/builder.py index 1b2afa44..a14fb86e 100644 --- a/morphlib/builder.py +++ b/morphlib/builder.py @@ -223,10 +223,7 @@ class ChunkBuilder(BlobBuilder): self.prepare_build_directory() os.mkdir(self.destdir) - if self.blob.morph.build_system: - self.build_using_buildsystem() - else: - self.build_using_commands() + self.build_with_system_or_commands() self.dump_memory_profile('after building chunk') chunks = self.create_chunks() @@ -322,21 +319,31 @@ class ChunkBuilder(BlobBuilder): extract_treeish(self.blob.morph.treeish, self.builddir) - def build_using_buildsystem(self): + def build_with_system_or_commands(self): + '''Run explicit commands or commands from build system. + + Use explicit commands, if given, and build system commands if one + has been specified. + + ''' + bs_name = self.blob.morph.build_system - self.msg('Building using well-known build system %s' % bs_name) - bs = self.build_system[bs_name] - self.run_sequentially('configure', bs['configure-commands']) - self.run_in_parallel('build', bs['build-commands']) - self.run_sequentially('test', bs['test-commands']) - self.run_sequentially('install', bs['install-commands']) - - def build_using_commands(self): - self.msg('Building using explicit commands') - self.run_sequentially('configure', self.blob.morph.configure_commands) - self.run_in_parallel('build', self.blob.morph.build_commands) - self.run_sequentially('test', self.blob.morph.test_commands) - self.run_sequentially('install', self.blob.morph.install_commands) + if bs_name: + bs = self.build_system[bs_name] + else: + bs = {} + + def run_them(runner, what): + key = '%s-commands' % what + attr = '%s_commands' % what + cmds = bs.get(key, []) + cmds = getattr(self.blob.morph, attr, cmds) + runner(what, cmds) + + run_them(self.run_sequentially, 'configure') + run_them(self.run_in_parallel, 'build') + run_them(self.run_sequentially, 'test') + run_them(self.run_sequentially, 'install') def run_in_parallel(self, what, commands): self.msg('commands: %s' % what) |