예제 #1
0
    def __CreateCommandGitClone(
            self, sourceCommand: XmlRecipePipelineFetchCommandGitClone,
            srcRootPath: str) -> PipelineCommand:
        if self.__SourcePackage is None or self.__SourceRecipe is None:
            raise Exception("Invalid state")

        readonlyCacheRootDir = self.__PathBuilder.ReadonlyCache_DownloadCacheRootPath
        if not readonlyCacheRootDir is None:
            cachePath = IOUtil.Join(readonlyCacheRootDir,
                                    self.__SourceRecipe.FullName)
            if IOUtil.IsDirectory(cachePath):
                info = PipelineInfo(self.PipelineTasks, self.__SourcePackage,
                                    self.__PathBuilder, cachePath, cachePath)
                return PipelineCommandNOP(self.__Log, sourceCommand, info)

        if self.__PathBuilder.DownloadCacheRootPath is None:
            raise Exception("Invalid State")

        dstPath = IOUtil.Join(self.__PathBuilder.DownloadCacheRootPath,
                              self.__SourceRecipe.FullName)
        info = PipelineInfo(self.PipelineTasks,
                            self.__SourcePackage,
                            self.__PathBuilder,
                            srcRootPath,
                            dstPath,
                            allowDownloads=self.__AllowDownloads)
        return PipelineCommandGitClone(self.__Log, sourceCommand, info)
예제 #2
0
    def __CreateCommandDownload(
            self, sourceCommand: XmlRecipePipelineFetchCommandDownload,
            srcRootPath: str) -> PipelineCommand:
        if self.__SourcePackage is None or self.__SourceRecipe is None:
            raise Exception("Invalid state")

        readonlyCacheRootDir = self.__PathBuilder.ReadonlyCache_DownloadCacheRootPath
        if not readonlyCacheRootDir is None:
            # If we have a download cache and the directory exists there then setup a void fetch command
            targetFilename = PipelineCommandDownload.GetTargetFilename(
                sourceCommand)
            cachePath = IOUtil.Join(readonlyCacheRootDir, targetFilename)
            if PipelineCommandDownload.IsValidCacheFile(
                    cachePath, sourceCommand):
                info = PipelineInfo(self.PipelineTasks, self.__SourcePackage,
                                    self.__PathBuilder, readonlyCacheRootDir,
                                    readonlyCacheRootDir)
                return PipelineCommandNOP(self.__Log, sourceCommand, info)

        if self.__PathBuilder.DownloadCacheRootPath is None:
            raise Exception("Invalid State")

        info = PipelineInfo(self.PipelineTasks,
                            self.__SourcePackage,
                            self.__PathBuilder,
                            srcRootPath,
                            self.__PathBuilder.DownloadCacheRootPath,
                            allowDownloads=self.__AllowDownloads)
        return PipelineCommandDownload(self.__Log, sourceCommand, info)
    def __CreateCommandSource(self, sourceCommand: XmlRecipePipelineFetchCommandSource, srcRootPath: str) -> PipelineCommand:
        if self.__SourcePackage is None or self.__SourceRecipe is None:
            raise Exception("Invalid state")

        # We basically setup a NOP command that points to the source package location which will allow the pipeline to work with that
        info = PipelineInfo(self.PipelineTasks, self.__SourcePackage, self.__PathBuilder, srcRootPath, srcRootPath, allowDownloads=self.__AllowDownloads)
        return PipelineCommandNOP(self.__BasicConfig, sourceCommand, info)
 def __CreateCommand(self, basicConfig: BasicConfig, sourceCommand: XmlRecipePipelineCommand, pipelineInfo: PipelineInfo, dstRootPath: str, sourceRecipeName: str) -> PipelineCommand:
     if sourceCommand.CommandType == BuildRecipePipelineCommand.CMakeBuild:
         if not isinstance(sourceCommand, XmlRecipePipelineCommandCMakeBuild):
             raise Exception("Internal error, sourceCommand was not XmlRecipePipelineCommandCMakeBuild")
         info = PipelineInfo(pipelineInfo.Tasks, pipelineInfo.SourcePackage, pipelineInfo.PathBuilder, pipelineInfo.SrcRootPath, dstRootPath, combinedDstRootPath=pipelineInfo.DstRootPath)
         return PipelineCommandCMakeBuild(basicConfig, sourceCommand, info, False)
     raise Exception("Unsupported combined command '{0}' in '{1}'".format(sourceCommand.CommandType, sourceRecipeName))
예제 #5
0
    def End(self) -> List[PipelineCommand]:
        if self.__SourcePackage is None or self.__PathBuilder is None or self.__CommandInputRootPath is None or self.__PipelineInstallPath is None or self.__CommandList is None or self.__SourceRecipe is None:
            raise Exception("Usage error, End called outside begin/end block")

        # Add a final install command to finish the pipe
        installInfo = PipelineInfo(self.PipelineTasks, self.__SourcePackage,
                                   self.__PathBuilder,
                                   self.__CommandInputRootPath,
                                   self.__PipelineInstallPath)
        pipelineInstallCommand = PipelineCommandInstall(
            self.__Log, installInfo)
        self.__CommandList.append(pipelineInstallCommand)

        result = self.__CommandList

        if pipelineInstallCommand.IsCompleted():
            self.__Log.LogPrint(
                "  Pipeline '{0}' skipped as target path '{1}' exists.".format(
                    self.__SourceRecipe.FullName, installInfo.DstRootPath))
            result = []

        self.__CommandList = None
        self.__SourcePackage = None
        self.__SourceRecipe = None
        self.__CommandInputRootPath = None
        self.__PipelineInstallPath = None
        return result
    def __CreateCommand(self, sourceCommand: XmlRecipePipelineCommand, srcRootPath: str) -> PipelineCommand:
        if self.__SourcePackage is None or self.__SourceRecipe is None:
            raise Exception("Invalid state")

        if sourceCommand.CommandType == BuildRecipePipelineCommand.Download:
            if not isinstance(sourceCommand, XmlRecipePipelineFetchCommandDownload):
                raise Exception("Internal error, sourceCommand was not XmlRecipePipelineFetchCommandDownload")
            return self.__CreateCommandDownload(sourceCommand, srcRootPath)
        elif sourceCommand.CommandType == BuildRecipePipelineCommand.GitClone:
            if not isinstance(sourceCommand, XmlRecipePipelineFetchCommandGitClone):
                raise Exception("Internal error, sourceCommand was not XmlRecipePipelineFetchCommandGitClone")
            return self.__CreateCommandGitClone(sourceCommand, srcRootPath)
        elif sourceCommand.CommandType == BuildRecipePipelineCommand.Source:
            if not isinstance(sourceCommand, XmlRecipePipelineFetchCommandSource):
                raise Exception("Internal error, sourceCommand was not XmlRecipePipelineFetchCommandSource")
            return self.__CreateCommandSource(sourceCommand, srcRootPath)
        elif sourceCommand.CommandType == BuildRecipePipelineCommand.Unpack:
            if not isinstance(sourceCommand, XmlRecipePipelineCommandUnpack):
                raise Exception("Internal error, sourceCommand was not XmlRecipePipelineCommandUnpack")
            info = PipelineInfo(self.PipelineTasks, self.__SourcePackage, self.__PathBuilder, srcRootPath, self.__GetTempDirectoryName(sourceCommand))
            return PipelineCommandUnpack(self.__BasicConfig, sourceCommand, info)
        elif sourceCommand.CommandType == BuildRecipePipelineCommand.CMakeBuild:
            if not isinstance(sourceCommand, XmlRecipePipelineCommandCMakeBuild):
                raise Exception("Internal error, sourceCommand was not XmlRecipePipelineCommandCMakeBuild")
            info = PipelineInfo(self.PipelineTasks, self.__SourcePackage, self.__PathBuilder, srcRootPath, self.__GetTempDirectoryName(sourceCommand))
            return PipelineCommandCMakeBuild(self.__BasicConfig, sourceCommand, info, True)
        elif sourceCommand.CommandType == BuildRecipePipelineCommand.Combine:
            if not isinstance(sourceCommand, XmlRecipePipelineCommandCombine):
                raise Exception("Internal error, sourceCommand was not XmlRecipePipelineCommandCombine")
            info = PipelineInfo(self.PipelineTasks, self.__SourcePackage, self.__PathBuilder, srcRootPath, self.__GetTempDirectoryName(sourceCommand))
            return PipelineCommandCombine(self.__BasicConfig, sourceCommand, info, self.__SourceRecipe.Name)
        elif sourceCommand.CommandType == BuildRecipePipelineCommand.Copy:
            if not isinstance(sourceCommand, XmlRecipePipelineCommandCopy):
                raise Exception("Internal error, sourceCommand was not XmlRecipePipelineCommandCopy")
            info = PipelineInfo(self.PipelineTasks, self.__SourcePackage, self.__PathBuilder, srcRootPath, self.__GetTempDirectoryName(sourceCommand))
            return PipelineCommandCopy(self.__BasicConfig, sourceCommand, info, self.__SourceRecipe.Name)
        raise Exception("Unsupported command '{0}' ({1}) in '{2}'".format(sourceCommand.CommandName, sourceCommand.CommandType, self.__SourceRecipe.Name))