summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Maat <tristan.maat@codethink.co.uk>2017-10-20 15:07:01 +0100
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-12-13 12:36:41 -0500
commitcce60d724f24ed8f07794515f272fce3b2b6f6f0 (patch)
tree74609644177ccc828f60f8c270d2e59168cadab0
parent34b43a9f5bfa49c5b19f1a237c7c384e05f57cf8 (diff)
downloadbuildstream-cce60d724f24ed8f07794515f272fce3b2b6f6f0.tar.gz
Issue #113: Split tracking and saving in `bst build`
-rw-r--r--buildstream/_frontend/main.py11
-rw-r--r--buildstream/_pipeline.py9
-rw-r--r--buildstream/_scheduler/trackqueue.py17
3 files changed, 24 insertions, 13 deletions
diff --git a/buildstream/_frontend/main.py b/buildstream/_frontend/main.py
index 7e1b0cc18..15fcf4b34 100644
--- a/buildstream/_frontend/main.py
+++ b/buildstream/_frontend/main.py
@@ -195,16 +195,21 @@ def cli(context, **kwargs):
help="Build elements that would not be needed for the current build plan")
@click.option('--track', default=False, is_flag=True,
help="Track new source references before building (implies --all)")
+@click.option('--track-save', default=False, is_flag=True,
+ help="Track new source references before building, updating their "
+ "corresponding element files")
@click.argument('elements', nargs=-1,
type=click.Path(dir_okay=False, readable=True))
@click.pass_obj
-def build(app, elements, all, track):
+def build(app, elements, all, track, track_save):
"""Build elements in a pipeline"""
- app.initialize(elements, rewritable=track, inconsistent=track, use_remote_cache=True)
+ track_first = track or track_save
+
+ app.initialize(elements, rewritable=track_save, inconsistent=track_first, use_remote_cache=True)
app.print_heading()
try:
- app.pipeline.build(app.scheduler, all, track)
+ app.pipeline.build(app.scheduler, all, track_first, track_save)
click.echo("")
app.print_summary()
except PipelineError:
diff --git a/buildstream/_pipeline.py b/buildstream/_pipeline.py
index c6bdeaebc..ec374df71 100644
--- a/buildstream/_pipeline.py
+++ b/buildstream/_pipeline.py
@@ -382,9 +382,12 @@ class Pipeline():
# scheduler (Scheduler): The scheduler to run this pipeline on
# build_all (bool): Whether to build all elements, or only those
# which are required to build the target.
- # track_first (bool): Track sources before fetching and building (implies build_all)
+ # track_first (list): Elements whose sources to track prior to
+ # building
+ # save (bool): Whether to save the tracking results in the
+ # elements
#
- def build(self, scheduler, build_all, track_first):
+ def build(self, scheduler, build_all, track_first, save):
if len(self.unused_workspaces) > 0:
self.message(MessageType.WARN, "Unused workspaces",
detail="\n".join([el + "-" + str(src) for el, src, _
@@ -407,7 +410,7 @@ class Pipeline():
push = None
queues = []
if track_first:
- track = TrackQueue()
+ track = TrackQueue(save=save)
queues.append(track)
if self.artifacts.can_fetch():
pull = PullQueue()
diff --git a/buildstream/_scheduler/trackqueue.py b/buildstream/_scheduler/trackqueue.py
index 404813f38..ffa143d5a 100644
--- a/buildstream/_scheduler/trackqueue.py
+++ b/buildstream/_scheduler/trackqueue.py
@@ -38,8 +38,9 @@ class TrackQueue(Queue):
complete_name = "Tracked"
queue_type = QueueType.FETCH
- def __init__(self):
+ def __init__(self, save=True):
super(TrackQueue, self).__init__()
+ self.save = save
def process(self, element):
return element._track()
@@ -68,12 +69,14 @@ class TrackQueue(Queue):
# Here we are in master process, what to do if writing
# to the disk fails for some reason ?
- try:
- _yaml.dump(toplevel, fullname)
- except OSError as e:
- source.error("Failed to update project file",
- detail="{}: Failed to rewrite tracked source to file {}: {}"
- .format(source, fullname, e))
+ if self.save:
+ try:
+ _yaml.dump(toplevel, fullname)
+ except OSError as e:
+ source.error("Failed to update project file",
+ detail="{}: Failed to rewrite "
+ "tracked source to file {}: {}"
+ .format(source, fullname, e))
# Forcefully recalculate the element's consistency state after successfully
# tracking, this is avoid a following fetch queue operating on the sources