Example #1
0
def run_cmd(cmd_name, cmd_opts, run_node, top_node, build_node):
    cmd_klass = COMMANDS_REGISTRY.get_command(cmd_name)

    # XXX: fix this special casing (commands which do not need a pkg instance)
    if cmd_name in ["help", "convert"]:
        cmd = cmd_klass()
        options_ctx = OPTIONS_REGISTRY.get_options(cmd_name)
        ctx_klass = CONTEXT_REGISTRY.get(cmd_name)
        ctx = ctx_klass(cmd_opts, options_ctx, None, run_node)
        # XXX: hack for help command to get option context for any command
        # without making help depends on bentomakerlib
        ctx.options_registry = OPTIONS_REGISTRY
        cmd.run(ctx)
        return

    bento_info = top_node.find_node(BENTO_SCRIPT)
    if bento_info is None:
        raise UsageException("Error: no %s found !" % os.path.join(top_node.abspath(), BENTO_SCRIPT))

    package_options = __get_package_options(top_node)
    pkg = _get_package_with_user_flags(cmd_name, cmd_opts, package_options, top_node, build_node)
    if is_help_only(cmd_name, cmd_opts):
        options_context = OPTIONS_REGISTRY.get_options(cmd_name)
        p = options_context.parser
        o, a = p.parse_args(cmd_opts)
        if o.help:
            p.print_help()
    else:
        run_dependencies(cmd_name, run_node, top_node, build_node, pkg)

        ctx_klass = CONTEXT_REGISTRY.get(cmd_name)
        run_cmd_in_context(cmd_klass, cmd_name, cmd_opts, ctx_klass, run_node, top_node, pkg)

        cmd_data_db = build_node.make_node(CMD_DATA_DUMP)
        _set_cmd_data_provider(cmd_name, cmd_opts, cmd_data_db)
Example #2
0
def run_sdist(context):
    sdist_name = "sdist"
    sdist_klass = COMMANDS_REGISTRY.get_command(sdist_name)
    cmd_argv = []
    sdist_context_klass = CONTEXT_REGISTRY.get(sdist_name)
    sdist, sdist_context = run_cmd_in_context(sdist_klass,
                        sdist_name, cmd_argv, sdist_context_klass,
                        context.run_node, context.top_node, context.pkg)
    return sdist
Example #3
0
def run_dependencies(cmd_name, run_node, top_node, build_node, pkg):
    cmd_data_db = build_node.make_node(CMD_DATA_DUMP)

    deps = CMD_SCHEDULER.order(cmd_name)
    for cmd_name in deps:
        cmd_klass = COMMANDS_REGISTRY.get_command(cmd_name)
        cmd_argv = _get_cmd_data_provider(cmd_data_db).get_argv(cmd_name)
        ctx_klass = CONTEXT_REGISTRY.get(cmd_name)
        run_cmd_in_context(cmd_klass, cmd_name, cmd_argv, ctx_klass, run_node, top_node, pkg)
Example #4
0
def register_command_contexts():
    CONTEXT_REGISTRY.set_default(CmdContext)
    if not CONTEXT_REGISTRY.is_registered("configure"):
        CONTEXT_REGISTRY.register("configure", ConfigureYakuContext)
    if not CONTEXT_REGISTRY.is_registered("build"):
        CONTEXT_REGISTRY.register("build", BuildYakuContext)
    if not CONTEXT_REGISTRY.is_registered("help"):
        CONTEXT_REGISTRY.register("help", HelpContext)