summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2019-02-23 15:38:06 +0100
committerJürg Billeter <j@bitron.ch>2019-02-26 13:06:53 +0100
commit2f7cb99dff29060e1e31f24dacb8a0b9a0ba0966 (patch)
tree6e2d398adc9d8ceccc7f5cc2b59690753290dddc
parent2a13069537c6c27cf81160c23c0b9d3ee9b99b88 (diff)
downloadbuildstream-2f7cb99dff29060e1e31f24dacb8a0b9a0ba0966.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 53e528247..365931e27 100644
--- a/buildstream/element.py
+++ b/buildstream/element.py
@@ -673,20 +673,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):