def do(args): """ Main entry point """ force_rm = args.force_remove tc = qitoolchain.get_toolchain(args.name) ui.info(ui.green, "Removing toolchain", ui.blue, tc.name) tc.remove(force_remove=force_rm) ui.info(ui.green, "done")
def configure_qtcreator(qibuild_cfg): """ Configure QtCreator """ ide = qibuild.config.IDE() ide.name = "QtCreator" build_env = qibuild.config.get_build_env() qtcreator_path = qibuild.command.find_program("qtcreator", env=build_env) if qtcreator_path: ui.info(ui.green, "::", ui.reset, "Found QtCreator:", qtcreator_path) mess = "Do you want to use qtcreator from %s ?\n" % qtcreator_path mess += "Answer 'no' if you installed qtcreator from Nokia's installer" answer = qibuild.interact.ask_yes_no(mess, default=True) if not answer: qtcreator_path = None else: ui.warning("QtCreator not found") if not qtcreator_path: qtcreator_path = qibuild.interact.ask_program( "Please enter full qtcreator path") if not qtcreator_path: ui.warning("Not adding config for QtCreator", "qibuild open will not work", sep="\n") return ide.path = qtcreator_path qibuild_cfg.add_ide(ide)
def ask_choice(choices, input_text): """Ask the user to choose from a list of choices """ ui.info(ui.green, "::", ui.reset, input_text) for i, choice in enumerate(choices): if i == 0: choice += " \t(default)" ui.info(" ", ui.blue, str(i+1), ui.reset, choice) keep_asking = True res = None while keep_asking: try: answer = read_input() except KeyboardInterrupt: break if not answer: return choices[0] try: index = int(answer) except ValueError: print "Please enter number" continue if index not in range(1, len(choices)+1): print "%i is out of range" % index continue res = choices[index-1] keep_asking = False return res
def clone_project(worktree, url, src=None, branch=None, remote="origin", skip_if_exists=False): """ Add a project to a worktree given its url. If src is not given, it will be guessed from the url If skip_if_exists is False, an error message will be raised if the project already exists """ should_add = True if not src: src = url.split("/")[-1].replace(".git", "") if os.path.isabs(src): src = os.path.relpath(worktree.root, src) src = qibuild.sh.to_posix_path(src) project = worktree.get_project(src, raises=False) if project: if not skip_if_exists: mess = "Could not add project from %s in %s\n" % (url, src) mess += "This path is already registered for worktree in %s\n" % worktree.root raise Exception(mess) else: if os.path.exists(project.path): ui.debug("Found project in %s, skipping" % src) return # Some one erase the project manually without telling qiworktree should_add = False path = os.path.join(worktree.root, src) path = qibuild.sh.to_native_path(path) if os.path.exists(path): if skip_if_exists: if qisrc.git.is_submodule(path): ui.warning("erasing submodule: ", path) qibuild.sh.rm(path) else: ui.debug("Adding project in %s", src) worktree.add_project(src) return else: mess = "Could not add project from %s in %s\n" % (url, src) mess += "This path already exists\n" raise Exception(mess) ui.info(ui.green, "Git clone: %s -> %s" % (url, path)) dirname = os.path.dirname(path) qibuild.sh.mkdir(dirname, recursive=True) git = qisrc.git.Git(path) if branch: git.clone(url, "-b", branch, "-o", remote) else: git.clone(url, "-o", remote) if should_add: worktree.add_project(path)
def build(src, dest, opts): """ Build a doxygen project configure() should have been called first """ ui.info(ui.green, "Building doxygen", src) cmd = ["doxygen", "Doxyfile.qidoc"] qibuild.command.call(cmd, cwd=src) build_html = os.path.join(src, "build-doc", "html") qibuild.sh.install(build_html, dest, quiet=True)
def do(args): """ Remove a project from a toolchain - Check that there is a current toolchain - Remove the package from the toolchain """ package_name = args.package_name tc_name = qitoolchain.toolchain_name_from_args(args) tc = qitoolchain.get_toolchain(tc_name) ui.info(ui.green, "Removing package", ui.blue, package_name, ui.green, "from toolchain", ui.blue, tc.name) tc.remove_package(package_name)
def init_worktree(worktree, manifest_location, setup_review=True): """ (re)-intianlize a worktree given a manifest location. Clonie any missing repository, set the correct remote and tracking branch on every repository :param setup_review: Also set up the projects for review """ errors = list() manifest = qisrc.manifest.load(manifest_location) if not manifest.projects: return project_count = len(manifest.projects) ui.info(ui.green, "Initializing worktree ...") setup_ok = True for i, project in enumerate(manifest.projects): ui.info( ui.green, "*", ui.reset, "(%2i/%2i)" % (i+1, project_count), ui.blue, project.name) # Use the same branch for the project as the branch # for the manifest, unless explicitely set: p_revision = project.revision p_url = project.fetch_url p_remote = project.remote p_src = project.path clone_project(worktree, p_url, src=p_src, branch=p_revision, remote=p_remote, skip_if_exists=True) wt_project = worktree.get_project(p_src) p_path = wt_project.path if project.review and setup_review and setup_ok: worktree.set_project_review(p_src, True) # If setup failed once, no point in trying for every project setup_ok = qisrc.review.setup_project(p_path, project.name, project.review_url, p_revision) git = qisrc.git.Git(p_path) git.set_remote(p_remote, p_url) git.set_tracking_branch(p_revision, p_remote) cur_branch = git.get_current_branch() if cur_branch != p_revision: if not cur_branch: ui.warning("Project", project.name, "is on a detached HEAD", "but should be on", p_revision) else: ui.warning("Project", project.name, "is on", cur_branch, "but should be on", p_revision) worktree.set_git_project_config(p_src, p_remote, p_revision) if not setup_ok: qisrc.review.warn_gerrit()
def ask_string(question, default=None): """Ask the user to enter something. Returns what the user entered """ if default: question += " (%s)" % default ui.info(ui.green, "::", ui.reset, question) try: answer = read_input() except KeyboardInterrupt: return default if not answer: return default return answer
def ask_yes_no(question, default=False): """Ask the user to answer by yes or no""" while True: if default: ui.info(ui.green, "::", ui.reset, question, "(Y/n)?") else: ui.info(ui.green, "::", ui.reset, question, "(y/N)?") answer = read_input() if answer in ["y", "yes", "Yes"]: return True if answer in ["n", "no", "No"]: return False if not answer: return default ui.warning("Please anwser by 'yes' or 'no'")
def setup_project(project_path, project_name, review_url, branch): """ Setup a project for code review. * Figure out the user name * Add a remote called 'gerrit' * Add the hook :return: a boolean to tell wether it's worth trying for other projects """ git = qisrc.git.Git(project_path) # Extract server from url: # pylint: disable-msg=E1103 netloc = urlparse.urlsplit(review_url).netloc server = netloc.split(":")[0] # Get username qibuild_cfg = qibuild.config.QiBuildConfig() qibuild_cfg.read(create_if_missing=True) access = qibuild_cfg.get_server_access(server) if access: username = access.username else: username = ask_gerrit_username(server) if not username: return False # Add it to config so we ask only once qibuild_cfg.set_server_access(server, username) qibuild_cfg.write() # Set a remote named 'gerrit' remote_url = http_to_ssh(review_url, project_name, username) git.set_remote("gerrit", remote_url) # Configure review.remote in git/config so that # qisrc push knows what to do: git.set_config("review.remote", "gerrit") # Install the hook commit_hook = os.path.join(project_path, ".git", "hooks", "commit-msg") if os.path.exists(commit_hook): return True ui.info("Configuring project for code review ...", end="") (username, server, port) = parse_git_url(remote_url) fetch_gerrit_hook(project_path, username, server, port) ui.info(ui.green, "[OK]") return True
def sync_all(worktree, args): """ Fetch any manifest project, re init everything, re-create branch configurations, review setup and so on """ manifest_projects = worktree.get_manifest_projects() if not manifest_projects: raise qisrc.manifest.NoManifest(worktree) # Re-synchronize everything: for manifest_project in manifest_projects: ui.info(ui.green, "Updating", manifest_project.src, "...") git = qisrc.git.Git(manifest_project.path) git.pull(quiet=True) manifest_filename = manifest_project.profile + ".xml" manifest_xml = os.path.join(manifest_project.path, manifest_filename) qisrc.sync.init_worktree(worktree, manifest_xml, setup_review=args.setup_review)
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(args): """ Main method """ toc = qibuild.toc.toc_open(args.worktree, args) ui.info(ui.green, "qibuild projects in:", ui.blue, toc.worktree.root) projects = toc.projects[:] for project in projects: project.directory = os.path.relpath(project.directory, toc.worktree.root) max_name = max([len(x.name) for x in projects]) max_src = max([len(x.directory) for x in projects]) regex = args.pattern if args.pattern: regex = re.compile(regex) for project in projects: if args.names: items = (project.name.ljust(max_name + 2), project.directory) else: items = (project.directory.ljust(max_src + 2), project.name) if not regex or regex.search(items[0]) or regex.search(items[1]): ui.info(ui.green, " * ", ui.blue, items[0], ui.reset, project.directory, items[1])
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()
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)
def ask_gerrit_username(server, gerrit_ssh_port=29418): """ Run a wizard to try to configure gerrit access If that fails, ask the user for its username If that fails, give up and suggest upload the public key """ ui.info(ui.green, "Configuring gerrit ssh access ...") # works on UNIX and git bash: username = os.environ.get("USERNAME") if not username: username = qibuild.interact.ask_string("Please enter your username") if not username: return ui.info("Checking gerrit connection with %s@%s:%i" % (username, server, gerrit_ssh_port)) if check_gerrit_connection(username, server, gerrit_ssh_port): ui.info("Success") return username ui.warning("Could not connect to ssh using username", username) try_other = qibuild.interact.ask_yes_no("Do you want to try with an other username ?") if not try_other: return username = qibuild.interact.ask_string("Please enter your username ") if not username: return if check_gerrit_connection(username, server, gerrit_ssh_port): return username
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 do(args): """Main entry point""" toc = qibuild.toc.toc_open(args.worktree, args) (project_names, _package_names, _not_found) = toc.resolve_deps() use_incredibuild = toc.config.build.incredibuild ui.info(ui.green, "Current worktree:", ui.reset, ui.bold, toc.worktree.root) if toc.active_config: ui.info(ui.green, "Active configuration: ", ui.blue, "%s (%s)" % (toc.active_config, toc.build_type)) projects = [toc.get_project(name) for name in project_names] project_count = len(projects) i = 0 for project in projects: i += 1 if args.target: mess = "Building target %s for" % args.target else: mess = "Building" ui.info(ui.green, "*", ui.reset, "(%i/%i)" % (i, project_count), ui.green, mess, ui.blue, project.name) toc.build_project(project, target=args.target, num_jobs=args.num_jobs, incredibuild=use_incredibuild, rebuild=args.rebuild, fix_shared_libs=args.fix_shared_libs)
def download(url, output_dir, output_name=None, callback=callback, clobber=True, message=None): """ Download a file from an url, and save it in output_dir. :param output_name: The name of the file will be the basename of the url, unless output_name is given :param callback: callback to use to show download progress. By default :py:func:`qitoolchain.remote.callback` is called :param message: a list of arguments for :py:func:`qibuild.ui.info' Will be printed right before the progress bar. :param clobber: If False, the file won't be overwritten if it already exists (True by default) :return: the path to the downloaded file """ qibuild.sh.mkdir(output_dir, recursive=True) if output_name: dest_name = os.path.join(output_dir, output_name) else: dest_name = url.split("/")[-1] dest_name = os.path.join(output_dir, dest_name) error = None if os.path.exists(dest_name) and not clobber: return dest_name if message: ui.info(*message) try: dest_file = open(dest_name, "wb") except Exception, e: mess = "Could not save %s to %s\n" % (url, dest_name) mess += "Error was %s" % e raise Exception(mess)
def build(src, dest, opts): """ Run sphinx-build on a sphinx repo configure() should have been called first """ ui.info(ui.green, "Building sphinx", src) config_path = os.path.join(src, "qidoc") # Try with sphinx-build2 (for arch), then fall back on # sphinx-build sphinx_build2 = qibuild.command.find_program("sphinx-build2") if sphinx_build2: cmd = [sphinx_build2] else: sphinx_build = qibuild.command.find_program("sphinx-build") if not sphinx_build: raise Exception("sphinx-build not in path, please install it") cmd = [sphinx_build] if os.path.exists(os.path.join(config_path, "conf.py")): cmd.extend(["-c", config_path]) if opts.get("werror"): cmd.append("-W") if opts.get("quiet"): cmd.append("-q") for flag in opts.get("flags", list()): cmd.extend(["-D", flag]) cmd.extend([os.path.join(src, "source"), dest]) env = os.environ.copy() release = opts.get("release", False) if release: env["build_type"] = "release" else: env["build_type"] = "internal" # by-pass sphinx-build bug on mac: if sys.platform == "darwin": env["LC_ALL"] = "en_US.UTF-8" qibuild.command.call(cmd, cwd=src, env=env)
def do(args): """ Main entry point """ dry_run = args.dry_run tc = qitoolchain.get_toolchain(args.name) tc_cache = tc.cache dirs_to_rm = os.listdir(tc_cache) dirs_to_rm = [os.path.join(tc_cache, x) for x in dirs_to_rm] dirs_to_rm = [x for x in dirs_to_rm if os.path.isdir(x)] num_dirs = len(dirs_to_rm) ui.info(ui.green, "Cleaning cache for", ui.blue, tc.name) if dry_run: print "Would remove %i packages" % num_dirs print "Use -f to proceed" return for (i, dir_to_rm) in enumerate(dirs_to_rm): sys.stdout.write("Removing package %i / %i\r" % ((i+1), num_dirs)) sys.stdout.flush() qibuild.sh.rm(dir_to_rm) ui.info(ui.green, "done")
def cmake(source_dir, build_dir, cmake_args, env=None, clean_first=True, profile=False): """Call cmake with from a build dir for a source dir. cmake_args are added on the command line. If clean_first is True, we will remove cmake-generated files. Useful when dependencies have changed. """ if not os.path.exists(source_dir): raise Exception("source dir: %s does not exist, aborting") if not os.path.exists(build_dir): mess = "Could not find build directory: %s \n" % build_dir raise Exception(mess) # Always remove CMakeCache if clean_first: cache = os.path.join(build_dir, "CMakeCache.txt") qibuild.sh.rm(cache) # Check that no one has made an in-source build in_source_cache = os.path.join(source_dir, "CMakeCache.txt") if os.path.exists(in_source_cache): # FIXME: better wording mess = "You have run CMake from your sources\n" mess += "CMakeCache.txt found here: %s\n" % in_source_cache mess += "Please clean your sources and try again\n" raise Exception(mess) # Check that the root CMakeLists file is correct root_cmake = os.path.join(source_dir, "CMakeLists.txt") check_root_cmake_list(root_cmake, os.path.basename(source_dir)) # Add path to source to the list of args, and set buildir for # the current working dir. cmake_args += [source_dir] if not profile: qibuild.command.call(["cmake"] + cmake_args, cwd=build_dir, env=env) return # importing here in order to not create circular dependencies: cmake_log = os.path.join(build_dir, "cmake.log") fp = open(cmake_log, "w") ui.info(ui.green, "Running cmake for profiling ...") subprocess.call(["cmake"] + cmake_args, cwd=build_dir, env=env, stdout=fp, stderr=fp) fp.close() qibuild_dir = get_cmake_qibuild_dir() ui.info(ui.green, "Analyzing cmake logs ...") profile = qibuild.cmake.profile.parse_cmake_log(cmake_log, qibuild_dir) outdir = os.path.join(build_dir, "profile") qibuild.cmake.profile.gen_annotations(profile, outdir, qibuild_dir) ui.info(ui.green, "Annotations generated in", outdir)
def do(args): """Main entry point""" worktree = qisrc.open_worktree(args.worktree) projects = qisrc.cmdparse.projects_from_args(args) should_fetch_first = True if len(projects) == len(worktree.projects): sync_all(worktree, args) should_fetch_first = False git_projects = set() for project in projects: if project.git_project and not project.manifest: git_projects.add(project.git_project) ui.info(ui.green, "Synchronizing projects ...") git_projects = list(git_projects) git_projects.sort(key = operator.attrgetter("src")) errors = list() project_count = len(git_projects) for i, project in enumerate(git_projects): if project_count != 1: ui.info( ui.green, "*", ui.reset, "(%2i/%2i)" % (i+1, project_count), ui.blue, project.src) else: ui.info(ui.bold, "Pulling", ui.blue, project.src) git = qisrc.git.open(project.path) error = git.update_branch(project.branch, project.remote, fetch_first=True) if error: errors.append((project.src, error)) if not errors: return print ui.error("Fail to sync some projects") for (src, err) in errors: ui.info(ui.blue, src) print "-" * len(src) print indent(err, 2) sys.exit(1)
def do(args): """Main entry point""" if args.build_directory and not args.single: raise Exception("You should use --single when specifying a build directory") if not args.cmake_flags: args.cmake_flags = list() if args.effective_cplusplus: args.cmake_flags.append("QI_EFFECTIVE_CPP=ON") if args.werror: args.cmake_flags.append("QI_WERROR=ON") toc = qibuild.toc_open(args.worktree, args) (project_names, _, _) = toc.resolve_deps() projects = [toc.get_project(name) for name in project_names] if args.build_directory: projects[0].set_custom_build_directory(args.build_directory) if args.debug_trycompile: print "--debug-trycompile ON" ui.info(ui.green, "Current worktree:", ui.reset, ui.bold, toc.worktree.root) if toc.active_config: ui.info(ui.green, "Active configuration:", ui.blue, toc.active_config) project_count = len(projects) i = 0 for project in projects: i = i + 1 ui.info(ui.green, "*", ui.reset, "(%i/%i)" % (i, project_count), ui.green, "Configuring", ui.blue, project.name) toc.configure_project(project, clean_first=args.clean_first, debug_trycompile=args.debug_trycompile, profile=args.profile)
def do(args): """Main entry point""" qiwt = qisrc.open_worktree(args.worktree) errors = list() ui.info(ui.green, "Running `%s` on every project" % " ".join(args.command)) c = 0 count = len(qiwt.git_projects) for project in qiwt.git_projects: c += 1 command = args.command[:] ui.info(ui.green, "*", ui.reset, "(%d/%d)" % (c, count), ui.blue, project.src) try: qibuild.command.call(command, cwd=project.path) except qibuild.command.CommandFailedException: if args.ignore_errors: errors.append(project) continue else: raise if not errors: return ui.error("Command failed on the following projects:") for project in errors: ui.info(ui.bold, " - ", project.src)
def do(args): """Main entry point""" url = args.url (username, server, remote_directory) = qibuild.deploy.parse_url(url) toc = qibuild.toc_open(args.worktree, args) ui.info(ui.green, "Current worktree:", ui.reset, ui.bold, toc.worktree.root) if toc.active_config: ui.info(ui.green, "Active configuration: ", ui.blue, "%s (%s)" % (toc.active_config, toc.build_type)) rsync = qibuild.command.find_program("rsync", env=toc.build_env) use_rsync = False if rsync: use_rsync = True else: ui.warning("Please install rsync to get faster synchronisation") scp = qibuild.command.find_program("scp", env=toc.build_env) if not scp: raise Exception("Could not find rsync or scp") # Resolve deps: (project_names, package_names, _) = toc.resolve_deps(runtime=True) projects = [toc.get_project(name) for name in project_names] if not args.single: ui.info(ui.green, "The following projects") for project_name in project_names: ui.info(ui.green, " *", ui.blue, project_name) if not args.single and package_names: ui.info(ui.green, "and the following packages") for package_name in package_names: ui.info(" *", ui.blue, package_name) ui.info(ui.green, "will be deployed to", ui.blue, url) # Deploy packages: install all of them in the same temp dir, then # deploy this temp dir to the target if not args.single and package_names: print ui.info(ui.green, ":: ", "Deploying packages") with qibuild.sh.TempDir() as tmp: for (i, package_name) in enumerate(package_names): ui.info(ui.green, "*", ui.reset, "(%i/%i)" % (i+1, len(package_names)), ui.green, "Deploying package", ui.blue, package_name, ui.green, "to", ui.blue, url) toc.toolchain.install_package(package_name, tmp, runtime=True) qibuild.deploy.deploy(tmp, args.url, use_rsync=use_rsync, port=args.port) print if not args.single: ui.info(ui.green, ":: ", "Deploying projects") # Deploy projects: install them inside a 'deploy' dir inside the build dir, # then deploy this dir to the target for (i, project) in enumerate(projects): ui.info(ui.green, "*", ui.reset, "(%i/%i)" % (i+1, len(projects)), ui.green, "Deploying project", ui.blue, project.name, ui.green, "to", ui.blue, url) destdir = os.path.join(project.build_directory, "deploy") #create folder for project without install rules qibuild.sh.mkdir(destdir, recursive=True) toc.install_project(project, destdir, prefix="/", runtime=True, num_jobs=args.num_jobs, split_debug=True) qibuild.deploy.deploy(destdir, args.url, use_rsync=use_rsync, port=args.port) qibuild.deploy.generate_debug_scripts(toc, project.name, args.url)
def main(): ui.info(ui.red, "This is a an error message\n", ui.reset, "And here are the details") ui.error("could not build") ui.warning("-j ignored for this generator") ui.info("building foo") ui.debug("debug message") ui.info(ui.brown, "this is brown") ui.info(ui.bold, ui.brown, "this is bold brown") ui.info(ui.red, "red is dead") ui.info(ui.darkred, "darkred is really dead") ui.info(ui.yellow, "this is yellow")
def do(args): """Main entry point""" toc = qibuild.toc_open(args.worktree, args) # Compute final destination: prefix = args.prefix[1:] destdir = qibuild.sh.to_native_path(args.destdir) dest = os.path.join(destdir, prefix) # Resolve deps: (project_names, package_names, _) = toc.resolve_deps(runtime=args.runtime) if toc.active_config: ui.info(ui.green, "Active configuration: ", ui.blue, "%s (%s)" % (toc.active_config, toc.build_type)) ui.info(ui.green, "The following projects") for project_name in project_names: ui.info(ui.green, " *", ui.blue, project_name) if args.include_deps and package_names: ui.info(ui.green, "and the following packages") for package_name in package_names: ui.info(" *", ui.blue, package_name) ui.info(ui.green, "will be installed to", ui.blue, dest) if args.runtime: ui.info(ui.green, "(runtime components only)") # Install packages to destdir: if args.include_deps and package_names: print ui.info(ui.green, ":: ", "Installing packages") for (i, package_name) in enumerate(package_names): ui.info(ui.green, "*", ui.reset, "(%i/%i)" % (i+1, len(package_names)), ui.green, "Installing package", ui.blue, package_name) toc.toolchain.install_package(package_name, dest, runtime=args.runtime) print # Install projects to destdir: ui.info(ui.green, ":: ", "Installing projects") projects = [toc.get_project(name) for name in project_names] for (i, project) in enumerate(projects): ui.info(ui.green, "*", ui.reset, "(%i/%i)" % (i+1, len(projects)), ui.green, "Installing project", ui.blue, project.name) toc.install_project(project, args.destdir, prefix=args.prefix, runtime=args.runtime, num_jobs=args.num_jobs, split_debug=args.split_debug)
def read_input(): """ Read input from the user """ ui.info(ui.green, "> ", end="") return raw_input()
toc = None if args.default: try: toc = qibuild.toc.toc_open(args.worktree) 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(): ui.warning(tc_name, "already exists,", "removing previous toolchain and creating a new one") toolchain = qitoolchain.Toolchain(tc_name) toolchain.remove() 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: toc.config.set_default_config(tc_name) toc.save_config() 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)