def projects_finished(self): if not self.commands_list: return print( "------------------------------------------------------------------------" ) create_directory("compile_commands") for label, commands_list in self.commands_list.items(): print_color(Color.CYAN, "Writing: " + f"compile_commands/{label}.json") compile_commands = json.dumps(commands_list, indent=4) with open(f"compile_commands/{label}.json", "w") as file_io: file_io.write(compile_commands)
def create_project(self, project: ProjectContainer) -> None: project_passes = self._get_passes(project) if not project_passes: return print_color(Color.CYAN, "Creating: " + project.file_name + MAKEFILE_EXT) compiler = get_compiler(project_passes[0].config.general.compiler, project_passes[0].config.general.language) makefile = gen_defines( project, compiler, project.base_info.get_base_info(self._platforms[0]).configurations) for p in project_passes: makefile += gen_project_config_definitions(p) with open(project.file_name + MAKEFILE_EXT, "w", encoding="utf-8") as f: f.write(makefile)
def create_project(self, project: ProjectContainer) -> None: project_passes = self._get_passes(project) if not project_passes: return proj_name = project.file_name.replace('.', '_').replace(':', '$') print_color(Color.CYAN, "Adding to Ninja: " + project.file_name) if project.dependencies: self.dependencies[ project.project_path] = project.dependencies.copy() for proj_pass in project_passes: conf = proj_pass.config self.cmd_gen.set_mode(proj_pass.config.general.compiler) label = f"{proj_pass.config_name.lower()}_{proj_pass.platform.name.lower()}_{proj_pass.arch.name.lower()}" if label not in self.all_files: self.all_files[label] = set() if label not in self.commands_list: self.commands_list[label] = [] if label not in self.output_files: self.output_files[label] = {} compiler = get_compiler(proj_pass.config.general.compiler, proj_pass.config.general.language) self.commands_list[label].append( self.gen_header(conf, project, compiler, proj_name)) for file, file_compile in proj_pass.source_files.items(): self.commands_list[label].append( self.handle_file(file, file_compile.compiler, proj_pass, proj_name)) output_file = self.handle_target(proj_pass, proj_name, proj_pass.source_files) self.commands_list[label].append(output_file) self.output_files[label][project.project_path] = ( self.get_output_file(proj_pass), output_file)
def create_project(self, project: ProjectContainer) -> None: project_passes = self._get_passes(project) if not project_passes: return print_color(Color.CYAN, "Adding to Compile Commands: " + project.file_name) for proj_pass in project_passes: self.cmd_gen.set_mode(proj_pass.config.general.compiler) label = f"{proj_pass.config_name.lower()}_{proj_pass.platform.name.lower()}_{proj_pass.arch.name.lower()}" if label not in self.all_files: self.all_files[label] = set() if label not in self.commands_list: self.commands_list[label] = [] for file in proj_pass.source_files: if file not in self.all_files[label]: self.all_files[label].add(file) self.commands_list[label].append( self.handle_file(file, proj_pass))
def create_master_file(self, info: BaseInfo, master_file_path: str) -> None: print_color(Color.CYAN, "Creating Master File: " + master_file_path) out_dir_dict = {} dependency_dict = {} wanted_projects = info.get_projects(Platform.LINUX, Platform.MACOS) for project_def in wanted_projects: out_dir = qpc_hash.get_out_dir( info.project_hashes[project_def.path]) if out_dir: out_dir_dict[project_def.path] = os.path.relpath(out_dir) dependency_dict[project_def.path] = info.project_dependencies[ project_def.path] # this chooses 64 bit architectures over 32 bit for a default arch architecture = None for arch in args.archs: if arch in self._architectures and not architecture or \ is_arch_64bit(arch) and architecture and not is_arch_64bit(architecture): architecture = arch master_file = f"""#!/usr/bin/make -f SETTINGS = ARCH={architecture.name.lower()} CONFIG={info.get_configs()[0]} all: """ # sort dict by most dependencies to least dependencies, 100% a flawed way of doing this make_paths, make_files = self.order_dependencies( out_dir_dict, dependency_dict) for index, path in enumerate(make_paths): master_file += f"\tmake -C {path} -f {make_files[index]} $(SETTINGS)\n" with open(master_file_path, "w") as master_file_w: master_file_w.write(master_file + "\n")
def projects_finished(self): if not self.commands_list: return print( "------------------------------------------------------------------------" ) create_directory("build_ninja") for label, commands_list in self.commands_list.items(): print_color(Color.CYAN, "Writing: " + f"build_ninja/{label}.ninja") script = self.gen_rules() for item, deps in self.dependencies.items(): if item in self.output_files[label]: out_file, command = self.output_files[label][item] if command in commands_list: new_command = command.split("\n") dep_list = self.get_dependencies(label, deps) new_command[0] += " || " + " ".join(dep_list) commands_list[commands_list.index( command)] = "\n".join(new_command) script += '\n\n'.join(commands_list) with open(f"build_ninja/{label}.ninja", "w") as file_io: file_io.write(script)
def warning_range(self, index: int, length: int, *text): file_error = self._make_arrow(index, length) warning_no_line(self.formatted_info(), *text) print(self.get_current_line().replace("\t", " ")) print_color(Color.GREEN, file_error)