コード例 #1
0
    def init_args(self):
        for project_path in args.add:
            if not self.add_project_by_script(project_path):
                if project_path not in self.shared.groups and not self.is_project_added(
                        project_path):
                    warning("Project, Group, or File does not exist: " +
                            project_path)

        for config in args.configs:
            if config not in self.configurations:
                self.configurations.append(config)

        if not self.configurations:
            self.configurations.append("Default")
コード例 #2
0
def get_arg_macros() -> dict:
    from qpc_logging import warning  # avoids circular imports
    arg_macros = {}
    for macro in args.macros:
        name = macro
        value = "1"
        if "=" in macro:
            name, value = macro.split("=", 1)
            if not value:
                warning(
                    f"Macro \"{macro}\" has trailing equals sign, setting to 1"
                )
                value = "1"
        arg_macros["$" + name] = value
    return arg_macros
コード例 #3
0
    def setup_wanted_projects(self, add_list: list, remove_list: list,
                              unwanted_projects: dict) -> None:
        self.projects = []
        self.project_folders = {}

        for removed_item in remove_list:
            if removed_item in self.shared.groups:
                for project in self.shared.groups[removed_item].projects:
                    if project not in unwanted_projects:
                        unwanted_projects[project] = None

            elif removed_item in self.shared.projects_all:
                if self.shared.projects_all[
                        removed_item] in self._projects_all:
                    unwanted_projects[removed_item] = None
            else:
                for project in self._projects_all:
                    if removed_item == project.path:
                        unwanted_projects[project.name] = None
                        break
                else:
                    warning("Project, Group, or Script does not exist: " +
                            removed_item)

        # TODO: clean up this mess
        if add_list:
            for added_item in add_list:
                if added_item in self.shared.groups:
                    for project, folders in self.shared.groups[
                            added_item].projects.items():
                        self._use_project(self.get_project(project),
                                          unwanted_projects, folders)

                elif added_item in self.shared.projects_all:
                    if self.shared.projects_all[
                            added_item] in self._projects_all:
                        self._use_project(self.shared.projects_all[added_item],
                                          unwanted_projects)
                else:
                    for project in self._projects_all:
                        if added_item in {project.path, project.path_real}:
                            self._use_project(project, unwanted_projects)
                            break
                    else:
                        warning("Project, Group, or Script does not exist: " +
                                added_item)
        else:
            raise Exception("No projects were added to generate for")
コード例 #4
0
    def parse_project(self, project_def: ProjectDefinition,
                      project_script: str, info: BaseInfo,
                      generator_list: list) -> ProjectContainer:
        if args.time:
            start_time = perf_counter()
        elif not args.verbose:
            print("Parsing: " + project_script)

        project_filename = os.path.split(project_script)[1]
        project_block = self.read_file(project_filename)

        if project_block is None:
            warning("Script does not exist: " + project_script)
            return

        project_name = os.path.splitext(project_filename)[0]
        project_container = ProjectContainer(project_name, project_script,
                                             info, project_def, generator_list)

        for project_pass in project_container._passes:
            verbose(f"\n ---- Parsing Project - "
                    f"Config: \"{project_pass.config_name}\" "
                    f"Platform: \"{project_pass.platform.name}\" "
                    f"Arch: \"{project_pass.arch.name}\" ---- \n")

            verbose("Parsing: " + project_script)
            project_pass.hash_list[project_filename] = qpc_hash.make_hash(
                project_filename)
            self._parse_project(project_block, project_pass, project_script)
            self.counter += 1

            if project_pass.config.general.configuration_type is None:
                error(
                    "No configuration_type Specified in Script!",
                    "Pick one of these and add it to the \"general\" group:",
                    " ".join(
                        [f"\"{enum.name.lower()}\"" for enum in ConfigType]))

        verbose("Parsed: " + project_container.get_display_name())

        if args.time:
            print(
                str(round(perf_counter() - start_time, 4)) + " - Parsed: " +
                project_script)

        return project_container
コード例 #5
0
    def parse_base_info(self, base_file_path: str) -> BaseInfo:
        info = BaseInfo()

        if base_file_path:
            verbose("\nReading: " + args.base_file)

            base_file = self.read_file(base_file_path)
            if not base_file:
                warning("Base File does not exist: " + base_file_path)
            else:
                verbose("\nParsing: " + args.base_file)

                [
                    self._parse_base_info_recurse(info_plat, base_file)
                    for info_plat in info.info_list
                ]

        info.finish_parsing()
        return info
コード例 #6
0
    def add_project(self,
                    project_name: str,
                    project_path: str,
                    include_dir: str = "") -> None:
        # TODO: check if script path is already used
        project_def = self.shared.add_project(project_name)
        project_def.platforms.add(self.platform)

        if include_dir and not include_dir.endswith("/"):
            include_dir += "/"

        project_path = replace_macros(project_path, self.macros)

        if not project_path:
            return

        if os.path.isfile(project_path):
            project_def.path_real = project_path
            project_def.path = include_dir + project_path
        else:
            warning("Script does not exist: " + project_path)

        self._projects_all.append(project_def)
コード例 #7
0
 def warning(self, message):
     warning(self.get_file_info(), message)
コード例 #8
0
 def invalid_option(self, value: str, *valid_option_list):
     warning(self.get_file_info(), f"Invalid Option: {value}",
             "Valid Options:", *valid_option_list)