def do(args):
    """ Main method """
    tc_names = qitoolchain.get_tc_names()
    tc_name = args.name
    if tc_name:
        if not tc_name in qitoolchain.get_tc_names():
            print "No such toolchain: ", tc_name
            return
        toolchain = qitoolchain.Toolchain(tc_name)
        print toolchain
    else:
        for tc_name in tc_names:
            toolchain = qitoolchain.Toolchain(tc_name)
            print toolchain
            print
Exemple #2
0
def do(args):
    """ Main method """
    tc_names = qitoolchain.get_tc_names()
    tc_name = args.name
    if tc_name:
        if not tc_name in qitoolchain.get_tc_names():
            print "No such toolchain: ", tc_name
            return
        toolchain = qitoolchain.Toolchain(tc_name)
        print toolchain
    else:
        for tc_name in tc_names:
            toolchain = qitoolchain.Toolchain(tc_name)
            print toolchain
            print
Exemple #3
0
def do(args):
    """Main entry point

    """
    feed = args.feed
    tc_name = args.name
    if tc_name:
        toolchain = qitoolchain.get_toolchain(tc_name)
        if not feed:
            feed = toolchain.feed_url
            if not feed:
                mess = "Could not find feed for toolchain %s\n" % tc_name
                mess += "Please check configuration or " \
                        "specifiy a feed on the command line\n"
                raise Exception(mess)
        toolchain.update(feed)
    else:
        tc_names = qitoolchain.get_tc_names()
        for i, tc_name in enumerate(tc_names, start=1):
            toolchain = qitoolchain.toolchain.Toolchain(tc_name)
            tc_feed = toolchain.feed_url
            if not tc_feed:
                ui.warning("No feed found for %s, skipping" % tc_name)
                continue
            ui.info(ui.green, "*", ui.reset, "(%i/%i)" % (i, len(tc_names)),
                    ui.green, "Updating", ui.blue, tc_name)
            toolchain.update(tc_feed)
Exemple #4
0
def do(args):
    """Main entry point

    """
    feed = args.feed
    tc_name = args.name
    if tc_name:
        toolchain = qitoolchain.get_toolchain(tc_name)
        if not feed:
            feed = toolchain.feed_url
            if not feed:
                mess  = "Could not find feed for toolchain %s\n" % tc_name
                mess += "Please check configuration or " \
                        "specifiy a feed on the command line\n"
                raise Exception(mess)
        toolchain.update(feed)
    else:
        tc_names = qitoolchain.get_tc_names()
        for i, tc_name in enumerate(tc_names, start=1):
            toolchain = qitoolchain.toolchain.Toolchain(tc_name)
            tc_feed = toolchain.feed_url
            if not tc_feed:
                ui.warning("No feed found for %s, skipping" % tc_name)
                continue
            ui.info(ui.green, "*", ui.reset, "(%i/%i)" % (i, len(tc_names)),
                    ui.green, "Updating", ui.blue, tc_name)
            toolchain.update(tc_feed)
Exemple #5
0
def do(args):
    """ Main method """
    tc_names = qitoolchain.get_tc_names()
    if not tc_names:
        ui.info("No toolchain yet", "\n",
                "Use `qitoolchain create` to create a new toolchain")
        return
    default_config = None
    try:
        build_worktree = qibuild.parsers.get_build_worktree(args)
        default_config = build_worktree.default_config
    except qisys.worktree.NotInWorkTree:
        pass
    ui.info("Known toolchains:")
    for tc_name in tc_names:
        if tc_name == default_config:
            ui.info("*", tc_name)
        else:
            ui.info(" ", tc_name)
    print
    if default_config is not None:
        ui.info("WorkTree", ui.green, build_worktree.root, ui.reset,
                "is using", ui.blue, default_config, ui.reset,
                "as its default toolchain.")
    ui.info("Use ``qitoolchain info <tc_name>`` for more info")
Exemple #6
0
def do(args):
    """ Main method """
    tc_names = qitoolchain.get_tc_names()
    if not tc_names:
        ui.info("No toolchain yet", "\n",
                "Use `qitoolchain create` to create a new toolchain")
        return
    default_config = None
    try:
        build_worktree = qibuild.parsers.get_build_worktree(args)
        default_config = build_worktree.default_config
    except qisys.worktree.NotInWorkTree:
        pass
    ui.info("Known toolchains:")
    for tc_name in tc_names:
        if tc_name == default_config:
            ui.info("*", tc_name)
        else:
            ui.info(" ", tc_name)
    print
    if default_config is not None:
        ui.info("WorkTree", ui.green, build_worktree.root, ui.reset, "is using",
                ui.blue, default_config, ui.reset,
                "as its default toolchain.")
    ui.info("Use ``qitoolchain info <tc_name>`` for more info")
Exemple #7
0
def do(args):
    """ Main entry point """
    feed = args.feed
    tc_name = args.name
    if tc_name:
        toolchain = qitoolchain.get_toolchain(tc_name)
        if not feed:
            feed = toolchain.feed_url
            if not feed:
                mess = "Could not find feed for toolchain %s\n" % tc_name
                mess += "Please check configuration or " \
                        "specifiy a feed on the command line\n"
                raise Exception(mess)
        toolchain.update(feed, branch=args.branch, name=args.feed_name)
    else:
        tc_names = qitoolchain.get_tc_names()
        tc_with_feed = [x for x in tc_names if qitoolchain.toolchain.Toolchain(x).feed_url]
        tc_without_feed = list(set(tc_names) - set(tc_with_feed))
        for i, tc_name in enumerate(tc_with_feed, start=1):
            toolchain = qitoolchain.toolchain.Toolchain(tc_name)
            tc_feed = toolchain.feed_url
            ui.info(ui.green, "*", ui.reset, "(%i/%i)" % (i, len(tc_with_feed)),
                    ui.green, "Updating", ui.blue, tc_name, ui.reset, "with", ui.green,
                    tc_feed)
            toolchain.update(tc_feed)
        if tc_without_feed:
            ui.info("These toolchains will be skipped because they have no feed:", ", ".join(tc_without_feed))
Exemple #8
0
def do(args):
    """Main entry point

    """
    feed = args.feed
    tc_name = args.name
    if tc_name:
        toolchain = qitoolchain.get_toolchain(tc_name)
        if not feed:
            feed = toolchain.feed_url
            if not feed:
                mess  = "Could not find feed for toolchain %s\n" % tc_name
                mess += "Please check configuration or " \
                        "specifiy a feed on the command line\n"
                raise Exception(mess)
        toolchain.update(feed, branch=args.branch, name=args.feed_name)
    else:
        tc_names = qitoolchain.get_tc_names()
        tc_with_feed = [x for x in tc_names if qitoolchain.toolchain.Toolchain(x).feed_url]
        tc_without_feed = list(set(tc_names) - set(tc_with_feed))
        for i, tc_name in enumerate(tc_with_feed, start=1):
            toolchain = qitoolchain.toolchain.Toolchain(tc_name)
            tc_feed = toolchain.feed_url
            ui.info(ui.green, "*", ui.reset, "(%i/%i)" % (i, len(tc_with_feed)),
                    ui.green, "Updating", ui.blue, tc_name, ui.reset, "with", ui.green,
                    tc_feed)
            toolchain.update(tc_feed)
        if tc_without_feed:
            ui.info("These toolchains will be skipped because they have no feed:", ", ".join(tc_without_feed))
Exemple #9
0
def do(args):
    """Main entry point

    """
    if "--name" in sys.argv:
        ui.warning("--name is deprecated, use --feed-name instead")
    feed = args.feed
    # Normalize feed path:
    if feed and os.path.exists(feed):
        feed = qisys.sh.to_native_path(feed)
    tc_name = args.name

    # Validate the name: must be a valid filename:
    bad_chars = r'<>:"/\|?*'
    for bad_char in bad_chars:
        if bad_char in tc_name:
            mess = "Invalid toolchain name: '%s'\n" % tc_name
            mess += "A valid toolchain name should not contain any "
            mess += "of the following chars:\n"
            mess += " ".join(bad_chars)
            raise Exception(mess)

    if tc_name in qitoolchain.get_tc_names():
        toolchain = qitoolchain.Toolchain(tc_name)  # pylint: disable=unused-variable
        ui.info(tc_name, "already exists,", "updating without removing")

    toolchain = qitoolchain.Toolchain(tc_name)
    if feed:
        toolchain.update(feed, branch=args.branch, name=args.feed_name)

    return toolchain
def do(args):
    """Main entry point

    """
    feed = args.feed
    tc_name = args.name
    dry_run = args.dry_run
    if tc_name:
        toolchain = qitoolchain.get_toolchain(tc_name)
        if not feed:
            feed = qitoolchain.toolchain.get_tc_feed(tc_name)
            if not feed:
                mess  = "Could not find feed for toolchain %s\n" % tc_name
                mess += "Pleas check configuration or specifiy a feed on the command line\n"
                raise Exception(mess)
        ui.info(ui.green, "Updating toolchain", tc_name, "with", feed)
        toolchain.parse_feed(feed, dry_run=dry_run)
    else:
        tc_names = qitoolchain.get_tc_names()
        i = 0
        for tc_name in tc_names:
            i += 1
            tc_feed = qitoolchain.toolchain.get_tc_feed(tc_name)
            ui.info(ui.green, "*", ui.reset, "(%i/%i)" % (i, len(tc_names)),
                    ui.green, "Updating", ui.blue, tc_name)
            if not tc_feed:
                ui.warning("No feed found for %s, skipping" % tc_name)
                continue
            ui.info(ui.green, "Reading", tc_feed)
            toolchain = qitoolchain.Toolchain(tc_name)
            toolchain.parse_feed(tc_feed, dry_run=dry_run)
Exemple #11
0
def do(args):
    """Main entry point

    """
    if "--name" in sys.argv:
        ui.warning("--name is deprecated, use --feed-name instead")
    feed = args.feed
    # Normalize feed path:
    if feed and os.path.exists(feed):
        feed = qisys.sh.to_native_path(feed)
    tc_name = args.name

    # Validate the name: must be a valid filename:
    bad_chars = r'<>:"/\|?*'
    for bad_char in bad_chars:
        if bad_char in tc_name:
            mess  = "Invalid toolchain name: '%s'\n" % tc_name
            mess += "A valid toolchain name should not contain any "
            mess += "of the following chars:\n"
            mess += " ".join(bad_chars)
            raise Exception(mess)

    build_worktree = None

    if tc_name in qitoolchain.get_tc_names():
        toolchain = qitoolchain.Toolchain(tc_name)
        ui.info(tc_name, "already exists,",
                "updating without removing")

    toolchain = qitoolchain.Toolchain(tc_name)
    if feed:
        toolchain.update(feed, branch=args.branch, name=args.feed_name)

    return toolchain
Exemple #12
0
def do(args):
    """ Main method """
    tc_names = qitoolchain.get_tc_names()
    print "Known toolchains:"
    for tc_name in tc_names:
        print "  ", tc_name
    print
    print "Use ``qitoolchain info <tc_name>`` for more info"
def do(args):
    """ Main method """
    tc_names = qitoolchain.get_tc_names()
    print "Known toolchains:"
    for tc_name in tc_names:
        print "  ", tc_name
    print
    print "Use ``qitoolchain info <tc_name>`` for more info"
Exemple #14
0
    def test_setup(self):
        # Check that we are not modifying normal config
        config_path = qitoolchain.get_tc_config_path()
        expected = os.path.join(self.tmp, ".config", "qi", "toolchains.cfg")
        self.assertEquals(config_path, expected)

        # Check that there are no toolchain yet
        tc_names = qitoolchain.get_tc_names()
        self.assertEquals(tc_names, list())
    def test_setup(self):
        # Check that we are not modifying normal config
        config_path = qitoolchain.get_tc_config_path()
        expected = os.path.join(self.tmp, "config", "toolchains.cfg")
        self.assertEquals(config_path, expected)

        # Check that there are no toolchain yet
        tc_names = qitoolchain.get_tc_names()
        self.assertEquals(tc_names, list())
Exemple #16
0
def do(args):
    """ Main method """
    if args.name:
        tc_names = [args.name]
    else:
        tc_names = qitoolchain.get_tc_names()
    for tc_name in tc_names:
        toolchain = qitoolchain.get_toolchain(tc_name)
        ui.info(str(toolchain))
Exemple #17
0
def do(args):
    """ Main method """
    if args.name:
        tc_names = [args.name]
    else:
        tc_names = qitoolchain.get_tc_names()
    for tc_name in tc_names:
        toolchain = qitoolchain.get_toolchain(tc_name)
        ui.info(str(toolchain))
Exemple #18
0
def do(args):
    """ Main method """
    tc_names = qitoolchain.get_tc_names()
    if not tc_names:
        ui.info("No toolchain yet", "\n",
                "Use `qitoolchain create` to create a new toolchain")
        return
    ui.info("Known toolchains:")
    for tc_name in tc_names:
        ui.info("*", tc_name)
    ui.info("Use ``qitoolchain info <tc_name>`` for more info")
Exemple #19
0
def do(args):  # pylint: disable=unused-argument
    """ Main method """
    tc_names = qitoolchain.get_tc_names()
    if not tc_names:
        ui.info("No toolchain yet", "\n",
                "Use `qitoolchain create` to create a new toolchain")
        return
    ui.info("Known toolchains:")
    for tc_name in tc_names:
        ui.info("*", tc_name)
    ui.info("Use ``qitoolchain info <tc_name>`` for more info")
Exemple #20
0
def do(args):
    """ Main method """
    tc_names = qitoolchain.get_tc_names()
    tc_name = args.name
    if tc_name:
        toolchain = qitoolchain.get_toolchain(tc_name)
        print toolchain
    else:
        for tc_name in tc_names:
            toolchain = qitoolchain.Toolchain(tc_name)
            print toolchain
            print
Exemple #21
0
def do(args):
    """Main entry point

    """
    feed = args.feed
    tc_name = args.name
    dry_run = args.dry_run

    # Validate the name: must be a valid filename:
    bad_chars = r'<>:"/\|?*'
    for bad_char in bad_chars:
        if bad_char in tc_name:
            mess  = "Invalid toolchain name: '%s'\n" % tc_name
            mess += "A valid toolchain name should not contain any "
            mess += "of the following chars:\n"
            mess += " ".join(bad_chars)
            raise Exception(mess)

    if tc_name == "system":
        raise Exception("'system' is a reserved name")

    build_worktree = None

    if args.default:
        try:
            build_worktree = qibuild.parsers.get_build_worktree(args)
        except qisys.worktree.NotInWorkTree:
            mess = "You need to be in a worktree to use --default"
            raise Exception(mess)

    if tc_name in qitoolchain.get_tc_names():
        toolchain = qitoolchain.Toolchain(tc_name)
        if feed and toolchain.feed != feed:
            ui.warning(tc_name, "already exists but points to a different feed,",
                   "removing previous toolchain and creating a new one")
            toolchain.remove()
        else:
            ui.info(tc_name, "already exists,",
                   "updating without removing")

    toolchain = qitoolchain.Toolchain(tc_name)
    if feed:
        ui.info(ui.green, "Updating toolchain", tc_name, "with feed:", feed)
        toolchain.parse_feed(feed, dry_run=dry_run)

    if args.default:
        build_worktree.set_default_config(tc_name)
        ui.info("Now using toolchain", ui.blue, tc_name, ui.reset, "by default")
    else:
        ui.info(ui.green, "Now try using", "\n"
                "  qibuild configure -c", ui.blue, tc_name, ui.green, "\n"
                "  qibuild make -c",      ui.blue, tc_name)
    return toolchain
Exemple #22
0
def do(args):
    """Main entry point

    """
    feed = args.feed
    tc_name = args.name

    # Validate the name: must be a valid filename:
    bad_chars = r'<>:"/\|?*'
    for bad_char in bad_chars:
        if bad_char in tc_name:
            mess = "Invalid toolchain name: '%s'\n" % tc_name
            mess += "A valid toolchain name should not contain any "
            mess += "of the following chars:\n"
            mess += " ".join(bad_chars)
            raise Exception(mess)

    if tc_name == "system":
        raise Exception("'system' is a reserved name")

    build_worktree = None

    if args.default:
        try:
            build_worktree = qibuild.parsers.get_build_worktree(args)
        except qisys.worktree.NotInWorkTree:
            mess = "You need to be in a worktree to use --default"
            raise Exception(mess)

    if tc_name in qitoolchain.get_tc_names():
        toolchain = qitoolchain.Toolchain(tc_name)
        if feed and toolchain.feed_url != feed:
            ui.warning(tc_name,
                       "already exists but points to a different feed,",
                       "removing previous toolchain and creating a new one")
            toolchain.remove()
        else:
            ui.info(tc_name, "already exists,", "updating without removing")

    toolchain = qitoolchain.Toolchain(tc_name)
    if feed:
        ui.info(ui.green, "Updating toolchain", tc_name, "with feed:", feed)
        toolchain.update(feed)

    if args.default:
        build_worktree.set_default_config(tc_name)
        ui.info("Now using toolchain", ui.blue, tc_name, ui.reset,
                "by default")
    else:
        ui.info(ui.green, "Now try using", "\n"
                "  qibuild configure -c", ui.blue, tc_name, ui.green, "\n"
                "  qibuild make -c", ui.blue, tc_name)
    return toolchain
Exemple #23
0
def do(args):
    """ Main method """
    tc_names = qitoolchain.get_tc_names()
    if not tc_names:
        print "No toolchain yet"
        print "Use `qitoolchain create` to create a new toolchain"
        return
    print "Known toolchains:"
    for tc_name in tc_names:
        print "  ", tc_name
    print
    print "Use ``qitoolchain info <tc_name>`` for more info"
def configure_local_settings(toc):
    """ Configure local settings for this worktree

    """
    print
    ui.info(ui.green, "::", ui.reset,  "Found a worktree in", toc.worktree.root)
    answer = qibuild.interact.ask_yes_no(
        "Do you want to configure settings for this worktree",
        default=True)
    if not answer:
        return
    tc_names = qitoolchain.get_tc_names()
    if tc_names:
        ui.info(ui.green, "::", ui.reset,
                "Found the following toolchains: ", ", ".join(tc_names))
        answer = qibuild.interact.ask_yes_no(
            "Use one of these toolchains by default",
            default=True)
        if answer:
            default = qibuild.interact.ask_choice(tc_names,
                "Choose a toolchain to use by default")
            if default:
                toc.config.local.defaults.config = default
                toc.save_config()
    answer = qibuild.interact.ask_yes_no(
        "Do you want to use a unique build dir "
        "(mandatory when using Eclipse)",
        default=False)

    build_dir = None
    if answer:
        build_dir = qibuild.interact.ask_string("Path to a build directory")
        build_dir = os.path.expanduser(build_dir)
        full_path = os.path.join(toc.worktree.root, build_dir)
        ui.info(ui.green, "::", ui.reset,
                "Will use", full_path, "as a root for all build directories")
    toc.config.local.build.build_dir = build_dir
    toc.save_config()

    sdk_dir = None
    answer = qibuild.interact.ask_yes_no(
        "Do you want to use a unique SDK dir",
        default=False)
    if answer:
        sdk_dir = qibuild.interact.ask_string("Path to a SDK directory")
        sdk_dir = os.path.expanduser(sdk_dir)
        full_path = os.path.join(toc.worktree.root, sdk_dir)
        ui.info(ui.green, "::", ui.reset,
                "Will use", full_path, "as a unique SDK directory")
    toc.config.local.build.sdk_dir = sdk_dir
    toc.save_config()
Exemple #25
0
def do(args):
    """ Main method """
    tc_names = qitoolchain.get_tc_names()
    if not tc_names:
        print "No toolchain yet"
        print "Use `qitoolchain create` to create a new toolchain"
        return
    default_toc_name = None
    try:
        worktree = qisys.worktree.open_worktree(args.worktree)
        toc = qibuild.toc.Toc(worktree)
        default_toc_name = toc.config.local.defaults.config
    except qisys.worktree.NotInWorktree, e:
        pass
Exemple #26
0
def do(args):
    """ Main entry point """
    if "--name" in sys.argv:
        ui.warning("--name is deprecated, use --feed-name instead")
    feed = args.feed
    # Normalize feed path:
    if feed and os.path.exists(feed):
        feed = qisys.sh.to_native_path(feed)
    tc_name = args.name
    qitoolchain.ensure_name_is_valid(tc_name)
    if tc_name in qitoolchain.get_tc_names():
        toolchain = qitoolchain.Toolchain(tc_name)
        ui.info(tc_name, "already exists,", "updating without removing")
    toolchain = qitoolchain.Toolchain(tc_name)
    if feed:
        toolchain.update(feed, branch=args.branch, name=args.feed_name)
    return toolchain
Exemple #27
0
def do(args):
    """ Main entry point """
    if "--name" in sys.argv:
        ui.warning("--name is deprecated, use --feed-name instead")
    feed = args.feed
    # Normalize feed path:
    if feed and os.path.exists(feed):
        feed = qisys.sh.to_native_path(feed)
    tc_name = args.name
    qitoolchain.ensure_name_is_valid(tc_name)
    if tc_name in qitoolchain.get_tc_names():
        toolchain = qitoolchain.Toolchain(tc_name)
        ui.info(tc_name, "already exists,", "updating without removing")
    toolchain = qitoolchain.Toolchain(tc_name)
    if feed:
        toolchain.update(feed, branch=args.branch, name=args.feed_name)
    return toolchain
Exemple #28
0
def configure_local_settings(toc):
    """ Configure local settings for this worktree

    """
    print
    print "Found a worktree in", toc.work_tree
    answer = qibuild.interact.ask_yes_no(
        "Do you want to configure settings for this worktree", default=True)
    if not answer:
        return
    tc_names = qitoolchain.get_tc_names()
    if tc_names:
        print "Found the following toolchains: ", ", ".join(tc_names)
        answer = qibuild.interact.ask_yes_no(
            "Use one of these toolchains by default", default=True)
        if answer:
            default = qibuild.interact.ask_choice(
                tc_names, "Choose a toolchain to use by default")
            if default:
                toc.config.local.defaults.config = default
                toc.save_config()
    answer = qibuild.interact.ask_yes_no(
        "Do you want to use a unique build dir "
        "(mandatory when using Eclipse)",
        default=False)

    build_dir = None
    if answer:
        build_dir = qibuild.interact.ask_string("Path to a build directory")
        build_dir = os.path.expanduser(build_dir)
        full_path = os.path.join(toc.work_tree, build_dir)
        print "Will use", full_path, "as a root for all build directories"
    toc.config.local.build.build_dir = build_dir
    toc.save_config()

    sdk_dir = None
    answer = qibuild.interact.ask_yes_no("Do you want to use a unique SDK dir",
                                         default=False)
    if answer:
        sdk_dir = qibuild.interact.ask_string("Path to a SDK directory")
        sdk_dir = os.path.expanduser(sdk_dir)
        full_path = os.path.join(toc.work_tree, sdk_dir)
        print "Will use", full_path, "as a unique SDK directory"
    toc.config.local.build.sdk_dir = sdk_dir
    toc.save_config()
Exemple #29
0
def configure_local_settings(build_worktree):
    """ Configure local settings for this worktree

    """
    print
    worktree_root = build_worktree.root
    ui.info(ui.green, "::", ui.reset,  "Found a worktree in", worktree_root)
    qibuild_cfg = build_worktree.qibuild_cfg
    answer = qisys.interact.ask_yes_no(
        "Do you want to configure settings for this worktree?",
        default=False)
    if not answer:
        return
    tc_names = qitoolchain.get_tc_names()
    if tc_names:
        ui.info(ui.green, "::", ui.reset,
                "Found the following toolchains: ", ", ".join(tc_names))
        answer = qisys.interact.ask_yes_no(
            "Use one of these toolchains by default",
            default=True)
        if answer:
            default = qisys.interact.ask_choice(tc_names,
                "Choose a toolchain to use by default")
            if default:
                qibuild_cfg.local.defaults.config = default
                qibuild_cfg.write_local_config(build_worktree.qibuild_xml)
    answer = qisys.interact.ask_yes_no(
        "Do you want to use a unique build dir?"
        " (mandatory when using Eclipse)",
        default=False)

    build_dir = None
    if answer:
        build_dir = qisys.interact.ask_string("Path to a build directory")
        build_dir = os.path.expanduser(build_dir)
        full_path = os.path.join(worktree_root, build_dir)
        ui.info(ui.green, "::", ui.reset,
                "Will use", full_path, "as a root for all build directories")
    qibuild_cfg.local.build.build_dir = build_dir
    qibuild_cfg.write_local_config(build_worktree.qibuild_xml)
Exemple #30
0
def do(args):
    """Main entry point

    """
    feed = args.feed
    if feed and not "://" in feed:
        feed = qisys.sh.to_native_path(feed)
    tc_name = args.name

    # Validate the name: must be a valid filename:
    bad_chars = r'<>:"/\|?*'
    for bad_char in bad_chars:
        if bad_char in tc_name:
            mess  = "Invalid toolchain name: '%s'\n" % tc_name
            mess += "A valid toolchain name should not contain any "
            mess += "of the following chars:\n"
            mess += " ".join(bad_chars)
            raise Exception(mess)

    if tc_name == "system":
        raise Exception("'system' is a reserved name")

    build_worktree = None

    if tc_name in qitoolchain.get_tc_names():
        toolchain = qitoolchain.Toolchain(tc_name)
        if feed and toolchain.feed_url != feed:
            ui.warning(tc_name, "already exists but points to a different feed,",
                   "removing previous toolchain and creating a new one")
            toolchain.remove()
        else:
            ui.info(tc_name, "already exists,",
                   "updating without removing")

    toolchain = qitoolchain.Toolchain(tc_name)
    if feed:
        toolchain.update(feed)

    return toolchain
Exemple #31
0
def do(args):
    """Main entry point

    """
    feed = args.feed
    if feed and not "://" in feed:
        feed = qisys.sh.to_native_path(feed)
    tc_name = args.name

    # Validate the name: must be a valid filename:
    bad_chars = r'<>:"/\|?*'
    for bad_char in bad_chars:
        if bad_char in tc_name:
            mess = "Invalid toolchain name: '%s'\n" % tc_name
            mess += "A valid toolchain name should not contain any "
            mess += "of the following chars:\n"
            mess += " ".join(bad_chars)
            raise Exception(mess)

    if tc_name == "system":
        raise Exception("'system' is a reserved name")

    build_worktree = None

    if tc_name in qitoolchain.get_tc_names():
        toolchain = qitoolchain.Toolchain(tc_name)
        if feed and toolchain.feed_url != feed:
            ui.warning(tc_name,
                       "already exists but points to a different feed,",
                       "removing previous toolchain and creating a new one")
            toolchain.remove()
        else:
            ui.info(tc_name, "already exists,", "updating without removing")

    toolchain = qitoolchain.Toolchain(tc_name)
    if feed:
        toolchain.update(feed)

    return toolchain
Exemple #32
0
def configure_local_settings(build_worktree):
    """ Configure local settings for this worktree

    """
    print
    worktree_root = build_worktree.root
    ui.info(ui.green, "::", ui.reset, "Found a worktree in", worktree_root)
    qibuild_cfg = build_worktree.qibuild_cfg
    answer = qisys.interact.ask_yes_no(
        "Do you want to configure settings for this worktree?", default=False)
    if not answer:
        return
    tc_names = qitoolchain.get_tc_names()
    if tc_names:
        ui.info(ui.green, "::", ui.reset, "Found the following toolchains: ",
                ", ".join(tc_names))
        answer = qisys.interact.ask_yes_no(
            "Use one of these toolchains by default", default=True)
        if answer:
            default = qisys.interact.ask_choice(
                tc_names, "Choose a toolchain to use by default")
            if default:
                qibuild_cfg.local.defaults.config = default
                qibuild_cfg.write_local_config(build_worktree.qibuild_xml)
    answer = qisys.interact.ask_yes_no(
        "Do you want to use a unique build dir?"
        " (mandatory when using Eclipse)",
        default=False)

    build_dir = None
    if answer:
        build_dir = qisys.interact.ask_string("Path to a build directory")
        build_dir = os.path.expanduser(build_dir)
        full_path = os.path.join(worktree_root, build_dir)
        ui.info(ui.green, "::", ui.reset, "Will use", full_path,
                "as a root for all build directories")
    qibuild_cfg.local.build.build_dir = build_dir
    qibuild_cfg.write_local_config(build_worktree.qibuild_xml)
def do(args):
    """Main entry point

    """
    feed = args.feed
    tc_name = args.name
    dry_run = args.dry_run

    known_tc_names = qitoolchain.toolchain.get_tc_names()
    if tc_name:
        if not tc_name in known_tc_names:
            mess = "No such toolchain: '%s'\n" % tc_name
            mess += "Known toolchains are: %s" % known_tc_names
            raise Exception(mess)
        if not feed:
            feed = qitoolchain.toolchain.get_tc_feed(tc_name)
            if not feed:
                mess = "Could not find feed for toolchain %s\n" % tc_name
                mess += "Pleas check configuration or specifiy a feed on the command line\n"
                raise Exception(mess)

        LOGGER.info("Updating toolchain %s using %s", tc_name, feed)
        toolchain = qitoolchain.Toolchain(tc_name)
        toolchain.parse_feed(feed, dry_run=dry_run)
    else:
        for tc_name in qitoolchain.get_tc_names():
            tc_feed = qitoolchain.toolchain.get_tc_feed(tc_name)
            if not tc_feed:
                LOGGER.info("No feed found for %s, skipping", tc_name)
                print
                continue
            LOGGER.info("###\n## Updating toolchain %s using %s\n##\n",
                        tc_name, tc_feed)
            toolchain = qitoolchain.Toolchain(tc_name)
            toolchain.parse_feed(tc_feed, dry_run=dry_run)
            print
Exemple #34
0
def do(args):
    """Main entry point

    """
    feed = args.feed
    tc_name = args.name
    dry_run = args.dry_run

    known_tc_names = qitoolchain.toolchain.get_tc_names()
    if tc_name:
        if not tc_name in known_tc_names:
            mess  = "No such toolchain: '%s'\n" % tc_name
            mess += "Known toolchains are: %s" % known_tc_names
            raise Exception(mess)
        if not feed:
            feed = qitoolchain.toolchain.get_tc_feed(tc_name)
            if not feed:
                mess  = "Could not find feed for toolchain %s\n" % tc_name
                mess += "Pleas check configuration or specifiy a feed on the command line\n"
                raise Exception(mess)

        LOGGER.info("Updating toolchain %s using %s", tc_name, feed)
        toolchain = qitoolchain.Toolchain(tc_name)
        toolchain.parse_feed(feed, dry_run=dry_run)
    else:
        for tc_name in qitoolchain.get_tc_names():
            tc_feed = qitoolchain.toolchain.get_tc_feed(tc_name)
            if not tc_feed:
                LOGGER.info("No feed found for %s, skipping", tc_name)
                print
                continue
            LOGGER.info("###\n## Updating toolchain %s using %s\n##\n",
                tc_name, tc_feed)
            toolchain = qitoolchain.Toolchain(tc_name)
            toolchain.parse_feed(tc_feed, dry_run=dry_run)
            print
Exemple #35
0
    if tc_name == "system":
        raise Exception("'system' is a reserved name")

    toc = None

    if args.default:
        try:
            toc = qibuild.toc.toc_open(args.work_tree)
        except qibuild.toc.TocException, e:
            mess = "You need to be in a valid toc worktree to use --default\n"
            mess += "Exception was:\n"
            mess += str(e)
            raise Exception(mess)

    if tc_name in qitoolchain.get_tc_names():
        LOGGER.info(
            "%s already exists, removing previous "
            "toolchain and creating a new one", tc_name)
        toolchain = qitoolchain.Toolchain(tc_name)
        toolchain.remove()

    toolchain = qitoolchain.Toolchain(tc_name)
    if feed:
        toolchain.parse_feed(feed, dry_run=dry_run)

    if args.default:
        toc.config.set_default_config(tc_name)
        toc.save_config()
        LOGGER.info("Now using toolchain %s by default", tc_name)
    else:
    def __init__(self,
                 work_tree,
                 path_hints=None,
                 config=None,
                 qibuild_cfg=None,
                 build_type="Debug",
                 cmake_flags=None,
                 cmake_generator=None,
                 active_projects=None,
                 solve_deps=True):
        """
        Create a new Toc object. Most of the keyargs come directly from
        the command line. (--wortree, --debug, -c, etc.)

        :param work_tree:  see :py:meth:`qibuild.worktree.WorkTree.__init__`
        :param path_hints: see :py:meth:`qibuild.worktree.WorkTree.__init__`
        :param qibuild_cfg: a  :py:class:`qibuild.config.QiBuildConfig` instance
                            if not given, a new one will be created
        :param build_type: a build type, could be debug or release
                           (defaults to debug)
        :param cmake_flags:     optional additional cmake flags
        :param cmake_generator: optional cmake generator
                         (defaults to Unix Makefiles)
        :param active_projects: the projects excplicitely specified by user
        """
        WorkTree.__init__(self, work_tree, path_hints=path_hints)
        # The local config file in which to write
        self.config_path = os.path.join(self.work_tree, ".qi", "qibuild.xml")

        # When you are running toc actions for a qibuild project, sometimes
        # a Toc object is created on the fly (Using toc_open with a non
        # empty path_hints) variable.
        # In this case, the .qi directory may not even exists, nor the
        # .qi directory, so create it:
        if not os.path.exists(self.config_path):
            to_create = os.path.dirname(self.config_path)
            qibuild.sh.mkdir(to_create, recursive=True)
            with open(self.config_path, "w") as fp:
                fp.write("<qibuild />\n")
        # Perform format conversion if necessary
        handle_old_qibuild_cfg(self.work_tree)
        handle_old_qibuild_xml(self.work_tree)

        # Handle config:
        if not qibuild_cfg:
            self.config = qibuild.config.QiBuildConfig(config)
            self.config.read()
        else:
            self.config = config
        self.config.read_local_config(self.config_path)
        self.active_config = self.config.active_config
        # Special case if "--system" was used:
        if config == "system":
            self.active_config = None

        self.build_type = build_type
        if not self.build_type:
            self.build_type = "Debug"

        self.cmake_generator = cmake_generator
        self.build_folder_name = None

        # Set build environment
        envsetter = qibuild.envsetter.EnvSetter()
        envsetter.read_config(self.config)
        self.build_env = envsetter.get_build_env()

        # List of objects of type qibuild.project.Project,
        # this is updated using WorkTree.buildable_projects
        self.projects = list()

        # The list of projects the user asked for from command
        # line.
        # Set by toc_open()
        if not active_projects:
            self.active_projects = list()
        else:
            self.active_projects = active_projects
        self.solve_deps = solve_deps

        # Set cmake generator if user has not set if in Toc ctor:
        if not self.cmake_generator:
            self.cmake_generator = self.config.cmake.generator
            if not self.cmake_generator:
                self.cmake_generator = "Unix Makefiles"

        # Read the current config, create toolchain and pacakges object
        # if necessary
        self.packages = list()
        self.toolchain = None
        if self.active_config is not None:
            if self.active_config in qitoolchain.get_tc_names():
                self.toolchain = qitoolchain.Toolchain(self.active_config)
                self.packages = self.toolchain.packages
            else:
                # The config does not match a toolchain
                local_dir = os.path.join(self.work_tree, ".qi")
                local_cmake = os.path.join(local_dir,
                                           "%s.cmake" % self.active_config)
                if not os.path.exists(local_cmake):
                    mess = """Invalid configuration {active_config}
 * No toolchain named {active_config}. Known toolchains are:
    {tc_names}
 * No custom cmake file for config {active_config} found.
   (looked in {local_cmake})
"""
                    mess = mess.format(active_config=self.active_config,
                                       local_cmake=local_cmake,
                                       tc_names=qitoolchain.get_tc_names())
                    if self.active_config == self.config.local.defaults.config:
                        mess += """Note: this is your default config
You may want to run:
 * `qibuild init --force`  (to re-initialize your worktree and not use any toolchain)
 * `qibuild init --force` --config=<config> (to use a different toolchain by default)
 """
                        raise WrongDefaultException(mess)
                    else:
                        raise Exception(mess)

        # Useful vars to cope with Visual Studio quirks
        self.using_visual_studio = "Visual Studio" in self.cmake_generator
        self.vc_version = self.cmake_generator.split()[-1]

        # The actual list of cmake flags we are going to use
        # will be computed during self.update_projects
        # Right now, we will just store the flags passed in ctor
        # in self.user_cmake_flags, to be sure they are always added
        # at the end of the list of flags
        if cmake_flags:
            self.user_cmake_flags = cmake_flags[:]
        else:
            self.user_cmake_flags = list()

        # Finally, update the build configuration of all the projects
        # (this way we are sure that the build configuration is the same for
        # every project)
        self.update_projects()
Exemple #37
0
        raise Exception(mess)

    toc_error = None
    toc = None
    try:
        toc = qibuild.toc.toc_open(args.work_tree)
    except qibuild.toc.TocException, e:
        toc_error = e

    if args.default and not toc:
        mess = "You need to be in a valid toc worktree to use --default\n"
        mess += "Exception was:\n"
        mess += str(toc_error)
        raise Exception(mess)

    if tc_name in qitoolchain.get_tc_names():
        LOGGER.info("%s already exists, creating a new one", tc_name)
        toolchain = qitoolchain.Toolchain(tc_name)
        toolchain.remove()

    toolchain = qitoolchain.Toolchain(tc_name)
    if feed:
        toolchain.parse_feed(feed, dry_run=dry_run)

    cmake_generator = args.cmake_generator
    qibuild_cfg = qibuild.config.QiBuildConfig()
    qibuild_cfg.read()
    config = qibuild.config.Config()
    config.name = tc_name
    if cmake_generator:
        config.cmake.generator = cmake_generator
Exemple #38
0
    def __init__(self, worktree,
            config=None,
            qibuild_cfg=None,
            build_type="Debug",
            cmake_flags=None,
            profiles=None,
            cmake_generator=None):
        """
        Create a new Toc object. Most of the keyargs come directly from
        the command line. (--worktree, --debug, -c, etc.)

        :param worktree:  see :py:meth:`qisys.worktree.WorkTree.__init__`
        :param qibuild_cfg: a  :py:class:`qibuild.config.QiBuildConfig` instance
                            if not given, a new one will be created
        :param build_type: a build type, could be debug or release
                           (defaults to debug)
        :param cmake_flags:     optional additional cmake flags
        :param cmake_generator: optional cmake generator
                         (defaults to Unix Makefiles)
        """
        # Set during qibuild.cmdparse.projects_from_args and
        # used by get_sdk_dirs().
        # Why? Assume you have hello depending on world, which is both
        # a project and a pacakge.
        # qc hello  -> get_sdk_dirs('hello') = []
        # qc world hello -> get_sdk_dirs('hello') = ["world/build/sdk"]
        self.active_projects = list()
        self.worktree = worktree
        # The local config file in which to write
        dot_qi = os.path.join(self.worktree.root, ".qi")
        qisys.sh.mkdir(dot_qi)
        self.config_path =  os.path.join(dot_qi, "qibuild.xml")
        if not os.path.exists(self.config_path):
            with open(self.config_path, "w") as fp:
                fp.write("<qibuild />\n")

        # Perform format conversion if necessary
        handle_old_qibuild_cfg(self.worktree.root)
        handle_old_qibuild_xml(self.worktree.root)

        # Handle config:
        if not qibuild_cfg:
            self.config = qibuild.config.QiBuildConfig(config)
            self.config.read()
        else:
            self.config = config
        self.config.read_local_config(self.config_path)
        self.active_config = self.config.active_config
        # Special case if "--system" was used:
        if config == "system":
            self.active_config = None

        self.local_cmake = None
        if self.active_config:
            local_dir = os.path.join(worktree.root, ".qi")
            local_cmake = os.path.join(local_dir, "%s.cmake" % self.active_config)
            if os.path.exists(local_cmake):
                self.local_cmake = local_cmake

        self.build_type = build_type
        if not self.build_type:
            self.build_type = "Debug"

        self.cmake_generator   = cmake_generator
        self.build_folder_name = None

        # Set build environment
        envsetter = qisys.envsetter.EnvSetter()
        envsetter.read_config(self.config)
        self.build_env =  envsetter.get_build_env()

        # List of objects of type qibuild.project.Project,
        # this is updated using WorkTree.buildable_projects
        self.projects          = list()

        # Set cmake generator if user has not set if in Toc ctor:
        if not self.cmake_generator:
            self.cmake_generator = self.config.cmake.generator
            if not self.cmake_generator:
                self.cmake_generator = "Unix Makefiles"

        # Read the current config, create toolchain and pacakges object
        # if necessary
        self.packages = list()
        self.toolchain = None
        if self.active_config is not None:
            if self.active_config in qitoolchain.get_tc_names():
                self.toolchain = qitoolchain.Toolchain(self.active_config)
                self.packages  = self.toolchain.packages
            else:
                # The config does not match a toolchain
                local_dir = os.path.join(self.worktree.root, ".qi")
                local_cmake = os.path.join(local_dir, "%s.cmake" % self.active_config)
                if not os.path.exists(local_cmake):
                    mess  = """Invalid configuration {active_config}
 * No toolchain named {active_config}. Known toolchains are:
    {tc_names}
 * No custom cmake file for config {active_config} found.
   (looked in {local_cmake})
"""
                    mess =  mess.format(active_config=self.active_config,
                                local_cmake = local_cmake,
                                tc_names = qitoolchain.get_tc_names())
                    if self.active_config == self.config.local.defaults.config:
                        mess += """Note: this is your default config
You may want to run:

  qibuild init --force -w {worktree.root}
(to re-initialize your worktree and not use any toolchain)

  qibuild init --force -w {worktree.root} --config=<config>
(to use a different toolchain by default)
 """
                        mess = mess.format(worktree=self.worktree)
                        raise WrongDefaultException(mess)
                    else:
                        raise Exception(mess)
        if self.toolchain:
            self.packages = self.toolchain.packages
        else:
            self.packages = list()

        # Useful vars to cope with Visual Studio quirks
        self.using_visual_studio = "Visual Studio" in self.cmake_generator
        self.vc_version = self.cmake_generator.split()[-1]

        # The actual list of cmake flags we are going to use
        # will be computed during self.update_projects
        # Right now, we will just store the flags passed in ctor
        # in self.user_cmake_flags, to be sure they are always added
        # at the end of the list of flags
        if cmake_flags:
            self.user_cmake_flags = cmake_flags[:]
        else:
            self.user_cmake_flags = list()

        self.profiles = list()
        self.apply_profiles(profiles)

        # Finally, update the build configuration of all the projects
        # (this way we are sure that the build configuration is the same for
        # every project)
        self.update_projects()
 def test_create_toolchain(self):
     qitoolchain.Toolchain("foo")
     self.assertEquals(qitoolchain.get_tc_names(), ["foo"])
 def test_remove_toolchain(self):
     tc = qitoolchain.Toolchain("foo")
     self.assertEquals(qitoolchain.get_tc_names(), ["foo"])
     tc.remove()
     self.assertEquals(qitoolchain.get_tc_names(), list())
Exemple #41
0
 def test_remove_toolchain(self):
     tc = qitoolchain.Toolchain("foo")
     self.assertEquals(qitoolchain.get_tc_names(), ["foo"])
     tc.remove()
     self.assertEquals(qitoolchain.get_tc_names(), list())
Exemple #42
0
 def test_create_toolchain(self):
     qitoolchain.Toolchain("foo")
     self.assertEquals(qitoolchain.get_tc_names(), ["foo"])
Exemple #43
0
    def __init__(self, work_tree,
            path_hints=None,
            config=None,
            build_type="debug",
            cmake_flags=None,
            cmake_generator=None,
            active_projects=None,
            solve_deps=True):
        """
        Create a new Toc object. Most of the keyargs come directly from
        the command line. (--wortree, --debug, -c, etc.)

        :param work_tree:  see :py:meth:`qibuild.worktree.WorkTree.__init__`
        :param path_hints: see :py:meth:`qibuild.worktree.WorkTree.__init__`
        :param build_type: a build type, could be debug or release
                           (defaults to debug)
        :param cmake_flags:     optional additional cmake flags
        :param cmake_generator: optional cmake generator
                         (defaults to Unix Makefiles)
        :param active_projects: the projects excplicitely specified by user
        """
        WorkTree.__init__(self, work_tree, path_hints=path_hints)
        # The local config file in which to write
        self.config_path = os.path.join(self.work_tree, ".qi", "qibuild.xml")

        # When you are running toc actions for a qibuild project, sometimes
        # a Toc object is created on the fly (Using toc_open with a non
        # empty path_hints) variable.
        # In this case, the .qi directory may not even exists, nor the
        # .qi directory, so create it:
        if not os.path.exists(self.config_path):
            to_create = os.path.dirname(self.config_path)
            qibuild.sh.mkdir(to_create, recursive=True)
            with open(self.config_path, "w") as fp:
                fp.write("<qibuild />\n")
        # Perform format conversion if necessary
        handle_old_qibuild_cfg(self.work_tree)
        handle_old_qibuild_xml(self.work_tree)

        # Handle config:
        self.config = qibuild.config.QiBuildConfig(config)
        self.config.read()
        self.config.read_local_config(self.config_path)
        self.active_config = self.config.active_config

        self.build_type = build_type
        if not self.build_type:
            self.build_type = "debug"

        # The cmake flags set by the user will always be added
        # to the actual cmake flags used by the Toc oject,
        # but we may add other flags when using a toolchain.
        # see self.update_cmake_flags()
        self.cmake_flags       = list()
        self.cmake_generator   = cmake_generator
        self.build_folder_name = None

        # Set build environment
        envsetter = qibuild.envsetter.EnvSetter()
        envsetter.read_config(self.config)
        self.build_env =  envsetter.get_build_env()

        # List of objects of type qibuild.project.Project,
        # this is updated using WorkTree.buildable_projects
        self.projects          = list()

        # The list of projects the user asked for from command
        # line.
        # Set by toc_open()
        if not active_projects:
            self.active_projects = list()
        else:
            self.active_projects = active_projects
        self.solve_deps = solve_deps

        # Set cmake generator if user has not set if in Toc ctor:
        if not self.cmake_generator:
            self.cmake_generator = self.config.cmake.generator
            if not self.cmake_generator:
                self.cmake_generator = "Unix Makefiles"

        # Read the current config, create toolchain and pacakges object
        # if necessary
        self.packages = list()
        self.toolchain = None
        if self.active_config is not None:
            if self.active_config in qitoolchain.get_tc_names():
                self.toolchain = qitoolchain.Toolchain(self.active_config)
                self.packages  = self.toolchain.packages
            else:
                # The config does not match a toolchain
                local_dir = os.path.join(self.work_tree, ".qi")
                local_cmake = os.path.join(local_dir, "%s.cmake" % self.active_config)
                if not os.path.exists(local_cmake):
                    mess  = """Invalid configuration {active_config}
 * No toolchain named {active_config}. Known toolchains are:
    {tc_names}
 * No custom cmake file for config {active_config} found.
   (looked in {local_cmake})
"""
                    raise TocException(mess.format(active_config=self.active_config,
                        local_cmake = local_cmake,
                        tc_names = qitoolchain.get_tc_names()))

        # Useful vars to cope with Visual Studio quirks
        self.using_visual_studio = "Visual Studio" in self.cmake_generator
        self.vc_version = self.cmake_generator.split()[-1]

        # The actual list of cmake flags we are going to use
        # will be computed during self.configure_project.
        # Right now, we will just store the flags passed in ctor
        # in self.user_cmake_flags, to be sure they are always added
        # at the end of the list of flags
        if cmake_flags:
            self.user_cmake_flags = cmake_flags[:]
        else:
            self.user_cmake_flags = list()

        # Finally, update the build configuration of all the projects
        # (this way we are sure that the build configuration is the same for
        # every project)
        self.update_projects()