summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2019-02-23 15:38:06 +0100
committerAbderrahim Kitouni <akitouni@gnome.org>2020-08-26 12:47:05 +0100
commitf913a061e97ed8ad64382813e02f24aa1942773f (patch)
treed025e08b04f603ca684f38293f6041439b97f1b5
parent259428e47a9bf570915b5d2065e2f62048e7437d (diff)
downloadbuildstream-f913a061e97ed8ad64382813e02f24aa1942773f.tar.gz
element.py: Replace file lists with filter callbacks in stage_artifact()
-rw-r--r--buildstream/element.py25
1 files changed, 17 insertions, 8 deletions
diff --git a/buildstream/element.py b/buildstream/element.py
index 7d2ae2453..1ec066669 100644
--- a/buildstream/element.py
+++ b/buildstream/element.py
@@ -675,20 +675,29 @@ class Element(Plugin):
if path is None \
else vbasedir.descend(path.lstrip(os.sep).split(os.sep))
- files = list(self.__compute_splits(include, exclude, orphans))
+ split_filter = self.__split_filter_func(include, exclude, orphans)
# We must not hardlink files whose mtimes we want to update
if update_mtimes:
- link_files = [f for f in files if f not in update_mtimes]
- copy_files = [f for f in files if f in update_mtimes]
+ def link_filter(path):
+ return ((split_filter is None or split_filter(path)) and
+ path not in update_mtimes)
+
+ def copy_filter(path):
+ return ((split_filter is None or split_filter(path)) and
+ path in update_mtimes)
else:
- link_files = files
- copy_files = []
+ link_filter = split_filter
+
+ result = vstagedir.import_files(artifact, filter_callback=link_filter,
+ report_written=True, can_link=True)
- link_result = vstagedir.import_files(artifact, files=link_files, report_written=True, can_link=True)
- copy_result = vstagedir.import_files(artifact, files=copy_files, report_written=True, update_mtime=True)
+ if update_mtimes:
+ copy_result = vstagedir.import_files(artifact, filter_callback=copy_filter,
+ report_written=True, update_mtime=True)
+ result = result.combine(copy_result)
- return link_result.combine(copy_result)
+ return result
def stage_dependency_artifacts(self, sandbox, scope, *, path=None,
include=None, exclude=None, orphans=True):