def Process(self, log: Log, configDisableWrite: bool, contentBuildPath: str, contentOutputPath: str, contentFileRecord: PathRecord) -> None: # we ask the tool to write to a temporary file so that we can ensure that the output file is only modified # if the content was changed tmpOutputFileName = self.GetTempFileName(contentBuildPath, contentFileRecord) buildCommand = [self.ToolCommand] buildCommand += self.__GetToolParameterList(tmpOutputFileName, contentFileRecord.ResolvedPath) if configDisableWrite: # if write is disabled we do a "tool-command" check directly since the subprocess call can't fail # which would normally trigger the check self.__ToolFinder.CheckToolCommand(self.ToolCommand, self.ToolDescription) return outputFileName = self.GetOutputFileName(log, contentOutputPath, contentFileRecord) self.EnsureDirectoryExist(configDisableWrite, outputFileName) try: result = subprocess.call(buildCommand, cwd=contentBuildPath) if result != 0: self.__ToolFinder.CheckToolCommand(self.ToolCommand, self.ToolDescription) raise Exception("{0}: Failed to process file '{1}' ({2})".format(self.ToolCommand, contentFileRecord.ResolvedPath, self.ToolDescription)) IOUtil.CopySmallFile(tmpOutputFileName, outputFileName) except: self.__ToolFinder.CheckToolCommand(self.ToolCommand, self.ToolDescription) raise finally: IOUtil.RemoveFile(tmpOutputFileName)
def __CopyFiles(self, config: Config, dstPath: str, filesToCopy: List[TemplateFileRecord]) -> None: for file in filesToCopy: if not self.GenFileOnly or file.FileName == config.ToolConfig.GenFileName: dst = IOUtil.Join(dstPath, file.RelativeDestPath) dirName = IOUtil.GetDirectoryName(dst) if not config.DisableWrite: IOUtil.SafeMakeDirs(dirName) IOUtil.CopySmallFile(file.AbsoluteSourcePath, dst)
def Process(self, log: Log, configDisableWrite: bool, contentBuildPath: str, contentOutputPath: str, contentFileRecord: PathRecord, toolFinder: ToolFinder) -> None: # we ask the tool to write to a temporary file so that we can ensure that the output file is only modified # if the content was changed tmpOutputFileName = self.GetTempFileName(contentBuildPath, contentFileRecord) buildCommand = [ toolFinder.VulkanShaderCompiler, '-t', '-o', tmpOutputFileName, '-V', contentFileRecord.ResolvedPath ] #if config.Verbosity == 0: # buildCommand += ['-s'] if configDisableWrite: # if write is disabled we do a vulkan shader compiler check directly since the subprocess call can't fail # which would normally trigger the check toolFinder.CheckVulkanShaderCompiler() return outputFileName = self.GetOutputFileName(log, contentOutputPath, contentFileRecord) self.EnsureDirectoryExist(configDisableWrite, outputFileName) try: result = subprocess.call(buildCommand, cwd=contentBuildPath) if result != 0: toolFinder.CheckVulkanShaderCompiler() raise Exception( "VulkanContentProcessor: Failed to compile file '{0}' to SPIR-V binary" .format(contentFileRecord.ResolvedPath)) IOUtil.CopySmallFile(tmpOutputFileName, outputFileName) except: toolFinder.CheckVulkanShaderCompiler() raise finally: IOUtil.RemoveFile(tmpOutputFileName)
def __GenerateFolderStructure(self, config: Config, package: Package) -> None: #don't generate anything for unsuported packages if package.ResolvedPlatformNotSupported: return if (package.AbsolutePath is None or package.ResolvedBuildPath is None or package.ResolvedBuildAllIncludeDirs is None or package.ResolvedBuildSourceFiles is None or package.ShortName is None): raise Exception("Invalid package") # Use a standard build path buildBasePath = IOUtil.Join(package.AbsolutePath, package.ResolvedBuildPath) newDir = "arm" relativePathBuildArm = IOUtil.Join(package.ResolvedBuildPath, newDir) buildArmPath = IOUtil.Join(buildBasePath, newDir) buildPath = buildBasePath #relativePathBuild = "" newDir = "a-le-v7" relativePathBuildLib = IOUtil.Join(relativePathBuildArm, newDir) buildPathLib = IOUtil.Join(buildArmPath, newDir) #check package type and prepare folder name if package.Type == PackageType.Library: relativePathBuild = relativePathBuildLib buildPath = buildPathLib elif package.Type == PackageType.Executable: newDir = "o-le-v7" relativePathBuild = IOUtil.Join(relativePathBuildArm, newDir) buildPath = IOUtil.Join(buildArmPath, newDir) else: raise InternalErrorException("Unknown package type: {0}".format(package.Name)) if not config.DisableWrite: # create folder structure IOUtil.SafeMakeDirs(buildPath) #copy make files that are not modified IOUtil.CopySmallFile(IOUtil.Join(config.SDKConfigTemplatePath, ".qnx_internal.mk"), IOUtil.Join(buildBasePath, ".qnx_internal.mk")) dstFile = IOUtil.Join(buildBasePath, "Makefile") content = self.TemplateMakefileCPU IOUtil.WriteFileIfChanged(dstFile, content) dstFile = IOUtil.Join(buildArmPath, "Makefile") content = self.TemplateMakefileVariant IOUtil.WriteFileIfChanged(dstFile, content) dstFile = IOUtil.Join(buildPath, "Makefile") content = self.TemplateMakefileTop IOUtil.WriteFileIfChanged(dstFile, content) #create common.mk with package-specific content dstFile = IOUtil.Join(buildBasePath, "common.mk") content = self.TemplateCommonMk #add "$(project_root)/" to local includes like "include", keep others as they are ("$(FSL_GRAPHICS_SDK)/a/b/") updatedIncludedirs = [] for includeDir in package.ResolvedBuildAllIncludeDirs: if not os.path.dirname(includeDir): updatedIncludedirs.append("$(project_root)/" + includeDir) else: updatedIncludedirs.append(includeDir) includes = self.__FormatListToString("EXTRA_INCVPATH += ", updatedIncludedirs) content = content.replace("##EXTRA_INCVPATHS##", includes) srcDirsList = self.__ExtractUniqueDirectoriesFromList(package.ResolvedBuildSourceFiles) srcDirs = self.__FormatListToString("EXTRA_SRCVPATH += $(project_root)/", srcDirsList) content = content.replace("##EXTRA_SRCVPATHS##", srcDirs) # QNX takes all sources in folder, just like this generator, so there is no need to # list all files in makefile. #sourceObjs = [] #for sourceFile in package.ResolvedBuildSourceFiles: # sourceObjs.append(os.path.splitext(sourceFile)[0] + ".o") #sourceObjsString = self.__FormatListToString("SOURCE_OBJECTS += $(project_root)/", sourceObjs) #content = content.replace("##EXTRA_SOURCE_OBJS##", sourceObjsString) content = content.replace("##EXTRA_SOURCE_OBJS##", "") libDirsList = self.__GetStaticLibsPaths(config, package, relativePathBuildLib) extLibraryDependencies = self.__GetExternalLibraryDependencies(package) libsExtern = "" for lib in extLibraryDependencies: libsExtern = libsExtern + lib[0] + " " if lib[1] is not None and lib[1] not in libDirsList: libDirsList.append(lib[1]) if libsExtern: libsExtern = "LIBS += " + libsExtern + "\n" content = content.replace("##PACKAGE_EXTERNAL_LIBRARY_DEPENDENCIES##", libsExtern) libDirs = self.__FormatListToString("EXTRA_LIBVPATH += ", libDirsList) content = content.replace("##EXTRA_LIBVPATHS##", libDirs) sl = self.__GetStaticLibs(package) content = content.replace("##STATIC_LIBS##", sl) name = package.ShortName if package.Type == PackageType.Executable else package.Name content = content.replace("##PINFO_DESC##", name) content = content.replace("##NAME##", name) # Local CPP defines localDefines = Util.ExtractNames(package.ResolvedBuildAllPrivateDefines) localDefines += Util.ExtractNames(package.ResolvedBuildAllPublicDefines) localDefineNames = MakeFileHelper.CreateList(localDefines) content = content.replace("##PACKAGE_DEFINES##", localDefineNames) #if package.Type == PackageType.Executable: #libraryDependencies = self.__GetLibraryDependencies(config, package) #libraryDependencies = MakeFileHelper.CreateList(libraryDependencies) #build = build.replace("##PACKAGE_LIBRARY_DEPENDENCIES##", libraryDependencies) if not config.DisableWrite: IOUtil.WriteFileIfChanged(dstFile, content) #remove this if statement if build scripts are required also for libraries if package.Type == PackageType.Executable: self.__GenerateBuildScript(config, package, self.BldTemplate, buildBasePath)