Skip to content

Commit 4e0500e

Browse files
committed
Add config to compose for filter-whilst-staging
The configuration allows applying filers based on `include`, `exclude` and `include-orphans` whilst staging dependencies rather than when assembling the artifact. This is useful to avoid overlapping files errors.
1 parent 79ac919 commit 4e0500e

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

src/buildstream/plugins/elements/compose.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,12 @@ class ComposeElement(Element):
5555
BST_FORBID_SOURCES = True
5656

5757
def configure(self, node):
58-
node.validate_keys(["integrate", "include", "exclude", "include-orphans"])
58+
node.validate_keys(["integrate", "filter-whilst-staging", "include", "exclude", "include-orphans"])
5959

6060
# We name this variable 'integration' only to avoid
6161
# collision with the Element.integrate() method.
6262
self.integration = node.get_bool("integrate")
63+
self.filter_whilst_staging = node.get_bool("filter-whilst-staging")
6364
self.include = node.get_str_list("include")
6465
self.exclude = node.get_str_list("exclude")
6566
self.include_orphans = node.get_bool("include-orphans")
@@ -72,7 +73,14 @@ def preflight(self):
7273
pass
7374

7475
def get_unique_key(self):
75-
key = {"integrate": self.integration, "include": sorted(self.include), "orphans": self.include_orphans}
76+
key = {
77+
"integrate": self.integration,
78+
"include": sorted(self.include),
79+
"orphans": self.include_orphans,
80+
}
81+
82+
if self.filter_whilst_staging:
83+
key["filter-whilst-staging"] = self.filter_whilst_staging
7684

7785
if self.exclude:
7886
key["exclude"] = sorted(self.exclude)
@@ -86,12 +94,24 @@ def stage(self, sandbox):
8694

8795
# Stage deps in the sandbox root
8896
with self.timed_activity("Staging dependencies", silent_nested=True):
89-
self.stage_dependency_artifacts(sandbox)
97+
if self.filter_whilst_staging:
98+
self.stage_dependency_artifacts(
99+
sandbox,
100+
include=self.include,
101+
exclude=self.exclude,
102+
orphans=self.include_orphans,
103+
)
104+
else:
105+
self.stage_dependency_artifacts(sandbox)
90106

91107
def assemble(self, sandbox):
92108
manifest = set()
93109

94-
require_split = self.include or self.exclude or not self.include_orphans
110+
require_split = (
111+
not self.filter_whilst_staging
112+
and (self.include or self.exclude or not self.include_orphans)
113+
)
114+
95115
if require_split:
96116
with self.timed_activity("Computing split", silent_nested=True):
97117
for dep in self.dependencies():

src/buildstream/plugins/elements/compose.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ config:
1818
#
1919
integrate: True
2020

21+
22+
# Apply filers based on `include`, `exclude` and `include-orphans` whilst
23+
# staging dependencies rather than when assembling the artifact. This is
24+
# useful to avoid overlapping files errors.
25+
#
26+
filter-whilst-staging: False
27+
2128
# A list of domains to include from each artifact, as
2229
# they were defined in the element's 'split-rules'.
2330
#

0 commit comments

Comments
 (0)