Beispiel #1
0
def TryBuildAndRun(toolAppContext: ToolAppContext, config: Config,
                   package: Package) -> Optional[JsonDictType]:
    if package.ResolvedPlatformNotSupported:
        return None
    if package.AbsolutePath is None:
        raise Exception("Invalid package")
    workDir = package.AbsolutePath
    tmpOutputFilename = IOUtil.Join(workDir, 'FslBuildDoc_AppArguments.json')
    try:
        # FslBuild.py --ForAllExe "(EXE) --System.Arguments.Save <filename>"

        toolFlowConfig = ToolFlowBuild.GetDefaultLocalConfig()
        toolFlowConfig.SetToolAppConfigValues(toolAppContext.ToolAppConfig)
        toolFlowConfig.ForAllExe = '(EXE) --System.Arguments.Save {0} -h'.format(
            tmpOutputFilename)
        buildFlow = ToolFlowBuild.ToolFlowBuild(toolAppContext)
        buildFlow.Process(workDir, config.ToolConfig, toolFlowConfig)

        return ReadJsonFile(tmpOutputFilename)
    except (Exception) as ex:
        if toolAppContext.LowLevelToolConfig.DebugEnabled:
            raise
        config.LogPrint(
            "Failed to build and run '{0}' due to exception {1}".format(
                package.Name, ex))
        return None
    finally:
        IOUtil.RemoveFile(tmpOutputFilename)
Beispiel #2
0
    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)
Beispiel #3
0
 def DoExecute(self) -> None:
     """ Delete a file or directory if it exist """
     sourcePath = self.__SourceCommand.Path
     path = sourcePath
     if '../' in path or '/..' in path or path.startswith(
             '/') or '\\' in path or path == '..' or len(path) <= 0:
         raise Exception("Invalid path format '{0}'".format(path))
     path = IOUtil.Join(self.FinalDstPath, path)
     if IOUtil.IsDirectory(path):
         self.LogPrint("Deleting directory '{0}'".format(sourcePath))
         IOUtil.SafeRemoveDirectoryTree(path)
     elif IOUtil.IsFile(path):
         self.LogPrint("Deleting file '{0}'".format(sourcePath))
         IOUtil.RemoveFile(path)
Beispiel #4
0
    def DoExecute(self) -> None:
        try:
            targetFilename = PipelineCommandDownload.GetTargetFilename(
                self.__SourceCommand)
            archiveFilePath = IOUtil.Join(self.Info.DstRootPath,
                                          targetFilename)

            if not self.Info.AllowDownloads and not PipelineCommandDownload.IsValidCacheFile(
                    archiveFilePath, self.__SourceCommand):
                raise Exception(
                    "Could not download {0} to {1} as downloads have been disabled. Enable downloads or download it manually."
                    .format(self.__SourceCommand.URL, archiveFilePath))

            self.Task.DownloadFromUrl(self.__SourceCommand.URL,
                                      archiveFilePath)
            # Generate file hash
            filehash = PipelineCommandFetch.GenerateFileHash(archiveFilePath)
            if self.__SourceCommand.Hash is None:
                if self.Log.Verbosity >= 1:
                    self.Log.LogPrintWarning(
                        "No hash value defined for file {0} which has a hash value of {1}"
                        .format(archiveFilePath, filehash))
            elif filehash != self.__SourceCommand.Hash:
                raise Exception(
                    "The downloaded file {0} has a hash of {1} which did not match the expected value of {2}"
                    .format(archiveFilePath, filehash,
                            self.__SourceCommand.Hash))
            elif self.Log.Verbosity >= 2:
                self.LogPrint(
                    "The downloaded file {0} hash was {1} as expected.".format(
                        archiveFilePath, filehash))
        except Exception:
            # A error occurred removing the targetPath
            if IOUtil.IsFile(archiveFilePath):
                self.LogPrint(
                    "* A error occurred removing '{0}' to be safe.".format(
                        archiveFilePath))
                IOUtil.RemoveFile(archiveFilePath)
            raise
Beispiel #5
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)