def TryExtractBrief(basicConfig: BasicConfig, lines: List[str], path: str) -> Optional[List[str]]: startIndex = IndexOf(lines, "AG_BRIEF_BEGIN") if startIndex < 0: basicConfig.LogPrint( "WARNING: {0} did not contain a AG_BRIEF_BEGIN section".format( path)) return None endIndex = IndexOf(lines, "AG_BRIEF_END") if endIndex < 0: basicConfig.LogPrint( "WARNING: {0} did not contain a AG_BRIEF_END section".format(path)) return None if startIndex >= endIndex: basicConfig.LogPrint( "WARNING: {0} AG_BRIEF_BEGIN must appear before AG_BRIEF_END". format(path)) return None result = lines[startIndex + 1:endIndex] # remove all empty lines at the end index = len(result) - 1 while index >= 0 and len(result[index]) == 0: result.pop(index) index = index - 1 return result
def TryReplaceSection(basicConfig: BasicConfig, lines: List[str], sectionName: str, replacementLines: List[str], path: str) -> Optional[List[str]]: sectionBegin = "{0}_BEGIN".format(sectionName) sectionEnd = "{0}_END".format(sectionName) startIndex = IndexOf(lines, sectionBegin) if startIndex < 0: basicConfig.LogPrint( "WARNING: {0} did not contain a {1} section".format( path, sectionBegin)) return None endIndex = IndexOf(lines, sectionEnd) if endIndex < 0: basicConfig.LogPrint( "WARNING: {0} did not contain a {1} section".format( path, sectionEnd)) return None if startIndex >= endIndex: basicConfig.LogPrint("WARNING: {0} {1} must appear before {2}".format( path, sectionBegin, sectionEnd)) return None start = lines[0:startIndex + 1] end = lines[endIndex:] return start + replacementLines + end
def __TryValidateInstallation(basicConfig: BasicConfig, validationEngine: ValidationEngine, package: Package, packagesToBuild: List[Package], recipePackageStateCache: RecipePackageStateCache, cmakeConfig: GeneratorCMakeConfig) -> bool: if package.ResolvedDirectExperimentalRecipe is None: raise Exception("Invalid package") sourceRecipe = package.ResolvedDirectExperimentalRecipe installPath = sourceRecipe.ResolvedInstallLocation if installPath is not None: if not IOUtil.IsDirectory(installPath.ResolvedPath): basicConfig.LogPrintVerbose( 2, "Installation directory not located: {0}".format( installPath.ResolvedPath)) return False elif basicConfig.Verbosity >= 2: basicConfig.LogPrint( "Installation directory located at '{0}'".format( installPath.ResolvedPath)) # Check if the user decided to do a build override by creating the required file. # This allows the user to tell the system that it has been build and it should mind its own buisness packageHasUserBuildOverride = False if not installPath is None: overrideFilename = IOUtil.Join( installPath.ResolvedPath, __g_BuildPackageInformationOverrideFilename) packageHasUserBuildOverride = IOUtil.IsFile(overrideFilename) if packageHasUserBuildOverride: basicConfig.LogPrint( "Package {0} contained a build override file '{1}'".format( package.Name, __g_BuildPackageInformationOverrideFilename)) if not __RunValidationEngineCheck(validationEngine, package): if packageHasUserBuildOverride: raise Exception( "Package {0} contained a build override file '{1}', but it failed validation. Fix the issues or delete the override file '{2}'" .format(package.Name, __g_BuildPackageInformationOverrideFilename, overrideFilename)) basicConfig.LogPrintVerbose(2, "Install validation failed") return False # If there is a user build override we dont check the build dependency json file if packageHasUserBuildOverride: return True # If there is no build pipeline we consider the validation to be completed, else we need to check the saved build info if not PackageRecipeUtil.HasBuildPipeline(package): return True if not BuildInfoFileUtil.TryValidateBuildInformation( basicConfig, package, packagesToBuild, recipePackageStateCache, cmakeConfig, __g_BuildPackageInformationFilename): basicConfig.LogPrintVerbose( 2, "Install validator failed to load build information") return False return True
def __init__(self, basicConfig: BasicConfig, recipeFilterManager: RecipeFilterManager, experimental: Optional[ToolConfigExperimental], generator: GeneratorPlugin) -> None: cmakeGenerator = CMakeTypes.TryDetermineCMakeGenerator(generator) cmakeGeneratorShortName = None if cmakeGenerator is not None: cmakeGeneratorShortName = CMakeTypes.TryGetCompilerShortIdFromGeneratorName( cmakeGenerator) shortCompilerName = "NotDefined" if cmakeGeneratorShortName is None else cmakeGeneratorShortName if cmakeGeneratorShortName is None: if basicConfig.Verbosity >= 2: basicConfig.LogPrintWarning( "No CMake short generator id has been defined, defaulting to '{0}'" .format(shortCompilerName)) recipeBuilderSetup = None allowDownloads = False if experimental is not None: targetLocation = ResolvedPath( experimental.DefaultThirdPartyInstallDirectory.DynamicName, experimental.DefaultThirdPartyInstallDirectory.ResolvedPath) installReadonlySource = experimental.DefaultThirdPartyInstallReadonlyCacheDirectory readonlyCachePath = None if installReadonlySource is None else installReadonlySource.ResolvedPath # type: Optional[str] recipeBuilderSetup = RecipeBuilderSetup(targetLocation, readonlyCachePath) if IOUtil.TryGetEnvironmentVariable( experimental.DisableDownloadEnv) != None: allowDownloads = False basicConfig.LogPrint( "Downloads disabled since the environment variable {0} was defined" .format(experimental.DisableDownloadEnv)) elif experimental.AllowDownloads: allowDownloads = True else: basicConfig.LogPrint( "Downloads disabled since the project has it disabled by default" ) super().__init__(basicConfig, generator.PlatformName, generator.PlatformName, shortCompilerName, recipeBuilderSetup) #allowDownload=True, disableDownloadEnv=None self.BasicConfig = basicConfig self.Generator = generator # for now the generator is also the platform and the existing code use that name so maintain compatibility for now self.Platform = generator self.AllowDownloads = allowDownloads self.RecipeFilterManager = recipeFilterManager
def __CreatePipelines(basicConfig: BasicConfig, builder: PipelineCommandBuilder, resolvedBuildOrder: List[Package]) -> List[RecipeRecord]: pipelines = [] # type: List[RecipeRecord] for package in resolvedBuildOrder: basicConfig.LogPrint("Creating package {0} build pipelines".format( package.Name)) try: basicConfig.PushIndent() record = RecipeRecord(basicConfig, builder, package) pipelines.append(record) finally: basicConfig.PopIndent() return pipelines
def GetDefaultConfigForTest( enableTestMode: bool = False, customUnitTestRoots: Optional[List[str]] = None) -> Config: strToolAppTitle = "UnitTest" log = Log(strToolAppTitle, 0) currentDir = IOUtil.GetEnvironmentVariableForDirectory( "FSL_GRAPHICS_INTERNAL") basicConfig = BasicConfig(log) localToolConfig = LowLevelToolConfig(log.Verbosity, False, False, False, False, currentDir) projectRootConfig = ToolAppMain.GetProjectRootConfig( localToolConfig, basicConfig, currentDir) buildPlatformType = PlatformUtil.DetectBuildPlatformType() toolConfig = ToolConfig(localToolConfig, buildPlatformType, Version(1, 3, 3, 7), basicConfig, projectRootConfig.ToolConfigFile, projectRootConfig) config = Config(log, toolConfig, PluginSharedValues.TYPE_UNIT_TEST, None, True) config.ForceDisableAllWrite() if enableTestMode: config.SetTestMode() if customUnitTestRoots is not None: TEST_AddPackageRoots(config, customUnitTestRoots, True) return config
def __init__(self, basicConfig: BasicConfig, errorHelpManager: ErrorHelpManager, recipeFilterManager: RecipeFilterManager, experimental: Optional[ToolConfigExperimental], generator: GeneratorPlugin) -> None: if generator.CMakeConfig is None: raise Exception("Invalid generator") recipeBuilderSetup = None allowDownloads = False if experimental is not None: targetLocation = ResolvedPath( experimental.DefaultThirdPartyInstallDirectory.DynamicName, experimental.DefaultThirdPartyInstallDirectory.ResolvedPath) installReadonlySource = experimental.DefaultThirdPartyInstallReadonlyCacheDirectory readonlyCachePath = None if installReadonlySource is None else installReadonlySource.ResolvedPath # type: Optional[str] recipeBuilderSetup = RecipeBuilderSetup(targetLocation, readonlyCachePath) if IOUtil.TryGetEnvironmentVariable( experimental.DisableDownloadEnv) != None: allowDownloads = False basicConfig.LogPrint( "Downloads disabled since the environment variable {0} was defined" .format(experimental.DisableDownloadEnv)) elif experimental.AllowDownloads: allowDownloads = True else: basicConfig.LogPrint( "Downloads disabled since the project has it disabled by default" ) generatorInfo = GeneratorInfo(generator.IsCMake, generator.CMakeConfig.AllowFindPackage) super().__init__(basicConfig, errorHelpManager, generator.PlatformName, generator.PlatformName, generatorInfo, generator.CMakeConfig, recipeBuilderSetup) #allowDownload=True, disableDownloadEnv=None self.BasicConfig = basicConfig self.Generator = generator # for now the generator is also the platform and the existing code use that name so maintain compatibility for now self.Platform = generator self.AllowDownloads = allowDownloads self.RecipeFilterManager = recipeFilterManager
def __FindMissingInstallations( basicConfig: BasicConfig, validationEngine: ValidationEngine, resolvedBuildOrder: List[Package], recipePackageStateCache: RecipePackageStateCache) -> List[Package]: """ Check packages in the resolvedBuildOrder and return all that fails install validation, keeping the initial order """ missingPackages = [] # type: List[Package] for package in resolvedBuildOrder: basicConfig.LogPrint("Checking if package {0} is installed".format( package.Name)) try: basicConfig.PushIndent() if not __TryValidateInstallation(basicConfig, validationEngine, package, missingPackages, recipePackageStateCache): missingPackages.append(package) finally: basicConfig.PopIndent() return missingPackages
def __ProcessCompilerConfiguration( self, basicConfig: BasicConfig, xmlCompilerConfiguration: List[XmlConfigCompilerConfiguration] ) -> Dict[str, ToolConfigCompilerConfiguration]: result = {} # type: Dict[str, ToolConfigCompilerConfiguration] for config in xmlCompilerConfiguration: if config.Id in result: raise XmlDuplicatedCompilerConfigurationException( result[config.Id].BasedOn.XMLElement, result[config.Id].Name, config.XMLElement, config.Name) elif config.Name == CompilerNames.VisualStudio: result[config.Id] = ToolConfigCompilerConfiguration( basicConfig, config) else: msg = "CompilerConfiguration name: '{0}' is not currently supported, so entry is ignored".format( config.Name) basicConfig.LogPrint(msg) return result
def __Run(appFlowFactory: AToolAppFlowFactory, strToolAppTitle: str, toolCommonArgConfig: ToolCommonArgConfig, lowLevelToolConfig: LowLevelToolConfig, allowStandaloneMode: bool) -> None: log = Log(strToolAppTitle, lowLevelToolConfig.VerbosityLevel, showAppTitleIfVerbose=True) generatorIds = __PrepareGeneratorPlugins(lowLevelToolConfig, toolCommonArgConfig) try: defaultPlatform = DetectBuildPlatform() except (Exception) as ex: print("ERROR: {0}".format(ex)) if lowLevelToolConfig.DebugEnabled: raise sys.exit(1) ### Do the actual command line parsing parser = __CreateParser(toolCommonArgConfig, allowStandaloneMode) if toolCommonArgConfig.AddPlatformArg: parser.add_argument('-p', '--platform', default=defaultPlatform, help='Select build platform: {0}'.format( ", ".join(generatorIds))) if toolCommonArgConfig.AllowForceClaimInstallArea: parser.add_argument( '--ForceClaimInstallArea', action='store_true', help= 'Override the security checks on the install area allowing us to use it even though its not empty. This means the existing content can be lost.' ) #parser.add_argument('--NativeGen', action='store_true', help='Force use the native build generator') toolConfig = None baseConfig = None try: basicConfig = BasicConfig(log) currentDir = lowLevelToolConfig.CurrentDir # Try to locate a project root configuration file projectRootConfig = GetProjectRootConfig(lowLevelToolConfig, basicConfig, currentDir) toolConfigFile = projectRootConfig.ToolConfigFile # Get the path to the toolconfig file if necessary and load the tool config file toolConfigPath = __GetToolConfigPath(toolConfigFile) toolConfig = ToolConfig(basicConfig, toolConfigPath, projectRootConfig) baseConfig = BaseConfig(log, toolConfig) except (Exception) as ex: print("ERROR: {0}".format(ex)) if lowLevelToolConfig.DebugEnabled: raise sys.exit(1) buildTiming = None try: defaultVSVersion = toolConfig.GetVisualStudioDefaultVersion() #if toolCommonArgConfig.AllowVSVersion: parser.add_argument( '--VSVersion', default=str(defaultVSVersion), help= 'Choose a specific visual studio version (2015,2017), This project defaults to: {0}' .format(defaultVSVersion)) userTag = appFlowFactory.CreateUserTag(baseConfig) appFlowFactory.AddCustomArguments(parser, toolConfig, userTag) args = parser.parse_args() #if toolCommonArgConfig.AllowVSVersion: PluginConfig.SetVSVersion(args.VSVersion) #if toolCommonArgConfig.AddPlatformArg and args.platform.lower() != PluginSharedValues.PLATFORM_ID_ALL: #PluginConfig.SetForceUseNativeGenerator(True) #PluginConfig.SetForceUseNativeGenerator(args.NativeGen) if toolCommonArgConfig.ProcessRemainingArgs: args.RemainingArgs = __ProcessRemainingArgs(args.RemainingArgs) if toolCommonArgConfig.SupportBuildTime and args.BuildTime: buildTiming = BuildTimer() if toolCommonArgConfig.AddBuildFiltering and args.Recipes == DefaultValue.Recipes: if projectRootConfig.XmlExperimental is not None: tmpResult = projectRootConfig.XmlExperimental.TryGetRecipesDefaultValue( defaultPlatform) if tmpResult is not None: args.Recipes = "[{0}]".format(tmpResult) toolAppConfig = __CreateToolAppConfig(args, defaultPlatform, toolCommonArgConfig, defaultVSVersion) toolAppContext = ToolAppContext(log, lowLevelToolConfig, toolAppConfig) toolAppFlow = appFlowFactory.Create(toolAppContext) toolAppFlow.ProcessFromCommandLine(args, currentDir, toolConfig, userTag) if buildTiming: PrintBuildTiming(buildTiming) except GroupedException as ex: if buildTiming: PrintBuildTiming(buildTiming) for entry in ex.ExceptionList: print("ERROR: {0}".format(entry)) if lowLevelToolConfig.DebugEnabled: raise for entry in ex.ExceptionList: if isinstance(entry, ExitException): sys.exit(entry.ExitCode) sys.exit(1) except AggregateException as ex: if buildTiming: PrintBuildTiming(buildTiming) for entry in ex.ExceptionList: print("ERROR: {0}".format(entry)) if lowLevelToolConfig.DebugEnabled: if len(ex.ExceptionList) > 0: raise ex.ExceptionList[0] raise for entry in ex.ExceptionList: if isinstance(entry, ExitException): sys.exit(entry.ExitCode) sys.exit(1) except ExitException as ex: sys.exit(ex.ExitCode) except Exception as ex: if buildTiming: PrintBuildTiming(buildTiming) print("ERROR: {0}".format(ex)) if lowLevelToolConfig.DebugEnabled: raise sys.exit(1)