summaryrefslogtreecommitdiff
path: root/buildstream/buildelement.py
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-01-18 12:12:34 -0500
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-01-18 12:21:21 -0500
commitcf8a6e48b6fbf50ac2d9092637cd13e0d9473ed9 (patch)
treeb39cc34c985f921905f47b01d80b3812cfcd6f34 /buildstream/buildelement.py
parent014c1bd412b55a1c3fd750ee8000dbb728f433b6 (diff)
downloadbuildstream-cf8a6e48b6fbf50ac2d9092637cd13e0d9473ed9.tar.gz
buildelement.py: Implement assemble()
This class implements the running of commands for all of the subtype plugins which derive it (manual, autotools, cmake, ...)
Diffstat (limited to 'buildstream/buildelement.py')
-rw-r--r--buildstream/buildelement.py29
1 files changed, 28 insertions, 1 deletions
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 = []