def reset_manifest(git_worktree, snapshot, ignore_groups=False): manifest = snapshot.manifest if ignore_groups: groups = git_worktree.manifest.groups else: groups = manifest.groups if not manifest.branch: ui.fatal("No branch configured for the manifest of the snapshot") ok = git_worktree.configure_manifest(manifest.url, groups=groups, branch=manifest.branch, ref=manifest.ref) if not ok: sys.exit(1)
def name_from_xml(xml_path): """ Get a name from an qiproject.xml file """ mess = "Invalid qiproject.xml file detected!\n" mess += "(%s)\n" % xml_path if not os.path.exists(xml_path): return None tree = etree.ElementTree() try: tree.parse(xml_path) except Exception, e: ui.fatal(e)
def do(args): """Main entry point.""" worktree = qisys.parsers.get_worktree(args) projects = qisys.parsers.get_projects(worktree, args) if not projects: ui.fatal("Please specify at least one project") if args.maintainers_action == "add": to_call = add_maintainer if args.maintainers_action == "list": to_call = list_maintainers elif args.maintainers_action == "remove": to_call = remove_maintainer elif args.maintainers_action == "clear": to_call = clear_maintainers for project in projects: to_call(project, args)
def do(args): """ Add a package to a toolchain - Check that there is a current toolchain - Add the package to the cache - Add the package from cache to toolchain """ toolchain = qitoolchain.parsers.get_toolchain(args) name = args.name package_path = args.package_path legacy = False try: archive = zipfile.ZipFile(package_path) archive.read("package.xml") except KeyError: legacy = True if legacy and not args.name: ui.fatal("Must specify --name when using legacy format") if args.name and not legacy: ui.warning("--name ignored when using modern format") package = None if legacy: package = qitoolchain.qipackage.QiPackage(args.name) else: package = qitoolchain.qipackage.from_archive(package_path) # extract it to the default packages path of the toolchain tc_name = toolchain.name tc_packages_path = qitoolchain.toolchain.get_default_packages_path(tc_name) dest = os.path.join(tc_packages_path, package.name) qisys.sh.rm(dest) qitoolchain.qipackage.extract(package_path, dest) package.path = dest # add the package to the toolchain toolchain.add_package(package)
def show_config(args, build_worktree): is_local = args.is_local if is_local and not build_worktree: ui.fatal("Cannot use --local when not in a worktree") qibuild_cfg = qibuild.config.QiBuildConfig() qibuild_cfg.read(create_if_missing=True) if args.edit: editor = qibuild_cfg.defaults.env.editor if not editor: editor = qisys.interact.get_editor() qibuild_cfg.defaults.env.editor = editor qibuild_cfg.write() full_path = qisys.command.find_program(editor) if is_local: cfg_path = build_worktree.qibuild_xml else: cfg_path = qibuild.config.get_global_cfg_path() subprocess.call([full_path, cfg_path]) return if not build_worktree: print qibuild_cfg return if not is_local: print "General configuration" print "---------------------" print ui.indent(str(qibuild_cfg)) print print "Local configuration" print "-------------------" print ui.indent(str(qibuild_cfg.local))
def do(args): """Main entry point""" root = args.worktree or os.getcwd() if os.path.exists(os.path.join(root, '.qi')): raise ui.fatal("A .qi directory already exists here. " + "Please remove it or initialize elsewhere.") worktree = qisys.worktree.WorkTree(root) build_worktree = qibuild.worktree.BuildWorkTree(worktree) if args.config: ui.warning("`qibuild init -c` is deprecated", "\n", "Use `qitoolchain set-default` instead") qisys.script.run_action("qitoolchain.actions.set_default", [args.config, "--worktree", build_worktree.root]) if args.interactive: ui.warning("`qibuild init --interactive` is deprecated", "\n", "Use `qibuild config --wizard` instead") qisys.script.run_action("qibuild.actions.config", ["--wizard", "--worktree", build_worktree.root])
def do(args): """"Create a new project """ try: worktree = qisys.parsers.get_worktree(args) except qisys.worktree.NotInWorkTree: worktree = None project_name = os.path.basename(args.project_name) output_dir = args.output_dir if not output_dir: output_dir = qisrc.templates.attached_lower(project_name) output_dir = os.path.join(os.getcwd(), output_dir) if os.path.exists(output_dir): raise ui.fatal("%s already exists" % output_dir) template_path = args.template_path if not template_path: template_path = os.path.join(qisrc.QISRC_ROOT_DIR, "templates", "project") qisrc.templates.process(template_path, output_dir, project_name=project_name) if args.git: qisys.command.call(["git", "init"], cwd=output_dir) with open(os.path.join(output_dir, ".gitignore"), "w") as fp: fp.write("build-*\n") qisys.command.call(["git", "add", "."], cwd=output_dir) qisys.command.call(["git", "commit", "-m", "initial commit"], cwd=output_dir) ui.info(ui.green, "New project initialized in", ui.bold, output_dir) if worktree: worktree.add_project(output_dir) return worktree.get_project(output_dir)
def do(args): """Main entry point""" standalone = args.standalone breakpad = args.breakpad cmake_builder = qibuild.parsers.get_cmake_builder(args) if breakpad: cmake_builder.build_config.build_type = "RelWithDebInfo" projects = cmake_builder.projects if len(projects) != 1: ui.fatal("This action can only work on one project") project = projects[0] archive_name = project.name version = args.version if version: project.version = version else: version = project.version if not version: version = "0.1" if not version: ui.warning("Could not find project version!", "Either use --version or fix qiproject.xml", sep="\n") build_dir_name = os.path.basename(project.build_directory) archive_suffix = build_dir_name.replace("build-", "") if version: archive_name += "-" + version archive_name += "-" + archive_suffix package_dir = os.path.join(cmake_builder.build_worktree.root, "package") destdir = os.path.join(package_dir, archive_name) # Clean the destdir just in case the package was already generated qisys.sh.rm(destdir) build_type = cmake_builder.build_config.build_type # Also build in debug on windows when building a package for a toolchain if sys.platform.startswith("win") and not standalone: _do_package(cmake_builder, destdir, build_type="Debug", standalone=False) _do_package(cmake_builder, destdir, build_type=build_type, standalone=standalone) package_xml_path = os.path.join(destdir, "package.xml") project.gen_package_xml(package_xml_path) if breakpad: symbols_archive_name = archive_name + "-symbols.zip" symbols_archive = os.path.join(package_dir, symbols_archive_name) with qisys.sh.TempDir() as tmp: pool_dir = os.path.join(tmp, "symbols") qibuild.breakpad.dump_symbols_from_directory(destdir, pool_dir) qisys.archive.compress(pool_dir, flat=True, output=symbols_archive) ui.info(ui.blue, "::", ui.reset, ui.bold, "Compressing package ...") flat = not standalone archive = qisys.archive.compress(destdir, algo="zip", quiet=True, flat=flat, output=destdir + ".zip") # Clean up after ourselves qisys.sh.rm(destdir) ui.info(ui.green, "Package generated in", ui.reset, ui.bold, archive) if breakpad: ui.info(ui.green, "Symbols package generated in", ui.reset, ui.bold, symbols_archive) return archive, symbols_archive else: return archive
""" mess = "Invalid qiproject.xml file detected!\n" mess += "(%s)\n" % xml_path if not os.path.exists(xml_path): return None tree = etree.ElementTree() try: tree.parse(xml_path) except Exception, e: ui.fatal(e) # Read name root = tree.getroot() if root.tag != "project": mess += "Root node must be 'project'" ui.fatal(mess) if root.get("version") == "3": project_elem = root.find("qbuild") if not project_elem: return else: project_elem = root name = project_elem.get('name') if not name: mess += "'project' node must have a 'name' attribute" ui.fatal(mess) return name