diff options
-rw-r--r-- | NEWS | 4 | ||||
-rw-r--r-- | buildstream/_context.py | 20 | ||||
-rw-r--r-- | buildstream/_frontend/app.py | 7 | ||||
-rw-r--r-- | buildstream/data/userconfig.yaml | 16 |
4 files changed, 43 insertions, 4 deletions
@@ -45,6 +45,10 @@ buildstream 1.3.1 instead of just a specially-formatted build-root with a `root` and `scratch` subdirectory. + o The buildstream.conf file learned a new 'prompt.auto-init' option. This + allows users to suppress prompts for automatically running 'bst init' if we + were unable to resolve the project. + o Due to the element `build tree` being cached in the respective artifact their size in some cases has significantly increased. In *most* cases the build trees are not utilised when building targets, as such by default bst 'pull' & 'build' diff --git a/buildstream/_context.py b/buildstream/_context.py index 55cce685b..9bb261b62 100644 --- a/buildstream/_context.py +++ b/buildstream/_context.py @@ -110,6 +110,10 @@ class Context(): # Whether or not to attempt to pull build trees globally self.pull_buildtrees = None + # Boolean, whether to offer to create a project for the user, if we are + # invoked outside of a directory where we can resolve the project. + self.prompt_auto_init = None + # Whether elements must be rebuilt when their dependencies have changed self._strict_build_plan = None @@ -165,7 +169,7 @@ class Context(): _yaml.node_validate(defaults, [ 'sourcedir', 'builddir', 'artifactdir', 'logdir', 'scheduler', 'artifacts', 'logging', 'projects', - 'cache' + 'cache', 'prompt' ]) for directory in ['sourcedir', 'builddir', 'artifactdir', 'logdir']: @@ -221,6 +225,20 @@ class Context(): self.sched_pushers = _yaml.node_get(scheduler, int, 'pushers') self.sched_network_retries = _yaml.node_get(scheduler, int, 'network-retries') + # Load prompt preferences + # + # We convert string options to booleans here, so we can be both user + # and coder-friendly. The string options are worded to match the + # responses the user would give at the cli, for least surprise. The + # booleans are converted here because it's easiest to eyeball that the + # strings are right. + # + prompt = _yaml.node_get( + defaults, Mapping, 'prompt') + _yaml.node_validate(prompt, ['auto-init']) + self.prompt_auto_init = _node_get_option_str( + prompt, 'auto-init', ['ask', 'no']) == 'ask' + # Load per-projects overrides self._project_overrides = _yaml.node_get(defaults, Mapping, 'projects', default_value={}) diff --git a/buildstream/_frontend/app.py b/buildstream/_frontend/app.py index b42b94bc1..4094eec17 100644 --- a/buildstream/_frontend/app.py +++ b/buildstream/_frontend/app.py @@ -222,9 +222,10 @@ class App(): # Let's automatically start a `bst init` session in this case if e.reason == LoadErrorReason.MISSING_PROJECT_CONF and self.interactive: click.echo("A project was not detected in the directory: {}".format(directory), err=True) - click.echo("", err=True) - if click.confirm("Would you like to create a new project here ?"): - self.init_project(None) + if self.context.prompt_auto_init: + click.echo("", err=True) + if click.confirm("Would you like to create a new project here?"): + self.init_project(None) self._error_exit(e, "Error loading project") diff --git a/buildstream/data/userconfig.yaml b/buildstream/data/userconfig.yaml index f540a97f6..0e6581cb7 100644 --- a/buildstream/data/userconfig.yaml +++ b/buildstream/data/userconfig.yaml @@ -100,3 +100,19 @@ logging: [%{elapsed}][%{key}][%{element}] %{action} %{message} +# +# Prompt overrides +# +# Here you can suppress 'are you sure?' and other kinds of prompts by supplying +# override values. Note that e.g. 'yes' and 'no' have the same meaning here as +# they do in the actual cli prompt. +# +prompt: + + # Whether to create a project with 'bst init' if we are invoked outside of a + # directory where we can resolve the project. + # + # ask - Prompt the user to choose. + # no - Never create the project. + # + auto-init: ask |