def __TestGetPackageLoader(config: Config, files: List[str], platformId: str) -> PackageLoader: packageFilters = PackageFilters() #generatorCMakeConfig = __GetTestGeneratorCMakeConfig() log = config # type: Log pluginConfigContext = PluginConfig.InitPluginConfigContext( log, config.ToolConfig.ToolVersion, allowDevelopmentPlugins=True) buildVariantConfig = BuildVariantConfig.Debug platformGeneratorPlugin = pluginConfigContext.GetGeneratorPluginById( platformId, GeneratorType.Default, buildVariantConfig, True, config.ToolConfig.CMakeConfiguration, None) return PackageLoader(config, files, platformGeneratorPlugin)
def __TestGenerateBuildFiles(config: Config, files: List[str], platformId: str) -> Dict[str, List[Package]]: errorHelpManager = ErrorHelpManager() packageFilters = PackageFilters() log = config # type: Log #generatorCMakeConfig = __GetTestGeneratorCMakeConfig() pluginConfigContext = PluginConfig.InitPluginConfigContext( log, config.ToolConfig.ToolVersion, allowDevelopmentPlugins=True) buildVariantConfig = BuildVariantConfig.Debug platform = pluginConfigContext.GetGeneratorPluginById( platformId, GeneratorType.Default, buildVariantConfig, True, config.ToolConfig.CMakeConfiguration, None) buildFilesDict = DoGenerateBuildFiles3(pluginConfigContext, config, errorHelpManager, files, platform, packageFilters) return { dictKey: dictValue[0] for dictKey, dictValue in buildFilesDict.items() }
def __TestGenerateBuildFilesAllPlatforms( config: Config, files: List[str]) -> Dict[str, List[Package]]: res = {} # type: Dict[str, List[Package]] for platformId in PackageConfig.APPROVED_PLATFORM_NAMES: errorHelpManager = ErrorHelpManager() packageFilters = PackageFilters() log = config # type: Log #generatorCMakeConfig = __GetTestGeneratorCMakeConfig() pluginConfigContext = PluginConfig.InitPluginConfigContext( log, config.ToolConfig.ToolVersion, allowDevelopmentPlugins=True) pluginConfigContext.SetVSVersion( str(config.ToolConfig.GetVisualStudioDefaultVersion())) buildVariantConfig = BuildVariantConfig.Debug platform = pluginConfigContext.GetGeneratorPluginById( platformId, GeneratorType.Default, buildVariantConfig, config.ToolConfig.DefaultPackageLanguage, config.ToolConfig.CMakeConfiguration, None, False) resultTuple = DoGenerateBuildFilesNow(pluginConfigContext, config, errorHelpManager, files, platform, packageFilters) if resultTuple is not None: res[platformId] = resultTuple[0] return res
def __Run(appFlowFactory: AToolAppFlowFactory, strToolAppTitle: str, toolCommonArgConfig: ToolCommonArgConfig, lowLevelToolConfig: LowLevelToolConfig, allowStandaloneMode: bool) -> None: log = Log(strToolAppTitle, lowLevelToolConfig.VerbosityLevel, showAppTitleIfVerbose=True) pluginConfigContext = PluginConfig.InitPluginConfigContext( log, CurrentVersion, lowLevelToolConfig.AllowDevelopmentPlugins) generatorIds = __PrepareGeneratorPlugins(pluginConfigContext, 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 buildPlatformType = PlatformUtil.DetectBuildPlatformType() toolConfigPath = __GetToolConfigPath(toolConfigFile) toolConfig = ToolConfig(lowLevelToolConfig, buildPlatformType, CurrentVersion, 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 errorHelpManager = ErrorHelpManager() 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: pluginConfigContext.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, errorHelpManager, lowLevelToolConfig, toolAppConfig, pluginConfigContext) toolAppFlow = appFlowFactory.Create(toolAppContext) toolAppFlow.ProcessFromCommandLine(args, currentDir, toolConfig, userTag) if buildTiming: PrintBuildTiming(buildTiming) except GroupedException as ex: __OnErrorInfo(buildTiming, errorHelpManager) 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: __OnErrorInfo(buildTiming, errorHelpManager) 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: __OnErrorInfo(buildTiming, errorHelpManager) sys.exit(ex.ExitCode) except Exception as ex: __OnErrorInfo(buildTiming, errorHelpManager) print("ERROR: {0}".format(ex)) if lowLevelToolConfig.DebugEnabled: raise sys.exit(1)
def __RunStandalone(appFlowFactory: AToolAppFlowFactory, strToolAppTitle: str, toolCommonArgConfig: ToolCommonArgConfig, lowLevelToolConfig: LowLevelToolConfig) -> None: log = Log(strToolAppTitle, lowLevelToolConfig.VerbosityLevel, showAppTitleIfVerbose=True) pluginConfigContext = PluginConfig.InitPluginConfigContext( log, CurrentVersion, lowLevelToolConfig.AllowDevelopmentPlugins) generatorIds = __PrepareGeneratorPlugins(pluginConfigContext, lowLevelToolConfig, toolCommonArgConfig) ### Do the actual command line parsing parser = __CreateParser(toolCommonArgConfig, True) if toolCommonArgConfig.AddPlatformArg: parser.add_argument('-p', '--platform', required=True, help='Select build platform: {0}'.format( ", ".join(generatorIds))) buildTiming = None errorHelpManager = ErrorHelpManager() try: userTag = appFlowFactory.CreateStandaloneUserTag() appFlowFactory.AddCustomStandaloneArguments(parser, userTag) args = parser.parse_args() if toolCommonArgConfig.ProcessRemainingArgs: args.RemainingArgs = __ProcessRemainingArgs(args.RemainingArgs) if toolCommonArgConfig.SupportBuildTime and args.BuildTime: buildTiming = BuildTimer() currentDir = lowLevelToolConfig.CurrentDir toolAppConfig = __CreateToolAppConfig(args, args.platform, toolCommonArgConfig, 0) toolAppContext = ToolAppContext(log, errorHelpManager, lowLevelToolConfig, toolAppConfig, pluginConfigContext) toolAppFlow = appFlowFactory.Create(toolAppContext) toolAppFlow.ProcessFromStandaloneCommandLine(args, currentDir, userTag) if buildTiming: PrintBuildTiming(buildTiming) except GroupedException as ex: __OnErrorInfo(buildTiming, errorHelpManager) 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: __OnErrorInfo(buildTiming, errorHelpManager) 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: __OnErrorInfo(buildTiming, errorHelpManager) sys.exit(ex.ExitCode) except Exception as ex: __OnErrorInfo(buildTiming, errorHelpManager) print("ERROR: {0}".format(ex)) if lowLevelToolConfig.DebugEnabled: raise sys.exit(1)