summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Maat <tristan.maat@codethink.co.uk>2018-03-12 13:11:57 +0100
committerTristan Maat <tristan.maat@codethink.co.uk>2018-03-27 14:32:54 +0100
commit18896a9e02e2677910c567de25760dd0432ac43a (patch)
treea88df048956080d168bf38ab8532ff7560116d13
parentdc9a4d39339fbfae77616ce7d30a918afe17d856 (diff)
downloadbuildstream-18896a9e02e2677910c567de25760dd0432ac43a.tar.gz
element.py: Update mtimes of modified dependency files (#216)
-rw-r--r--buildstream/element.py40
1 files changed, 39 insertions, 1 deletions
diff --git a/buildstream/element.py b/buildstream/element.py
index a4248a471..bc3063b6c 100644
--- a/buildstream/element.py
+++ b/buildstream/element.py
@@ -497,13 +497,39 @@ class Element(Plugin):
ignored = {}
overlaps = OrderedDict()
files_written = {}
+ old_dep_keys = {}
+
+ if self._workspaced():
+ workspace = self._get_workspace()
+
+ if workspace.last_successful:
+ old_meta = self._get_artifact_metadata(workspace.last_successful)
+ old_dep_keys = old_meta['keys']['dependencies']
for dep in self.dependencies(scope):
+ # If we are workspaced, and we therefore perform an
+ # incremental build, we must ensure that we update the mtimes
+ # of any files created by our dependencies since the last
+ # successful build.
+ to_update = None
+ if self._workspaced() and old_dep_keys:
+ dep._assert_cached()
+
+ if dep.name in old_dep_keys:
+ key_new = dep._get_cache_key()
+ key_old = old_dep_keys[dep.name]
+
+ # We only need to worry about modified and added
+ # files, since removed files will be picked up by
+ # build systems anyway.
+ to_update, _, added = self.__artifacts.diff(dep, key_old, key_new, subdir='files')
+
result = dep.stage_artifact(sandbox,
path=path,
include=include,
exclude=exclude,
- orphans=orphans)
+ orphans=orphans,
+ update_mtimes=to_update)
if result.overwritten:
for overwrite in result.overwritten:
# Completely new overwrite
@@ -747,6 +773,18 @@ class Element(Plugin):
def _get_workspace(self):
return self._get_project()._workspaces.get_workspace(self)
+ # _get_artifact_metadata():
+ #
+ # Retrieve metadata from the given artifact.
+ #
+ # Args:
+ # key (str): The artifact key.
+ #
+ def _get_artifact_metadata(self, key):
+ base = self.__artifacts.extract(self, key)
+ meta_file = os.path.join(base, 'meta', 'artifact.yaml')
+ return _yaml.load(os.path.join(meta_file))
+
# _write_script():
#
# Writes a script to the given directory.