summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Maat <tristan.maat@codethink.co.uk>2018-03-12 13:09:08 +0100
committerTristan Maat <tristan.maat@codethink.co.uk>2018-03-27 14:32:54 +0100
commit6d5a7217cbc3f88a3355b62025cdf0ba079348b7 (patch)
treee4fc15282069080617b119dcd6ec9de02aa53b17
parentf761140f18a7d54caf6e6dba8a722b9ff1f4430e (diff)
downloadbuildstream-6d5a7217cbc3f88a3355b62025cdf0ba079348b7.tar.gz
Record last successful workspace build key
-rw-r--r--buildstream/_workspaces.py12
-rw-r--r--buildstream/element.py6
2 files changed, 15 insertions, 3 deletions
diff --git a/buildstream/_workspaces.py b/buildstream/_workspaces.py
index 9c3933bbd..36b2c9e74 100644
--- a/buildstream/_workspaces.py
+++ b/buildstream/_workspaces.py
@@ -40,9 +40,11 @@ BST_WORKSPACE_FORMAT_VERSION = 1
# Args:
# path (str): The path that should host this workspace
# project (Project): The project this workspace is part of
+# last_successful (str): The key of the last successful build of this workspace
#
class Workspace():
- def __init__(self, path, project):
+ def __init__(self, path, project, last_successful=None):
+ self.last_successful = last_successful
self.path = path
self._element = None
@@ -52,8 +54,12 @@ class Workspace():
@classmethod
def from_yaml_node(cls, node, project):
path = _yaml.node_get(node, str, 'path')
+ last_successful = _yaml.node_get(node, str, 'last_successful', default_value='')
- return cls(path, project)
+ if last_successful == '':
+ last_successful = None
+
+ return cls(path, project, last_successful)
# _to_dict()
#
@@ -63,7 +69,7 @@ class Workspace():
# (dict) A dict representation of the workspace
#
def _to_dict(self):
- to_return = ['path']
+ to_return = ['path', 'last_successful']
return {key: val for key, val in self.__dict__.items()
if key in to_return and val is not None}
diff --git a/buildstream/element.py b/buildstream/element.py
index b36ae965c..7bcb71860 100644
--- a/buildstream/element.py
+++ b/buildstream/element.py
@@ -834,6 +834,12 @@ class Element(Plugin):
self._update_state()
+ if self._workspaced():
+ key = self._get_cache_key()
+ workspace = self._get_workspace()
+ workspace.last_successful = key
+ self._get_project()._workspaces.save_config()
+
# _cached():
#
# Returns: