Commit 580b2f33 authored by Tristan Maat's avatar Tristan Maat
Browse files

main.py: Move --arch* options to the main command

parent 917a1b9f
Loading
Loading
Loading
Loading
Loading
+22 −58
Original line number Diff line number Diff line
@@ -77,6 +77,12 @@ _, _, _, _, host_machine = os.uname()
              help="A file to store the main log (allows storing the main log while in interactive mode)")
@click.option('--colors/--no-colors', default=None,
              help="Force enable/disable ANSI color codes in output")
@click.option('--arch', '-a', default=host_machine,
              help="Architecture of the machine running the build (default: %s)" % host_machine)
@click.option('--host-arch',
              help="Run as a native build for the given architecture (defaults to --arch)")
@click.option('--target-arch',
              help="Produce elements that execute on this architecture (defaults to --arch)")
@click.pass_context
def cli(context, **kwargs):
    """Build and manipulate BuildStream projects
@@ -97,20 +103,14 @@ 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('--arch', '-a', default=host_machine,
              help="Architecture of the machine running the build (default: %s)" % host_machine)
@click.option('--host-arch',
              help="Run as a native build for the given architecture (defaults to --arch)")
@click.option('--target-arch',
              help="Produce elements that execute on this architecture (defaults to --arch)")
@click.option('--variant',
              help='A variant of the specified target')
@click.argument('target')
@click.pass_obj
def build(app, target, arch, host_arch, target_arch, variant, all, track):
def build(app, target, variant, all, track):
    """Build elements in a pipeline"""

    app.initialize(target, host_arch or arch, target_arch or arch, variant,
    app.initialize(target, app.host_arch, app.target_arch, variant,
                   rewritable=track, inconsistent=track)
    app.print_heading()
    try:
@@ -132,17 +132,11 @@ def build(app, target, arch, host_arch, target_arch, variant, all, track):
              help='The dependencies to fetch (default: plan)')
@click.option('--track', default=False, is_flag=True,
              help="Track new source references before fetching")
@click.option('--arch', '-a', default=host_machine,
              help="Architecture of the machine running the build (default: %s)" % host_machine)
@click.option('--host-arch',
              help="Run as a native build for the given architecture (defaults to --arch)")
@click.option('--target-arch',
              help="Produce elements that execute on this architecture (defaults to --arch)")
@click.option('--variant',
              help='A variant of the specified target')
@click.argument('target')
@click.pass_obj
def fetch(app, target, arch, host_arch, target_arch, variant, deps, track, except_):
def fetch(app, target, variant, deps, track, except_):
    """Fetch sources required to build the pipeline

    By default this will only try to fetch sources which are
@@ -157,7 +151,7 @@ def fetch(app, target, arch, host_arch, target_arch, variant, deps, track, excep
        plan:  Only dependencies required for the build plan
        all:   All dependencies
    """
    app.initialize(target, host_arch or arch, target_arch or arch, variant,
    app.initialize(target, app.host_arch, app.target_arch, variant,
                   rewritable=track, inconsistent=track)
    try:
        dependencies = app.pipeline.deps_elements(deps, except_)
@@ -178,17 +172,11 @@ def fetch(app, target, arch, host_arch, target_arch, variant, deps, track, excep
@click.option('--deps', '-d', default='none',
              type=click.Choice(['none', 'all']),
              help='The dependencies to track (default: none)')
@click.option('--arch', '-a', default=host_machine,
              help="Architecture of the machine running the build (default: %s)" % host_machine)
@click.option('--host-arch',
              help="Run as a native build for the given architecture (defaults to --arch)")
@click.option('--target-arch',
              help="Produce elements that execute on this architecture (defaults to --arch)")
@click.option('--variant',
              help='A variant of the specified target')
@click.argument('target')
@click.pass_obj
def track(app, target, arch, host_arch, target_arch, variant, deps, except_):
def track(app, target, variant, deps, except_):
    """Consults the specified tracking branches for new versions available
    to build and updates the project with any newly available references.

@@ -201,7 +189,7 @@ def track(app, target, arch, host_arch, target_arch, variant, deps, except_):
        none:  No dependencies, just the element itself
        all:   All dependencies
    """
    app.initialize(target, host_arch or arch, target_arch or arch, variant,
    app.initialize(target, app.host_arch, app.target_arch, variant,
                   rewritable=True, inconsistent=True)
    try:
        dependencies = app.pipeline.deps_elements(deps, except_)
@@ -228,17 +216,11 @@ def track(app, target, arch, host_arch, target_arch, variant, deps, except_):
@click.option('--format', '-f', metavar='FORMAT', default="%{state: >12} %{key} %{name}",
              type=click.STRING,
              help='Format string for each element')
@click.option('--arch', '-a', default=host_machine,
              help="Architecture of the machine running the build (default: %s)" % host_machine)
@click.option('--host-arch',
              help="Run as a native build for the given architecture (defaults to --arch)")
@click.option('--target-arch',
              help="Produce elements that execute on this architecture (defaults to --arch)")
@click.option('--variant',
              help='A variant of the specified target')
@click.argument('target')
@click.pass_obj
def show(app, target, arch, host_arch, target_arch, variant, deps, except_, order, format):
def show(app, target, variant, deps, except_, order, format):
    """Show elements in the pipeline

    By default this will show all of the dependencies of the
@@ -283,7 +265,7 @@ def show(app, target, arch, host_arch, target_arch, variant, deps, except_, orde
        bst show target.bst --format \\
            $'---------- %{name} ----------\\n%{vars}'
    """
    app.initialize(target, host_arch or arch, target_arch or arch, variant)
    app.initialize(target, app.host_arch, app.target_arch, variant)
    try:
        dependencies = app.pipeline.deps_elements(deps, except_)
    except PipelineError as e:
@@ -307,17 +289,11 @@ def show(app, target, arch, host_arch, target_arch, variant, deps, except_, orde
@click.option('--scope', '-s', default=None,
              type=click.Choice(['build', 'run']),
              help='Specify element scope to stage')
@click.option('--arch', '-a', default=host_machine,
              help="Architecture of the machine running the build (default: %s)" % host_machine)
@click.option('--host-arch',
              help="Run as a native build for the given architecture (defaults to --arch)")
@click.option('--target-arch',
              help="Produce elements that execute on this architecture (defaults to --arch)")
@click.option('--variant',
              help='A variant of the specified target')
@click.argument('target')
@click.pass_obj
def shell(app, target, arch, host_arch, target_arch, variant, builddir, scope):
def shell(app, target, variant, builddir, scope):
    """Shell into an element's sandbox environment

    This can be used either to debug building or to launch
@@ -336,7 +312,7 @@ def shell(app, target, arch, host_arch, target_arch, variant, builddir, scope):
    elif scope == "build":
        scope = Scope.BUILD

    app.initialize(target, host_arch or arch, target_arch or arch, variant)
    app.initialize(target, app.host_arch, app.target_arch, variant)

    # Assert we have everything we need built.
    missing_deps = []
@@ -368,21 +344,15 @@ def shell(app, target, arch, host_arch, target_arch, variant, builddir, scope):
@cli.command(short_help="Checkout a built artifact")
@click.option('--force', '-f', default=False, is_flag=True,
              help="Overwrite files existing in checkout directory")
@click.option('--arch', '-a', default=host_machine,
              help="Architecture of the machine running the build (default: %s)" % host_machine)
@click.option('--host-arch',
              help="Run as a native build for the given architecture (defaults to --arch)")
@click.option('--target-arch',
              help="Produce elements that execute on this architecture (defaults to --arch)")
@click.option('--variant',
              help='A variant of the specified target')
@click.argument('target')
@click.argument('directory')
@click.pass_obj
def checkout(app, target, arch, host_arch, target_arch, variant, directory, force):
def checkout(app, target, variant, directory, force):
    """Checkout a built artifact to the specified directory
    """
    app.initialize(target, host_arch or arch, target_arch or arch, variant)
    app.initialize(target, app.host_arch, app.target_arch, variant)
    try:
        app.pipeline.checkout(directory, force)
        click.echo("")
@@ -406,12 +376,6 @@ def checkout(app, target, arch, host_arch, target_arch, variant, directory, forc
              help='The elements to bundle (default: build)')
@click.option('--track', default=False, is_flag=True,
              help="Track new source references before building")
@click.option('--arch', '-a', default=host_machine,
              help="Architecture of the machine running the build (default: %s)" % host_machine)
@click.option('--host-arch',
              help="Run as a native build for the given architecture (defaults to --arch)")
@click.option('--target-arch',
              help="Produce elements that execute on this architecture (defaults to --arch)")
@click.option('--variant',
              help='A variant of the specified target')
@click.option('--force', '-f', default=False, is_flag=True,
@@ -420,7 +384,7 @@ def checkout(app, target, arch, host_arch, target_arch, variant, directory, forc
              help="The directory to write the tarball to")
@click.argument('target')
@click.pass_obj
def source_bundle(app, target, arch, host_arch, target_arch, variant, force, directory,
def source_bundle(app, target, variant, force, directory,
                  track, deps, compression, except_):
    """Produce a build bundle to be manually executed

@@ -431,7 +395,7 @@ def source_bundle(app, target, arch, host_arch, target_arch, variant, force, dir
        run:   Runtime dependencies, including the element itself
        build: Build time dependencies, excluding the element itself
    """
    app.initialize(target, host_arch or arch, target_arch or arch, variant,
    app.initialize(target, app.host_arch, app.target_arch, variant,
                   rewritable=track, inconsistent=track)
    try:
        dependencies = app.pipeline.deps_elements(deps, except_)
@@ -457,9 +421,9 @@ class App():
        self.logger = None
        self.status = None
        self.target = None
        self.host_arch = None
        self.target_arch = None
        self.variant = None
        self.host_arch = main_options['host_arch'] or main_options['arch']
        self.target_arch = main_options['target_arch'] or main_options['arch']

        # Main asset handles
        self.context = None