Пример #1
0
    def __ValidateAddTool(self, rErrorRecordList: List[ErrorRecord],
                          installationPath: Optional[str],
                          command: XmlRecipeValidateCommandAddTool,
                          packageRecipeResult: PackageRecipeResult) -> bool:
        toolName = PlatformUtil.GetPlatformDependentExecuteableName(
            command.Name, PlatformUtil.DetectBuildPlatformType())
        result, value = self.__DoValidateFile(rErrorRecordList,
                                              installationPath, toolName,
                                              False)
        if self.__Log.Verbosity >= 1:
            self.__Log.LogPrint("Validating AddTool '{0}': {1}".format(
                command.Name, result))
            if self.__Log.Verbosity >= 2:
                self.__Log.LogPrint("  '{0}'".format(value))
        if result and value is not None:
            foundVersion = [0]
            if result and value is not None and command.VersionCommand is not None:
                if command.VersionCommand is None or command.VersionRegEx is None:
                    raise Exception("Internal error")
                foundVersion = self.__TryValidateCommandVersion(
                    value, command.VersionCommand, command.VersionRegEx,
                    command.MinVersion, [])
                result = len(foundVersion) > 0

            exeRecord = PackageRecipeResultFoundExecutable(
                command.Name, command.Name, value,
                self.__ToVersion(foundVersion))
            packageRecipeResult.AddFoundExecutable(exeRecord)
        return result
Пример #2
0
    def GetVersion() -> CMakeVersion:
        exeName = PlatformUtil.GetPlatformDependentExecuteableName(
            "cmake", PlatformUtil.DetectBuildPlatformType())
        path = IOUtil.TryFindExecutable(exeName)
        if path is None:
            raise Exception(
                "Could not locate cmake in path. Please install cmake 3.10.2+ (https://cmake.org/) as it is used to generate build files."
            )
        cmd = [path, "--version"]
        version = CMakeUtil.RunCommand(cmd)
        versionString = "cmake version "
        if not version.startswith(versionString):
            raise Exception(
                "Failed to parse cmake version string '{0}'".format(
                    versionString))
        version = version[len(versionString):]
        indexEnd = version.find('\n')
        indexEnd = indexEnd if indexEnd >= 0 else len(version)
        version = version[0:indexEnd].strip()
        parsedVersion = version.split('.')
        if len(parsedVersion) < 3:
            raise Exception(
                "Failed to parse cmake version string: '{0}'".format(version))
        while len(parsedVersion) < 3:
            parsedVersion.append("0")

        indexNonDigit = CMakeUtil._FindNonDigit(parsedVersion[2])
        strBuild = parsedVersion[2][:indexNonDigit]
        return CMakeVersion(int(parsedVersion[0]), int(parsedVersion[1]),
                            int(strBuild))
Пример #3
0
 def __init__(self,
              generatorContext: GeneratorContext,
              buildThreads: int,
              useRecipe: bool = True) -> None:
     super().__init__(generatorContext, buildThreads,
                      PlatformBuildTypeInfo.CMakeCustom)
     self.IsSingleConfiguration = True
     self.__CommandName = PlatformUtil.GetPlatformDependentExecuteableName(
         "ninja", PlatformUtil.DetectBuildPlatformType())
     self.__UseRecipe = useRecipe
 def __ValidateAddTool(self, rErrorRecordList: List[ErrorRecord],
                      installationPath: Optional[str],
                      command: XmlRecipeValidateCommandAddTool) -> bool:
     toolName = PlatformUtil.GetPlatformDependentExecuteableName(command.Name, PlatformUtil.DetectBuildPlatformType())
     result, value = self.__DoValidateFile(rErrorRecordList, installationPath, toolName, False)
     if self.__BasicConfig.Verbosity >= 1:
         self.__BasicConfig.LogPrint("Validating AddTool '{0}': {1}".format(command.Name, result))
         if self.__BasicConfig.Verbosity >= 2:
             self.__BasicConfig.LogPrint("  '{0}'".format(value))
     return result
Пример #5
0
    def __ValidateFindExecutableFileInPath(self, rErrorRecordList: List[ErrorRecord],
                                           installationPath: Optional[str],
                                           command: XmlRecipeValidateCommandFindExecutableFileInPath,
                                           packageRecipeResult: PackageRecipeResult) -> bool:
        # Patch filename with the platform dependent name
        alternatives = [command.Name]
        if len(command.Alternatives) > 0:
            alternatives += command.Alternatives
        retry = True
        currentCommandName = ""
        newErrors = [] # type: List[ErrorRecord]
        while retry and len(alternatives) > 0:
            currentCommandName = alternatives[0]
            retry = False
            platformFilename = PlatformUtil.GetPlatformDependentExecuteableName(currentCommandName, PlatformUtil.DetectBuildPlatformType())

            result, value = self.__TryFindFileInPath(newErrors, installationPath, platformFilename, command.ExpectedPath)

            foundVersion = [0]
            if result and value is not None and command.VersionCommand is not None:
                if command.VersionCommand is None or command.VersionRegEx is None:
                    raise Exception("Internal error")
                foundVersion = self.__TryValidateCommandVersion(value, command.VersionCommand, command.VersionRegEx, command.MinVersion, command.AddOnErrorWarning)
                result = len(foundVersion) > 0

            # Cache information about what we discovered
            if result and value is not None:
                exeRecord = PackageRecipeResultFoundExecutable(command.Name, currentCommandName, value, self.__ToVersion(foundVersion))
                packageRecipeResult.AddFoundExecutable(exeRecord)
            elif len(alternatives) > 0:
                alternatives = alternatives[1:]
                retry = True

        if self.__BasicConfig.Verbosity >= 1:
            # On failure we show the 'most' common name
            if result or (len(command.Alternatives) < 0):
                if command.ExpectedPath is None:
                    self.__BasicConfig.LogPrint("Validating executable file '{0}' is in path: {1}".format(currentCommandName, result))
                else:
                    self.__BasicConfig.LogPrint("Validating executable file '{0}' is in path at '{1}': {2}".format(currentCommandName, command.ExpectedPath, result))
            else:
                allAlternatives = [command.Name]
                if command.Alternatives is not None:
                    allAlternatives += command.Alternatives
                if command.ExpectedPath is None:
                    self.__BasicConfig.LogPrint("Validating one of these executable files '{0}' is in path: {1}".format(", ".join(allAlternatives), result))
                else:
                    self.__BasicConfig.LogPrint("Validating one of these executable files '{0}' is in path at '{1}': {2}".format(", ".join(allAlternatives), command.ExpectedPath, result))
            if not value is None and self.__BasicConfig.Verbosity >= 2:
                self.__BasicConfig.LogPrint("  '{0}'".format(value))

        if not result:
            rErrorRecordList += newErrors

        return result
Пример #6
0
 def GetVersion() -> CMakeVersion:
     exeName = PlatformUtil.GetPlatformDependentExecuteableName(
         "cmake", PlatformUtil.DetectBuildPlatformType())
     path = IOUtil.TryFindExecutable(exeName)
     if path is None:
         raise Exception("Could not locate cmake in path")
     cmd = [path, "--version"]
     version = RunCommand(cmd)
     versionString = "cmake version "
     if not version.startswith(versionString):
         raise Exception(
             "Failed to parse cmake version string '{0}'".format(
                 versionString))
     version = version[len(versionString):]
     indexEnd = version.find('\n')
     indexEnd = indexEnd if indexEnd >= 0 else len(version)
     version = version[0:indexEnd]
     indexEndMajor = version.index('.')
     indexEndMinor = version.index('.', indexEndMajor + 1)
     versionMajor = version[0:indexEndMajor]
     versionMinor = version[indexEndMajor + 1:indexEndMinor]
     return CMakeVersion(int(versionMajor), int(versionMinor))
Пример #7
0
 def GetPlatformDependentExecuteableName(self, exeName: str) -> str:
     return PlatformUtil.GetPlatformDependentExecuteableName(
         exeName, self.BuildPlatform)
Пример #8
0
 def __init__(self, generatorContext: GeneratorContext,
              buildThreads: int) -> None:
     super().__init__(generatorContext, buildThreads)
     self.IsSingleConfiguration = True
     self.__CommandName = PlatformUtil.GetPlatformDependentExecuteableName(
         "ninja", PlatformUtil.DetectBuildPlatformType())