summaryrefslogtreecommitdiff
path: root/src/buildstream/_frontend/cli.py
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2020-04-20 20:30:17 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2020-04-25 00:16:01 +0900
commit6ef6be52c1cd66245fc7f13a3c472024e10c3c1a (patch)
tree19e1fa50917931aac784bca94d765f132c75805d /src/buildstream/_frontend/cli.py
parentbacc060cfcf32cdb696ce1a3ef195ea9bed0d8c1 (diff)
downloadbuildstream-6ef6be52c1cd66245fc7f13a3c472024e10c3c1a.tar.gz
Replace format-version with min-version
* "min-version" is specified as a <major>.<minor> point version and uses the installed BuildStream version instead of having a separate versioning number for the format. * The presence of "format-version" is now used to indicate that we might be loading a BuildStream 1 project. * For now, where parsing the version at startup is concerned, and also where `bst init` is concerned, we artificially bump the detected BuildStream version to 2.0 if we detect a version < 2.0, these exceptions can be removed once 2.0 is tagged and released. Summary of changes: _project.py: Now parse "min-version" and detect "format-version" to warn about loading a BuildStream 1 project _versions.py: Remove obsolete BST_FORMAT_VERSION numbers from here data/projectconfig.yaml: Remove old "format-version" from defaults utils.py: Added new private _parse_version() helper function, and another _get_bst_api_version() to get an adjusted API version. frontend/app.py, frontend/cli.py: Updated `bst init` implementation testing (buildstream.testing): Updated testing utilities to generate and use projects with min-version instead of format-version. tests and examples: Updated to use min-version across the board.
Diffstat (limited to 'src/buildstream/_frontend/cli.py')
-rw-r--r--src/buildstream/_frontend/cli.py25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/buildstream/_frontend/cli.py b/src/buildstream/_frontend/cli.py
index 44bb99f92..522f15115 100644
--- a/src/buildstream/_frontend/cli.py
+++ b/src/buildstream/_frontend/cli.py
@@ -7,10 +7,9 @@ import shutil
import click
from .. import _yaml
from .._exceptions import BstError, LoadError, AppError
-from .._versions import BST_FORMAT_VERSION
from .complete import main_bashcomplete, complete_path, CompleteUnhandled
from ..types import _CacheBuildTrees, _SchedulerErrorAction, _PipelineSelection
-from ..utils import _get_compression, UtilError
+from ..utils import UtilError
##################################################################
@@ -414,12 +413,20 @@ def help_command(ctx, command):
##################################################################
# Init Command #
##################################################################
+def default_min_version():
+ from .. import utils
+
+ bst_major, bst_minor = utils._get_bst_api_version()
+
+ return "{}.{}".format(bst_major, bst_minor)
+
+
@cli.command(short_help="Initialize a new BuildStream project")
@click.option("--project-name", type=click.STRING, help="The project name to use")
@click.option(
- "--format-version",
- type=click.INT,
- default=BST_FORMAT_VERSION,
+ "--min-version",
+ type=click.STRING,
+ default=default_min_version(),
show_default=True,
help="The required format version",
)
@@ -433,7 +440,7 @@ def help_command(ctx, command):
@click.option("--force", "-f", is_flag=True, help="Allow overwriting an existing project.conf")
@click.argument("target-directory", nargs=1, required=False, type=click.Path(file_okay=False, writable=True))
@click.pass_obj
-def init(app, project_name, format_version, element_path, force, target_directory):
+def init(app, project_name, min_version, element_path, force, target_directory):
"""Initialize a new BuildStream project
Creates a new BuildStream project.conf in the project
@@ -442,7 +449,7 @@ def init(app, project_name, format_version, element_path, force, target_director
Unless `--project-name` is specified, this will be an
interactive session.
"""
- app.init_project(project_name, format_version, element_path, force, target_directory)
+ app.init_project(project_name, min_version, element_path, force, target_directory)
##################################################################
@@ -1226,6 +1233,8 @@ def artifact_checkout(app, force, deps, integrate, hardlinks, tar, compression,
When this command is executed from a workspace directory, the default
is to checkout the artifact of the workspace element.
"""
+ from .. import utils
+
if hardlinks and tar:
click.echo("ERROR: options --hardlinks and --tar conflict", err=True)
sys.exit(-1)
@@ -1249,7 +1258,7 @@ def artifact_checkout(app, force, deps, integrate, hardlinks, tar, compression,
else:
location = tar
try:
- inferred_compression = _get_compression(tar)
+ inferred_compression = utils._get_compression(tar)
except UtilError as e:
click.echo("ERROR: Invalid file extension given with '--tar': {}".format(e), err=True)
sys.exit(-1)