diff options
author | James Ennis <james.ennis@codethink.co.uk> | 2019-09-06 17:53:54 +0100 |
---|---|---|
committer | James Ennis <james.ennis@codethink.co.uk> | 2019-09-12 16:29:12 +0100 |
commit | 6cb668ade39dfe1cf5e23177b022492e1632b035 (patch) | |
tree | e134aed8352e144bcac85b35376c94796b01037c /src/buildstream | |
parent | 11e9934df6ec8dcdf2abde074e27450f51522bfd (diff) | |
download | buildstream-6cb668ade39dfe1cf5e23177b022492e1632b035.tar.gz |
cli.py: Make source checkout more consistent with artifact checkout
This MR changes the behaviour of source checkout so that it is more
like artifact checkout. That is, a --directory option can be provided,
rather than a mandatory LOCATION.
In addition to this, the --tar option is no longer a boolean flag,
rather it expects a tarfile name (just like artifact checkout)
The appropriate tests have also been altered so that they support
the new API
Diffstat (limited to 'src/buildstream')
-rw-r--r-- | src/buildstream/_frontend/cli.py | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/buildstream/_frontend/cli.py b/src/buildstream/_frontend/cli.py index 631eff7d3..9fa482666 100644 --- a/src/buildstream/_frontend/cli.py +++ b/src/buildstream/_frontend/cli.py @@ -807,28 +807,31 @@ def source_track(app, elements, deps, except_, cross_junctions): @click.option('--deps', '-d', default='none', show_default=True, type=click.Choice(['build', 'none', 'run', 'all']), help='The dependencies whose sources to checkout') -@click.option('--tar', 'tar', is_flag=True, - help='Create a tarball from the element\'s sources instead of a ' - 'file tree.') +@click.option('--tar', default=None, metavar='LOCATION', + type=click.Path(), + help="Create a tarball containing the sources instead " + "of a file tree.") @click.option('--include-build-scripts', 'build_scripts', is_flag=True) +@click.option('--directory', default='source-checkout', + type=click.Path(file_okay=False), + help="The directory to checkout the sources to") @click.argument('element', required=False, type=click.Path(readable=False)) -@click.argument('location', type=click.Path(), required=False) @click.pass_obj -def source_checkout(app, element, location, force, deps, except_, +def source_checkout(app, element, directory, force, deps, except_, tar, build_scripts): """Checkout sources of an element to the specified location When this command is executed from a workspace directory, the default is to checkout the sources of the workspace element. """ - if not element and not location: - click.echo("ERROR: LOCATION is not specified", err=True) + + if tar and directory != "source-checkout": + click.echo("ERROR: options --directory and --tar conflict", err=True) sys.exit(-1) - if element and not location: - # Nasty hack to get around click's optional args - location = element - element = None + # Set the location depending on whether --tar/--directory were specified + # Note that if unset, --directory defaults to "source-checkout" + location = tar if tar else directory with app.initialized(): if not element: @@ -841,7 +844,7 @@ def source_checkout(app, element, location, force, deps, except_, force=force, deps=deps, except_targets=except_, - tar=tar, + tar=bool(tar), include_build_scripts=build_scripts) |