def parse_config_option(self, group: QPCBlock, option: QPCBlock): if self.check_build_step(group): self.parse_build_step(self.__dict__[group.key], option) elif group.key in self.__dict__ and group.key != "_proj": self.__dict__[group.key].parse_option(self._proj.macros, option) else: group.warning("Unknown Configuration Group: ")
def parse_option(self, macros: dict, option_block: QPCBlock) -> None: if option_block.key in {"options", "libraries", "ignore_libraries"}: for item in option_block.get_items_cond(macros): if option_block.key == "libraries": if item.key == "-": self.remove_lib(macros, item) else: self.add_lib(macros, item) else: self.__dict__[option_block.key].extend(replace_macros_list(macros, *item.get_list())) elif not option_block.values: return elif option_block.key in {"output_file", "debug_file"}: # TODO: maybe split the extension for output_file, debug_file, or import_library? self.__dict__[option_block.key] = clean_path(option_block.values[0], macros) elif option_block.key in {"import_library", "entry_point"}: # TODO: maybe split the extension for output_file, debug_file, or import_library? self.__dict__[option_block.key] = replace_macros(option_block.values[0], macros) elif option_block.key == "ignore_import_library": self.ignore_import_library = convert_bool_option(self.ignore_import_library, option_block) else: option_block.error("Unknown Linker Option: ")
def add_lib(self, macros: dict, lib_block: QPCBlock) -> None: for lib_path in (lib_block.key, *lib_block.values): lib_path = self._fix_lib_path(macros, lib_path) if lib_path not in self.libraries: self.libraries.append(lib_path) elif not args.hide_warnings: lib_block.warning(f"Library already added: \"{lib_path}\"")
def remove_lib(self, macros: dict, lib_block: QPCBlock) -> None: for lib_path in lib_block.values: lib_path = self._fix_lib_path(macros, lib_path) if lib_path in self.libraries: self.libraries.remove(lib_path) elif not args.hide_warnings: lib_block.warning(f"Trying to remove a library that hasn't been added yet: \"{lib_path}\"")
def parse_option(self, macros: dict, option_block: QPCBlock) -> None: if option_block.values: if option_block.key == "arguments": self.arguments = replace_macros(option_block.values[0], macros) elif option_block.key in self.__dict__: self.__dict__[option_block.key] = clean_path(option_block.values[0], macros) else: option_block.warning("Invalid Debug Option: ")
def convert_bool_option(old_value: bool, option_block: QPCBlock) -> bool: value = option_block.values[0] if value == "true": return True elif value == "false": return False else: option_block.invalid_option(value, "true", "false") return old_value
def convert_enum_option(old_value: Enum, option_block: QPCBlock, enum_list: EnumMeta) -> Enum: # value = replace_macros(option_block.values[0]) value = option_block.values[0] for enum in enum_list: if value == enum.name.lower(): return enum else: option_block.invalid_option(value, *[enum.name.lower() for enum in enum_list]) return old_value
def _remove_file_internal(self, folder_list: list, file_path: str, file_block: QPCBlock): if os.path.splitext(file_path)[1] in EXTS_C: if file_path in self.source_files: del self.source_files[file_path] else: file_block.warning(f"Trying to remove a file that isn't added: \"{file_path}\"") else: if file_path in self.files: del self.files[file_path] else: file_block.warning(f"Trying to remove a file that isn't added: \"{file_path}\"")
def _base_group_define(self, group_block: QPCBlock, info: BaseInfoPlatform): if not group_block.values: group_block.warning("No Group Name Defined, skipping") return group = group_block.values[0] project_group = info.shared.add_group(group) self._parse_project_group_items(project_group, info, group_block, []) for contain_group_name in group_block.values[1:]: contain_group = info.shared.add_group(contain_group_name) contain_group.contains_group(project_group, [])
def parse_option(self, macros: dict, option_block: QPCBlock) -> None: if option_block.key in ("preprocessor_definitions", "options"): for item in option_block.get_items_cond(macros): self.__dict__[option_block.key].extend(replace_macros_list(macros, *item.get_list())) elif option_block.key == "precompiled_header": if option_block.values: self.precompiled_header = convert_enum_option(self.precompiled_header, option_block, PrecompiledHeader) elif option_block.key in {"precompiled_header_file", "precompiled_header_output_file"}: self.__dict__[option_block.key] = replace_macros(option_block.values[0], macros) else: option_block.error("Unknown Compiler Option: ")
def set_language(self, option: QPCBlock) -> None: self.set_standard(option) value = option.values[0] for enum in Language: if value.startswith(enum.name.lower()): self.language = enum break else: option.invalid_option( value, *[enum.name.lower() for enum in Language], *[enum.name.lower() for enum in Standard] )
def _parse_files(self, files_block: QPCBlock, project: ProjectPass, folder_list: list) -> None: if files_block.solve_condition(project.macros): for block in files_block.items: if not block.solve_condition(project.macros): continue if block.key == "folder": folder_list.append(block.values[0]) self._parse_files(block, project, folder_list) folder_list.remove(block.values[0]) elif block.key == "-": project.remove_file(folder_list, block) else: project.add_file(folder_list, block) if block.items: for file_path in block.get_list(): if check_file_path_glob(file_path): [ self._source_file(block, project, found_file) for found_file in glob.glob(file_path) ] else: self._source_file(block, project, file_path)
def add_file(self, folder_list: list, file_block: QPCBlock) -> None: for file_path in file_block.get_list(): file_path = self.replace_macros(file_path) if check_file_path_glob(file_path): self._add_file_glob(folder_list, file_path, file_block) else: self._add_file_internal(folder_list, file_path, file_block)
def parse_build_step(self, step: list, event: QPCBlock): # this kind of sucks if event.key == "-": if not event.values: event.warning("Empty build event name!") elif not self._validate_build_step(event.values[0], event.warning): return else: if not self._validate_build_step(event.key, event.warning): return if event.items: for value in event.get_items_cond(self._proj.macros): self._parse_build_step_glob(step, event, value, *value.get_list()) else: event_args = replace_macros_list(self._proj.macros, *event.values) self._parse_build_step_call(step, event, *event_args)
def _add_file_internal(self, folder_list: list, file_path: str, file_block: QPCBlock): build = file_block.get_item("build") force_src_file = build and build.solve_condition(self.macros) and build.values and build.values[0] == "true" if force_src_file or os.path.splitext(file_path)[1] in EXTS_C: if not self._check_file_added(file_path, file_block, self.source_files): self.source_files[file_path] = SourceFile(folder_list) elif not self._check_file_added(file_path, file_block, self.files): self.files[file_path] = "/".join(folder_list)
def _parse_build_event(project_block: QPCBlock, project: ProjectPass): if not project_block.values and not args.hide_warnings: project_block.warning("build_event has no name") # can only define it here elif project_block.items: # check to see if it's already defined if project_block.values[0] in project.build_events: if not args.hide_warnings: project_block.warning( "build_event already defined, redefining") build_event = BuildEvent( *replace_macros_list(project.macros, *project_block.values)) command_list = replace_macros_list( project.macros, *project_block.get_item_list_condition(project.macros)) build_event.commands.append(command_list) project.build_events[project_block.values[0]] = build_event
def _parse_project_group_items(self, project_group: ProjectGroup, info: BaseInfoPlatform, project_block: QPCBlock, folder_list: list) -> None: for item in project_block.get_items_cond(info.macros): if item.key == "folder": folder_list.append(item.values[0]) self._parse_project_group_items(project_group, info, item, folder_list) folder_list.remove(item.values[0]) elif item.key == "contains": for group_name in item.values: if group_name in info.shared.groups: contain_group = info.shared.groups[group_name] else: contain_group = info.shared.add_group(group_name) project_group.contains_group(contain_group, folder_list) else: info.add_project_to_group(item.key, project_group, folder_list)
def parse_option(self, macros: dict, option_block: QPCBlock) -> None: # multiple path options if option_block.key in {"include_directories", "library_directories", "options"}: for item in option_block.get_items_cond(macros): self.__dict__[option_block.key].extend(replace_macros_list(macros, *item.get_list())) elif option_block.key == "options": for item in option_block.get_items_cond(macros): self.options.extend(item.get_list()) if not option_block.values: return if option_block.key in {"out_dir", "int_dir", "build_dir"}: value = clean_path(option_block.values[0], macros) if option_block.key in {"build_dir", "int_dir"}: self.build_dir = value else: self.out_dir = value elif option_block.key == "out_name": self.out_name = replace_macros(option_block.values[0], macros) elif option_block.key in {"default_include_directories", "default_library_directories"}: self.__dict__[option_block.key] = convert_bool_option(self.__dict__[option_block.key], option_block) elif option_block.key == "configuration_type": self.set_type(option_block) elif option_block.key == "language": self.set_language(option_block) elif option_block.key in {"toolset_version", "compiler"}: if option_block.key == "toolset_version": if not args.hide_warnings: option_block.warning("toolset_version is now compiler") self.compiler = replace_macros(option_block.values[0], macros) else: option_block.error("Unknown General Option: ")
def _parse_config(config: QPCBlock, project: ProjectPass) -> None: if config.solve_condition(project.macros): for group in config.get_items_cond(project.macros): for option_block in group.get_items_cond(project.macros): project.config.parse_config_option(group, option_block)
def _check_file_added(file_path: str, file_block: QPCBlock, file_dict: dict) -> bool: if file_path in file_dict: file_block.warning("File already added: " + file_path) return True else: return not check_if_file_exists(file_path, file_block.warning)