diff options
author | Jonathan Maw <jonathan.maw@codethink.co.uk> | 2018-02-26 14:06:33 +0000 |
---|---|---|
committer | Jonathan Maw <jonathan.maw@codethink.co.uk> | 2018-03-01 17:27:28 +0000 |
commit | 42de997e993fb1f97b2f2f8e873294e8a7055f79 (patch) | |
tree | acd39b428a6a9b0d941656335539ff81ddde9caa /buildstream | |
parent | 8a4fff9af391bea52397dbfcac907ab5759ef50c (diff) | |
download | buildstream-42de997e993fb1f97b2f2f8e873294e8a7055f79.tar.gz |
Pipeline: Give more helpful errors when opening a workspace for an element that has no sources
When trying to look at the source code for an element, elements that
modify artifacts (e.g. script and compose elements) don't have sources,
so we suggest some other elements that they might try opening workspaces
for.
Diffstat (limited to 'buildstream')
-rw-r--r-- | buildstream/_frontend/cli.py | 3 | ||||
-rw-r--r-- | buildstream/_pipeline.py | 7 |
2 files changed, 7 insertions, 3 deletions
diff --git a/buildstream/_frontend/cli.py b/buildstream/_frontend/cli.py index 29bae1da4..be84902d9 100644 --- a/buildstream/_frontend/cli.py +++ b/buildstream/_frontend/cli.py @@ -611,8 +611,7 @@ def workspace_open(app, no_checkout, force, track, element, directory): app.pipeline.open_workspace(app.scheduler, directory, no_checkout, track, force) click.echo("", err=True) except BstError as e: - click.echo("", err=True) - click.echo("ERROR: {}".format(e), err=True) + app.print_error(e) sys.exit(-1) diff --git a/buildstream/_pipeline.py b/buildstream/_pipeline.py index d1ab0f27c..1c147d59e 100644 --- a/buildstream/_pipeline.py +++ b/buildstream/_pipeline.py @@ -561,7 +561,12 @@ class Pipeline(): workdir = os.path.abspath(directory) if len(list(target.sources())) == 0: - raise PipelineError("The given element has no sources") + build_depends = [x.name for x in target.dependencies(Scope.BUILD, recurse=False)] + if len(build_depends) == 0: + raise PipelineError("The given element has no sources or build-dependencies") + detail = "Try opening a workspace on one of its dependencies instead:\n" + detail += " \n".join(build_depends) + raise PipelineError("The given element has no sources", detail=detail) # Check for workspace config if self.project._get_workspace(target.name): |