示例#1
0
 def __init__(self, log: Log, toolFinder: ToolFinder, contentBuilderConfig: ToolContentBuilder) -> None:
     super().__init__(contentBuilderConfig.Name, contentBuilderConfig.FeatureRequirements, self.__GetExtensionsSet(contentBuilderConfig.DefaultExtensions))
     self.BasedUpon = contentBuilderConfig
     self.DefaultExtensions = contentBuilderConfig.DefaultExtensions
     self.ToolArguments = self.__ProcessToolParameters(contentBuilderConfig.Parameters)
     self.ToolCommand = toolFinder.GetPlatformDependentExecuteableName(contentBuilderConfig.Executable)
     self.ToolDescription = contentBuilderConfig.Description
     self.__ToolFinder = toolFinder
示例#2
0
    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)
示例#3
0
    def Process(self, config: Config, 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 = [self.ToolCommand]
        buildCommand += self.__GetToolParameterList(
            tmpOutputFileName, contentFileRecord.ResolvedPath)

        if config.DisableWrite:
            # if write is disabled we do a "tool-command" check directly since the subprocess call can't fail
            # which would normally trigger the check
            toolFinder.CheckToolCommand(self.ToolCommand, self.ToolDescription)
            return

        outputFileName = self.GetOutputFileName(config, contentOutputPath,
                                                contentFileRecord)
        self.EnsureDirectoryExist(config, outputFileName)

        try:
            result = subprocess.call(buildCommand, cwd=contentBuildPath)
            if result != 0:
                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:
            toolFinder.CheckToolCommand(self.ToolCommand, self.ToolDescription)
            raise
        finally:
            IOUtil.RemoveFile(tmpOutputFileName)
示例#4
0
def Build(config: Config, currentPath: str, featureList: List[str]) -> None:
    contentBuildDir = __CONTENT_BUILD_DIR
    contentOutputDir = __CONTENT_OUTPUT_DIR
    contentBuildPath = IOUtil.Join(currentPath, contentBuildDir)
    contentOutputPath = IOUtil.Join(currentPath, contentOutputDir)
    if not IOUtil.IsDirectory(contentBuildPath):
        config.LogPrintVerbose(
            1,
            "No '{0}' directory present at '{1}' so there is no content to process."
            .format(contentBuildDir, currentPath))
        return

    packageBuildPath = IOUtil.Join(currentPath, config.GetBuildDir())
    if not config.DisableWrite:
        IOUtil.SafeMakeDirs(packageBuildPath)

    toolFinder = ToolFinder(config)
    features = Features(config, featureList)
    Builder(config, packageBuildPath, contentBuildPath, contentOutputPath,
            features, toolFinder)
示例#5
0
def GetContentProcessorManager(
        log: Log, toolConfig: ToolConfig,
        featureList: List[str]) -> ContentProcessorManager:
    toolFinder = ToolFinder(log)
    features = Features(log, featureList)
    return ContentProcessorManager(log, toolConfig, features, toolFinder)