From cf8a6e48b6fbf50ac2d9092637cd13e0d9473ed9 Mon Sep 17 00:00:00 2001 From: Tristan Van Berkom Date: Wed, 18 Jan 2017 12:12:34 -0500 Subject: buildelement.py: Implement assemble() This class implements the running of commands for all of the subtype plugins which derive it (manual, autotools, cmake, ...) --- buildstream/buildelement.py | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'buildstream/buildelement.py') diff --git a/buildstream/buildelement.py b/buildstream/buildelement.py index 4f3af5ea6..221a3f491 100644 --- a/buildstream/buildelement.py +++ b/buildstream/buildelement.py @@ -22,7 +22,7 @@ implementing the most common case of element. """ -from . import Element +from . import Element, Scope, ElementError _command_steps = ['bootstrap-commands', @@ -56,6 +56,33 @@ class BuildElement(Element): return dictionary + def assemble(self, sandbox): + + # Stage deps in the sandbox root + for dep in self.dependencies(Scope.BUILD): + dep.stage(sandbox) + + # Stage sources in /buildstream/build + self.stage_sources(sandbox, '/buildstream/build') + + # And set the sandbox work directory too + sandbox.set_cwd('/buildstream/build') + + # Run commands + for step in _command_steps: + for prefix in _command_prefixes: + command_name = prefix + step + commands = self.commands[command_name] + for cmd in commands: + with self.timed_activity("Running %s" % command_name): + self.status("Running %s" % command_name, detail=cmd) + exitcode, _, _ = sandbox.run(['/bin/sh', '-c', cmd]) + if exitcode != 0: + raise ElementError("Command '{}' failed with exitcode {}".format(cmd, exitcode)) + + # Return the payload (XXX TODO: expand 'install-root' variable) + return '/buildstream/install' + def _get_commands(self, node, name): list_node = self.node_get_member(node, list, name, default_value=[]) commands = [] -- cgit v1.2.1