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
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