Exemple #1
0
def do(args):
    """"Create a new project """
    # Try to open a worktree.
    # If not, ask the user if he wants to create one:
    qiwt = None
    try:
        qiwt = qibuild.worktree_open(args.work_tree)
    except qibuild.worktree.WorkTreeException:
        if qibuild.interact.ask_yes_no("Warning, no worktree found. Create one"):
            qibuild.run_action("qibuild.actions.init", ["--interactive"])
            qiwt = qibuild.worktree_open(args.work_tree)

    # Module Name can be Capitalized.
    # Project Name must be lowered.
    project_name = args.project_name.lower()
    module_name  = args.project_name
    if qiwt:
        project_path = os.path.join(qiwt.work_tree, project_name)
    else:
        project_path = os.path.join(os.getcwd(), project_name)

    if os.path.exists(project_path):
        raise Exception("%s already exists" % project_path)
    os.mkdir(project_path)
    copy_helper(module_name, project_path)


    if args.git:
        qibuild.command.call(["git", "init"], cwd=project_path)
        with open(os.path.join(project_path, ".gitignore"), "w") as fp:
            fp.write("build-*\n")
        qibuild.command.call(["git" , "add" , "."], cwd=project_path)
        qibuild.command.call(["git" , "commit" , "-m" , "initial commit"], cwd=project_path)

    LOGGER.info("New project initialized in %s", project_path)
Exemple #2
0
def do(args):
    """ Main method """
    print "`qitoolchain status` is deprecated"
    print "use `qitoolchain list` or `qitoolchain info` instead"
    if args.list:
        qibuild.run_action("qitoolchain.actions.list", forward_args=args)
    else:
        qibuild.run_action("qitoolchain.actions.info", forward_args=args)
def do(args):
    """ Main method """
    print "`qitoolchain status` is deprecated"
    print "use `qitoolchain list` or `qitoolchain info` instead"
    if args.list:
        qibuild.run_action("qitoolchain.actions.list",
            forward_args=args)
    else:
        qibuild.run_action("qitoolchain.actions.info",
            forward_args=args)
Exemple #4
0
def do(args):
    """Main entry point"""
    fail = list()
    qiwt = qibuild.worktree_open(args.work_tree)
    toc  = qibuild.toc_open(args.work_tree, args)

    manifest = toc.config.local.manifest
    if manifest:
        try:
            qibuild.run_action("qisrc.actions.fetch",
                args=[manifest.url],
                forward_args=args)
        except Exception, e:
            mess  = "Could not run qisrc fetch\n"
            mess += "Error was: %s\n" % e
            LOGGER.warning(mess)
Exemple #5
0
def do(args):
    """Main entry point"""
    fail = list()
    qiwt = qibuild.worktree_open(args.work_tree)
    toc = qibuild.toc_open(args.work_tree, args)

    manifest = toc.config.local.manifest
    if manifest:
        try:
            qibuild.run_action("qisrc.actions.fetch",
                               args=[manifest.url],
                               forward_args=args)
        except Exception, e:
            mess = "Could not run qisrc fetch\n"
            mess += "Error was: %s\n" % e
            LOGGER.warning(mess)
def _do_package(args, project_name, destdir, debug):
    """ Helper function used on windows.
    We need both debug and release in the package,
    otherwize the package is not usable to compile
    something else

    """
    build_type= ""
    if debug:
        build_type = "debug"
        build_args = ["--debug",  project_name]
    else:
        build_type = "release"
        build_args = ["--release", project_name]

    ui.info(ui.green, "> Configuring ... (%s)" % build_type)
    qibuild.run_action("qibuild.actions.configure", build_args + ["--no-clean-first"],
        forward_args=args)
    print
    ui.info(ui.green, "> Building ... (%s)" % build_type)
    qibuild.run_action("qibuild.actions.make", build_args + ["--no-fix-shared-libs"],
        forward_args=args)
    ui.info(ui.green, "> Installing ... (%s)" % build_type)
    qibuild.run_action("qibuild.actions.install", build_args + [destdir],
        forward_args=args)
    print
 def test_convert_no_cmake(self):
     src_no_cmake = os.path.join(self.tmp, "src", "no_cmake")
     qibuild.sh.install(
         os.path.join(self.test_dir, "src", "no_cmake"),
         src_no_cmake,
         quiet=True)
     qibuild.run_action("qibuild.actions.convert",
         [src_no_cmake, "--go"])
     qibuild.run_action("qibuild.actions.init",
         ["--work-tree", self.tmp])
     qibuild.run_action("qibuild.actions.configure",
         ["--work-tree", self.tmp, "no_cmake"])
     qibuild.run_action("qibuild.actions.make",
         ["--work-tree", self.tmp, "no_cmake"])
 def test_convert_1_12(self):
     src_1_12 = os.path.join(self.tmp, "src", "1.12")
     qibuild.sh.install(
         os.path.join(self.test_dir, "src", "1.12"),
         src_1_12,
         quiet=True)
     qibuild.run_action("qibuild.actions.convert",
         [src_1_12, "--go"])
     qibuild.run_action("qibuild.actions.init",
         ["--work-tree", self.tmp])
     qibuild.run_action("qibuild.actions.configure",
         ["--work-tree", self.tmp, "foo_1_12"])
     qibuild.run_action("qibuild.actions.make",
         ["--work-tree", self.tmp, "foo_1_12"])
 def test_convert_pure_cmake(self):
     src_pure_cmake = os.path.join(self.tmp, "src", "pure_cmake")
     qibuild.sh.install(
         os.path.join(self.test_dir, "src", "pure_cmake"),
         src_pure_cmake,
         quiet=True)
     worktree = qisrc.worktree.create(self.tmp)
     worktree.add_project(src_pure_cmake)
     qibuild.run_action("qibuild.actions.convert",
         [src_pure_cmake, "--go"])
     qibuild.run_action("qibuild.actions.init",
         ["--work-tree", self.tmp])
     qibuild.run_action("qibuild.actions.configure",
         ["--work-tree", self.tmp, "pure_cmake"])
     qibuild.run_action("qibuild.actions.make",
         ["--work-tree", self.tmp, "pure_cmake"])
Exemple #10
0
def do(args):
    """Main entry point

    """
    toc = qibuild.toc.toc_open(args.work_tree)
    if args.url:
        manifest_url = args.url
    else:
        manifest = toc.config.local.manifest
        if manifest is None:
            mess = "Could not find URL fo fetch from.\n"
            mess += "Here is what you can do:\n"
            mess += " - specify an URL from the command line\n"
            mess += " - edit %s to have: \n\n" % toc.config_path
            mess += """<qibuild>
            <manifest
                url = ftp://example.com/foo.manifest
            />
</qibuild>
"""
            raise Exception(mess)
        manifest_url = manifest.url

    qiwt = qibuild.worktree_open(args.work_tree)

    projects = qisrc.parse_manifest(manifest_url)
    for (project_name, project_url) in projects.iteritems():
        if project_name not in qiwt.git_projects.keys():
            qibuild.run_action("qisrc.actions.add",
                               [project_url, project_name])
        else:
            p_path = qiwt.git_projects[project_name]
            LOGGER.info("Found project %s, skipping", project_name)

    # Everything went fine, store the manifest URL for later use:
    toc.config.set_manifest_url(manifest_url)
    toc.save_config()
Exemple #11
0
def do(args):
    """Main entry point

    """
    toc = qibuild.toc.toc_open(args.work_tree)
    if args.url:
        manifest_url = args.url
    else:
        manifest = toc.config.local.manifest
        if manifest is None:
            mess  = "Could not find URL fo fetch from.\n"
            mess += "Here is what you can do:\n"
            mess += " - specify an URL from the command line\n"
            mess += " - edit %s to have: \n\n" % toc.config_path
            mess += """<qibuild>
            <manifest
                url = ftp://example.com/foo.manifest
            />
</qibuild>
"""
            raise Exception(mess)
        manifest_url = manifest.url

    qiwt = qibuild.worktree_open(args.work_tree)

    projects = qisrc.parse_manifest(manifest_url)
    for (project_name, project_url) in projects.iteritems():
        if project_name not in qiwt.git_projects.keys():
            qibuild.run_action("qisrc.actions.add", [project_url, project_name])
        else:
            p_path = qiwt.git_projects[project_name]
            LOGGER.info("Found project %s, skipping", project_name)

    # Everything went fine, store the manifest URL for later use:
    toc.config.set_manifest_url(manifest_url)
    toc.save_config()
Exemple #12
0
def _do_package(args, project_name, destdir, debug):
    """ Helper function used on windows.
    We need both debug and release in the package,
    otherwize the package is not usable to compile
    something else

    """
    if debug:
        build_args = ["--debug",  project_name]
    else:
        build_args = ["--release", project_name]

    qibuild.run_action("qibuild.actions.configure", build_args + ["--no-clean-first"],
        forward_args=args)
    qibuild.run_action("qibuild.actions.make", build_args,
        forward_args=args)
    qibuild.run_action("qibuild.actions.install", build_args + [destdir],
        forward_args=args)
def do(args):
    """Main entry point"""
    toc = qibuild.toc_open(args.worktree, args)
    config = toc.active_config
    if not args.project:
        project_name = qibuild.project.project_from_cwd()
    else:
        project_name = args.project
    project = toc.get_project(project_name)
    package_name = get_package_name(project,
        version=args.version, config=config)
    destdir = os.path.join(toc.worktree.root, "package")
    destdir = os.path.join(destdir, package_name)

    if args.internal:
        args.cmake_flags.append('QI_INSTALL_INTERNAL=ON')

    if sys.platform.startswith("win") and not args.runtime:
        # Ignore the --release flag and always build in debug and in release:
        _do_package(args, project_name, destdir, debug=True)
        _do_package(args, project_name, destdir, debug=False)
    else:
        ui.info(ui.green, "> Configuring ...")
        qibuild.run_action("qibuild.actions.configure", [project_name, "--no-clean-first"],
            forward_args=args)
        print
        ui.info(ui.green, "> Building ...")
        qibuild.run_action("qibuild.actions.make", [project_name, "--no-fix-shared-libs"],
            forward_args=args)
        print
        ui.info(ui.green, "> Installing ...")
        qibuild.run_action("qibuild.actions.install", [project_name, destdir],
            forward_args=args)
        print

    if args.compress:
        ui.info(ui.green, "> Compressing package ...")
        archive = qibuild.archive.compress(destdir, algo="zip", quiet=True)
        ui.info(ui.green, "Package generated in", ui.reset, ui.bold, archive)
        # Now, clean the destdir.
        qibuild.sh.rm(destdir)
        return archive
    else:
        return destdir
def _do_package(args, project_name, destdir, debug):
    """ Helper function used on windows.
    We need both debug and release in the package,
    otherwize the package is not usable to compile
    something else

    """
    if debug:
        build_args = ["--debug", project_name]
    else:
        build_args = ["--release", project_name]

    qibuild.run_action("qibuild.actions.configure",
                       build_args + ["--no-clean-first"],
                       forward_args=args)
    qibuild.run_action("qibuild.actions.make", build_args, forward_args=args)
    qibuild.run_action("qibuild.actions.install",
                       build_args + [destdir],
                       forward_args=args)
def do(args):
    """Main entry point"""
    toc = qibuild.toc_open(args.work_tree, args)
    config = toc.active_config
    if not args.project:
        project_name = qibuild.toc.project_from_cwd()
    else:
        project_name = args.project
    project = toc.get_project(project_name)
    package_name = get_package_name(project,
                                    version=args.version,
                                    config=config)
    destdir = os.path.join(toc.work_tree, "package")
    destdir = os.path.join(destdir, package_name)

    if args.internal:
        args.cmake_flags.append('QI_INSTALL_INTERNAL=ON')

    if sys.platform.startswith("win") and not args.runtime:
        # Ignore the --release flag and always build in debug and in release:
        _do_package(args, project_name, destdir, debug=True)
        _do_package(args, project_name, destdir, debug=False)
    else:
        qibuild.run_action("qibuild.actions.configure",
                           [project_name, "--no-clean-first"],
                           forward_args=args)
        qibuild.run_action("qibuild.actions.make", [project_name],
                           forward_args=args)
        qibuild.run_action("qibuild.actions.install", [project_name, destdir],
                           forward_args=args)

    if args.compress:
        LOGGER.info("Compressing package")
        archive = qibuild.archive.zip(destdir)
        LOGGER.info("Package generated in %s", archive)
        # Now, clean the destdir.
        qibuild.sh.rm(destdir)
        return archive
    else:
        return destdir
Exemple #16
0
def do(args):
    """Main entry point"""
    toc = qibuild.toc_open(args.work_tree, args)
    config = toc.active_config
    if not args.project:
        project_name = qibuild.toc.project_from_cwd()
    else:
        project_name = args.project
    project = toc.get_project(project_name)
    package_name = get_package_name(project,
        version=args.version, config=config)
    destdir = os.path.join(toc.work_tree, "package")
    destdir = os.path.join(destdir, package_name)

    if args.internal:
        args.cmake_flags.append('QI_INSTALL_INTERNAL=ON')

    if sys.platform.startswith("win") and not args.runtime:
        # Ignore the --release flag and always build in debug and in release:
        _do_package(args, project_name, destdir, debug=True)
        _do_package(args, project_name, destdir, debug=False)
    else:
        qibuild.run_action("qibuild.actions.configure", [project_name, "--no-clean-first"],
            forward_args=args)
        qibuild.run_action("qibuild.actions.make", [project_name],
            forward_args=args)
        qibuild.run_action("qibuild.actions.install", [project_name, destdir],
            forward_args=args)


    if args.compress:
        LOGGER.info("Compressing package")
        archive = qibuild.archive.zip(destdir)
        LOGGER.info("Package generated in %s", archive)
        # Now, clean the destdir.
        qibuild.sh.rm(destdir)
        return archive
    else:
        return destdir
Exemple #17
0
def do(args):
    """Main entry point """
    toc = qibuild.toc.toc_open(args.worktree, args)
    if not args.project:
        project_name = qibuild.project.project_from_cwd()
    else:
        project_name = args.project

    project = toc.get_project(project_name)
    if not os.path.exists(project.build_directory):
        ui.error("""It looks like your project has not been configured yet
(The build directory: '%s' does not exists)""" %
        project.build_directory)
        answer = qibuild.interact.ask_yes_no(
            "Do you want me to run qibuild configure for you",
            default=True)
        if not answer:
            sys.exit(2)
        else:
            qibuild.run_action("qibuild.actions.configure",
                [project.name, "--config", toc.active_config])

    error_message = "Could not open project %s\n" % project_name
    qibuild_cfg = qibuild.config.QiBuildConfig(user_config=toc.active_config)
    qibuild_cfg.read()
    qibuild_cfg.read_local_config(toc.config_path)
    ide = get_ide(qibuild_cfg)
    if not ide:
        return

    if ide.name == "Visual Studio":
        sln_files = glob.glob(project.build_directory + "/*.sln")
        if len(sln_files) != 1:
            raise Exception(error_message + "Expecting only one sln, got %s" % sln_files)
        print "starting VisualStudio:"
        print "%s %s" % ("start", sln_files[0])
        subprocess.Popen(["start", sln_files[0]], shell=True)
        return

    if ide.name == "Xcode":
        projs = glob.glob(project.build_directory + "/*.xcodeproj")
        if len(projs) == 0:
            raise Exception(error_message +
                "Do you have called qibuild configure with --cmake-generator=Xcode?")
        if len(projs) > 1:
            raise Exception(error_message +
                "Expecting only one xcode project file, got %s" % projs)
        print "starting Xcode:"
        print "%s %s" % ("open", projs[0])
        subprocess.Popen(["open", projs[0]])
        return

    if ide.name == "QtCreator":
        ide_path = ide.path
        if not ide_path:
            ide_path = 'qtcreator'
        cmake_list = os.path.join(project.directory, "CMakeLists.txt")
        if not os.access(ide_path, os.X_OK):
            mess  = "Invalid configuration dectected!\n"
            mess += "QtCreator path (%s) is not a valid path\n" % ide_path
            mess += "Please run `qibuild config --wizard\n"
            raise Exception(mess)
        print "starting QtCreator:"
        print ide_path, cmake_list
        subprocess.Popen([ide_path, cmake_list])
        return

    # Not supported (yet) IDE:
    mess  = "Invalid ide: %s\n" % ide.name
    mess += "Supported IDES are: %s" % ", ".join(SUPPORTED_IDES)
    raise Exception(mess)
 def _run_action(self, action, *args):
     qibuild.run_action("qibuild.actions.%s" % action, args,
         forward_args=self.args)
 def _run_action(self, action, *args):
     qibuild.run_action("qibuild.actions.%s" % action,
                        args,
                        forward_args=self.args)