in src/buildstream/plugins/elements/compose.py [0:0]
def assemble(self, sandbox):
manifest = set()
require_split = self.include or self.exclude or not self.include_orphans
if require_split:
with self.timed_activity("Computing split", silent_nested=True):
for dep in self.dependencies():
files = dep.compute_manifest(
include=self.include, exclude=self.exclude, orphans=self.include_orphans
)
manifest.update(files)
# Make a snapshot of all the files.
vbasedir = sandbox.get_virtual_directory()
removed_files = set()
added_files = set()
# Run any integration commands provided by the dependencies
# once they are all staged and ready
if self.integration:
with self.timed_activity("Integrating sandbox"):
if require_split:
# Make a snapshot of all the files before integration-commands are run.
snapshot = set(vbasedir.list_relative_paths())
with sandbox.batch():
for dep in self.dependencies():
dep.integrate(sandbox)
if require_split:
# Calculate added and removed files
post_integration_snapshot = vbasedir.list_relative_paths()
basedir_contents = set(post_integration_snapshot)
for path in manifest:
if path in snapshot and path not in basedir_contents:
removed_files.add(path)
for path in basedir_contents:
if path not in snapshot:
added_files.add(path)
self.info("Integration added {} and removed {} files".format(len(added_files), len(removed_files)))
# The remainder of this is expensive, make an early exit if
# we're not being selective about what is to be included.
if not require_split:
return "/"
# Update the manifest with files which were added/removed by integration commands
#
manifest.update(added_files)
manifest.difference_update(removed_files)
# XXX We should be moving things outside of the build sandbox
# instead of into a subdir. The element assemble() method should
# support this in some way.
#
installdir = vbasedir.open_directory("buildstream/install", create=True)
# We already saved the manifest for created files in the integration phase,
# now collect the rest of the manifest.
#
lines = []
if self.include:
lines.append("Including files from domains: " + ", ".join(self.include))
else:
lines.append("Including files from all domains")
if self.exclude:
lines.append("Excluding files from domains: " + ", ".join(self.exclude))
if self.include_orphans:
lines.append("Including orphaned files")
else:
lines.append("Excluding orphaned files")
detail = "\n".join(lines)
def import_filter(path):
return path in manifest
with self.timed_activity("Creating composition", detail=detail, silent_nested=True):
self.info("Composing {} files".format(len(manifest)))
installdir.import_files(vbasedir, filter_callback=import_filter, collect_result=False)
# And we're done
return os.path.join(os.sep, "buildstream", "install")