def __init__(self, config: Config, packages: List[Package], platformName: str, androidABIList: List[str]) -> None: super().__init__() if config.SDKPathAndroidProjectDir is None: raise EnvironmentError("Android environment variable {0} not defined".format(ToolEnvironmentVariableName.FSL_GRAPHICS_SDK_ANDROID_PROJECT_DIR)) strAppTemplatePath = "AndroidGradleCMake" templateFilePath = IOUtil.Join(config.SDKConfigTemplatePath, strAppTemplatePath) templateFileRecordManager = TemplateFileRecordManager(templateFilePath) templateFileProcessor = TemplateFileProcessor(config, platformName) strTemplatePath = IOUtil.Join(strAppTemplatePath, "CMake") extTemplate = CMakeGeneratorUtil.CodeTemplateCMake(config, strTemplatePath, "Ext", False, None) libTemplate = CMakeGeneratorUtil.CodeTemplateCMake(config, strTemplatePath, "Lib", False, None) exeTemplate = CMakeGeneratorUtil.CodeTemplateCMake(config, strTemplatePath, "Exe", False, None) templatePath = IOUtil.Join(config.SDKConfigTemplatePath, strAppTemplatePath) exeFileList = self.__ParseExeFileList(IOUtil.Join(templatePath, "ExeFiles.txt")) localSnippets = AndroidGradleCMakeSnippets(templatePath) cmakePackageRootVariables = self.__GenerateCmakePackageRootVariables(config, localSnippets) totalExeCount = 0 for mainPackage in packages: if mainPackage.Type == PackageType.Executable: totalExeCount = totalExeCount + 1 appPackageTemplateInfo = AndroidGeneratorUtil.AppPackageTemplateInfo(mainPackage) androidProjectDir = IOUtil.Join(config.SDKPathAndroidProjectDir, appPackageTemplateInfo.ProjectPathName) androidProjectCMakeDir = IOUtil.Join(androidProjectDir, ".FslCMake") for package in mainPackage.ResolvedBuildOrder: if not package.ResolvedPlatformNotSupported: if package.Type == PackageType.ExternalLibrary or package.Type == PackageType.HeaderLibrary: self.__GenerateCMakeFile(config, package, platformName, extTemplate, androidProjectDir, androidProjectCMakeDir) elif package.Type == PackageType.Library: self.__GenerateCMakeFile(config, package, platformName, libTemplate, androidProjectDir, androidProjectCMakeDir) elif package.Type == PackageType.Executable: self.__GenerateExecutable(config, package, platformName, exeTemplate, templateFileRecordManager, templateFileProcessor, appPackageTemplateInfo, androidProjectDir, androidProjectCMakeDir, exeFileList, androidABIList, cmakePackageRootVariables) # For now we only support doing 'exe' builds using full source for everything (like the old builder) if totalExeCount <= 0: config.DoPrint("No executables provided, nothing to build.")
def BuildPackages(generatorContext: GeneratorContext, config: Config, packages: List[Package], variantSettingsDict: Dict[str, str], buildArgs: List[str], buildForAllExe: Optional[str], generator: GeneratorPluginBase2, enableContentBuilder: bool, forceClaimInstallArea: bool, buildThreads: int, buildCommand: CommandType, printPathIfCMake: bool = False) -> None: PlatformUtil.CheckBuildPlatform(generatorContext.PlatformName) topLevelPackage = PackageListUtil.GetTopLevelPackage(packages) BuildVariantUtil.ValidateUserVariantSettings(config, topLevelPackage, variantSettingsDict) BuildVariantUtil.LogVariantSettings(config, variantSettingsDict) buildConfig = BuildConfigRecord(config.ToolConfig.ToolVersion, generatorContext.PlatformName, variantSettingsDict, buildCommand, buildArgs, buildForAllExe, generator, buildThreads) builder = Builder(generatorContext, config, topLevelPackage, buildConfig, enableContentBuilder, forceClaimInstallArea) # Print executable paths if enabled and its a cmake type build if printPathIfCMake and generatorContext.Generator.IsCMake and buildCommand == CommandType.Build and topLevelPackage is not None: for depPackage in topLevelPackage.ResolvedAllDependencies: package = depPackage.Package if package.Type == PackageType.Executable and builder.UsedBuildContext is not None and builder.UsedGeneratorConfig is not None: if not package.ResolvedPlatformNotSupported: runCommand = builder.TryGenerateRunCommandForExecutable( builder.UsedBuildContext, package, buildConfig, ["(EXE)"], builder.UsedGeneratorConfig) if runCommand is not None: config.DoPrint("Executable at: '{0}'".format( runCommand[0])) else: config.LogPrint( "Package '{0}' was not supported on this platform". format(package.Name))
def __ToolMainEx(self, currentDir: str, toolConfig: ToolConfig, localToolConfig: LocalToolConfig, templateDict: Dict[str, List[XmlNewTemplateFile]], performSanityCheck: bool = False) -> None: config = Config(self.Log, toolConfig, 'sdk', localToolConfig.BuildVariantsDict, localToolConfig.AllowDevelopmentPlugins) #config.ForceDisableAllWrite() config.PrintTitle() packageFilters = localToolConfig.BuildPackageFilters reservedProjectNames = set() # type: Set[str] packages = None # type: Optional[List[Package]] if not localToolConfig.NoParse: # Get the generator and see if its supported on this platform buildVariantConfig = BuildVariantConfigUtil.GetBuildVariantConfig( localToolConfig.BuildVariantsDict) generator = self.ToolAppContext.PluginConfigContext.GetGeneratorPluginById( localToolConfig.PlatformName, localToolConfig.Generator, buildVariantConfig, config.ToolConfig.DefaultPackageLanguage, config.ToolConfig.CMakeConfiguration, localToolConfig.GetUserCMakeConfig(), False) PlatformUtil.CheckBuildPlatform(generator.PlatformName) config.LogPrint("Active platform: {0}".format( generator.PlatformName)) generatorContext = GeneratorContext( config, self.ErrorHelpManager, packageFilters.RecipeFilterManager, config.ToolConfig.Experimental, generator) packages = ParsePackages( generatorContext, config, toolConfig.GetMinimalConfig(generator.CMakeConfig), currentDir, packageFilters) # Reserve the name of all packages if not packages is None: for package in packages: reservedProjectNames.add(package.Name) currentDir, projectName = DetermineDirAndProjectName( currentDir, localToolConfig.ProjectName) localConfig = LocalConfig(config, currentDir, projectName, localToolConfig.Template, localToolConfig.Force, templateDict, reservedProjectNames, localToolConfig.Language) configVariant = localConfig.ConfigVariant if not localToolConfig.AllowOverwrite: if os.path.isdir(configVariant.ProjectPath): raise EnvironmentError( "The project directory already exist: '{0}', you can use '{1}' to overwrite it." .format(configVariant.ProjectPath, g_allowOverwriteOption)) elif os.path.exists(configVariant.ProjectPath): raise EnvironmentError( "A file named '{0}' already exist, you can use '{1}' to overwrite it." .format(configVariant.ProjectPath, g_allowOverwriteOption)) visualStudioGUID = localToolConfig.VisualStudioGUID if packages: visualStudioGUID = GeneratorVCUtil.GenerateGUID( config, packages, visualStudioGUID) GenerateProject(config, localConfig, configVariant, visualStudioGUID, localToolConfig.GenFileOnly) if not localToolConfig.NoBuildGen: config.DoPrint("Generating build files") projectConfig = Config(self.Log, toolConfig, PluginSharedValues.TYPE_DEFAULT, localToolConfig.BuildVariantsDict, localToolConfig.AllowDevelopmentPlugins) theFiles = MainFlow.DoGetFiles( projectConfig, toolConfig.GetMinimalConfig(generator.CMakeConfig), configVariant.ProjectPath) buildVariantConfig = BuildVariantConfigUtil.GetBuildVariantConfig( localToolConfig.BuildVariantsDict) platformGeneratorPlugin = self.ToolAppContext.PluginConfigContext.GetGeneratorPluginById( localToolConfig.PlatformName, localToolConfig.Generator, buildVariantConfig, config.ToolConfig.DefaultPackageLanguage, config.ToolConfig.CMakeConfiguration, localToolConfig.GetUserCMakeConfig(), False) MainFlow.DoGenerateBuildFiles( self.ToolAppContext.PluginConfigContext, projectConfig, self.ErrorHelpManager, theFiles, platformGeneratorPlugin, packageFilters) if performSanityCheck: self.__PerformSanityCheck(config, currentDir, localConfig.ProjectName, localConfig.Template)
def __init__(self, generatorContext: GeneratorContext, config: Config, topLevelPackage: Package, buildConfig: BuildConfigRecord, enableContentBuilder: bool, forceClaimInstallArea: bool) -> None: super().__init__() self.Log = config localPlatformBuildContext = LocalPlatformBuildContext( config, generatorContext.Generator.OriginalPlatformName, generatorContext.Generator.IsCMake, buildConfig.BuildThreads) # Do a final filter that removes all unsupported packages resolvedBuildOrder = topLevelPackage.ResolvedBuildOrder resolvedBuildOrder = PackageFilter.FilterNotSupported( self.Log, topLevelPackage, resolvedBuildOrder) if not PackageFilter.WasThisAExecutableBuildAndAreThereAnyLeft( topLevelPackage.ResolvedBuildOrder, resolvedBuildOrder): self.Log.DoPrint("No executables left, skipping all") return # Run the recipe builder on the packages we have left # We run the recipe builder on the resolvedBuildOrder since it all required packages, not just the ones we need to build as libs and executables builderSettings = BuilderSettings() builderSettings.ForceClaimInstallArea = forceClaimInstallArea builderSettings.BuildThreads = buildConfig.BuildThreads RecipeBuilder.BuildPackagesInOrder(config, generatorContext, resolvedBuildOrder, builderSettings) resolvedBuildOrderBuildable = PackageFilter.FilterBuildablePackages( resolvedBuildOrder) if len(resolvedBuildOrderBuildable) == 0: config.DoPrint("Nothing to build!") return generatorConfig = GeneratorConfig( generatorContext.PlatformName, config.SDKConfigTemplatePath, config.ToolConfig, localPlatformBuildContext.NumBuildThreads, buildConfig.BuildCommand) generatorConfigReport = generatorContext.Generator.TryGenerateConfigReport( self.Log, generatorConfig, topLevelPackage) packageCount = len(resolvedBuildOrderBuildable) resolvedBuildOrderBuildable = self.__ApplyPlatformOrderChanges( resolvedBuildOrderBuildable, buildConfig.PlatformName) originalBuildArgs = buildConfig.BuildArgs # Handle the configure step masterBuildReport = None # type: Optional[GeneratorBuildReport] masterBuildVariableReport = None # type: Optional[GeneratorVariableReport] if generatorConfigReport is not None: # Setup some extra variables for configure self.__AddCustomVariables(generatorConfigReport.VariableReport, config.ToolConfig.ProjectInfo) self.__ConfigureBuild(generatorConfigReport, buildConfig) masterBuildReport = generatorConfigReport.MasterBuildReport masterBuildVariableReport = generatorConfigReport.MasterBuildVariableReport if masterBuildVariableReport is not None: self.__AddCustomVariables(masterBuildVariableReport, config.ToolConfig.ProjectInfo) # Acquire information about the build step generatorReport = generatorContext.Generator.GenerateReport( self.Log, generatorConfig, resolvedBuildOrderBuildable) generatorReportDict = generatorReport.PackageReportDict for generatorEntry in generatorReportDict.values(): if generatorEntry.VariableReport is not None: self.__AddCustomVariables(generatorEntry.VariableReport, config.ToolConfig.ProjectInfo) # Default content building for all platform (for those generators that don't add it to the build file) builderCanBuildContent = (generatorConfigReport is not None and generatorConfigReport.CanBuildContent) if enableContentBuilder and not builderCanBuildContent: for package in resolvedBuildOrderBuildable: if package.Type == PackageType.Executable: featureList = [ entry.Name for entry in package.ResolvedAllUsedFeatures ] if package.Path is None: raise Exception("Invalid package") ContentBuilder.Build(config, package.Path, featureList) # Windows runs its validation checks slightly differently runValidationChecks = (buildConfig.PlatformName != PlatformNameString.WINDOWS) buildContext = LocalBuildContext(config, localPlatformBuildContext, generatorReportDict, generatorContext.GeneratorName) if masterBuildReport is not None: if masterBuildVariableReport is None: raise Exception("master-build must have a variable report") self.__BuildMaster(buildConfig, buildContext, masterBuildReport, masterBuildVariableReport, topLevelPackage, originalBuildArgs, builderCanBuildContent, runValidationChecks, config.IsDryRun) # Build and run all the packages in the resolvedBuildOrderBuildable self.__BuildAndRunPackages(config, buildConfig, buildContext, resolvedBuildOrderBuildable, originalBuildArgs, builderCanBuildContent, runValidationChecks, masterBuildReport is None, config.IsDryRun, generatorConfig) if packageCount > 0: config.LogPrint("Build {0} packages".format(packageCount)) else: config.DoPrint("Nothing build!") if generatorContext.Generator.IsCMake and buildConfig.BuildCommand == CommandType.Clean: self.Log.DoPrint( "*** To do a full cmake clean build delete the out of source build folder ***" ) if not generatorContext.Generator.SupportCommandClean and buildConfig.BuildCommand == CommandType.Clean: self.Log.DoPrint("*** clean not supported by this builder ***") if not generatorContext.Generator.SupportCommandInstall and buildConfig.BuildCommand == CommandType.Install: self.Log.DoPrint("*** install not supported by this builder ***")
def __init__(self, generatorContext: GeneratorContext, config: Config, topLevelPackage: Package, buildConfig: BuildConfigRecord, enableContentBuilder: bool, forceClaimInstallArea: bool) -> None: super(Builder, self).__init__() self.Log = config localPlatformBuildContext = LocalPlatformBuildContext( config, generatorContext.Generator.OriginalName, buildConfig.BuildCommand, buildConfig.BuildThreads) # Do a final filter that removes all unsupported packages resolvedBuildOrder = topLevelPackage.ResolvedBuildOrder resolvedBuildOrder = PackageFilter.FilterNotSupported( self.Log, topLevelPackage, resolvedBuildOrder) if not PackageFilter.WasThisAExecutableBuildAndAreThereAnyLeft( topLevelPackage.ResolvedBuildOrder, resolvedBuildOrder): self.Log.DoPrint("No executables left, skipping all") return # Run the recipe builder on the packages we have left # We run the recipe builder on the resolvedBuildOrder since it all required packages, not just the ones we need to build as libs and executables builderSettings = BuilderSettings() builderSettings.ForceClaimInstallArea = forceClaimInstallArea builderSettings.BuildThreads = buildConfig.BuildThreads RecipeBuilder.BuildPackagesInOrder(config, generatorContext, resolvedBuildOrder, builderSettings) resolvedBuildOrderBuildable = PackageFilter.FilterBuildablePackages( resolvedBuildOrder) if len(resolvedBuildOrderBuildable) == 0: config.DoPrint("Nothing to build!") return generatorConfig = GeneratorConfig(config.SDKConfigTemplatePath, config.ToolConfig) generatorReportDict = generatorContext.Generator.GenerateReport( self.Log, generatorConfig, resolvedBuildOrderBuildable) packageCount = len(resolvedBuildOrderBuildable) resolvedBuildOrderBuildable = self.__ApplyPlatformOrderChanges( resolvedBuildOrderBuildable, buildConfig.PlatformName) originalBuildArgs = buildConfig.BuildArgs # Default content building for all platform (for those generators that don't add it to the build file) if enableContentBuilder: for package in resolvedBuildOrderBuildable: if package.Type == PackageType.Executable: featureList = [ entry.Name for entry in package.ResolvedAllUsedFeatures ] if package.AbsolutePath is None: raise Exception("Invalid package") ContentBuilder.Build(config, package.AbsolutePath, featureList) # Windows runs its validation checks slightly differently runValidationChecks = (buildConfig.PlatformName != PlatformNameString.WINDOWS) buildContext = LocalBuildContext(config, localPlatformBuildContext, generatorReportDict, generatorContext.GeneratorName) for package in resolvedBuildOrderBuildable: config.LogPrint("Building package: {0}".format(package.Name)) config.LogPrint("Package location: {0}".format( package.AbsolutePath)) if not config.IsDryRun: buildEnv = os.environ.copy() # type: Dict[str, str] buildEnv[CONFIG_FSLBUILDCONTENT_ENABLED] = "false" BuildVariantUtil.ExtendEnvironmentDictWithVariants( config, buildEnv, package, buildConfig.VariantSettingsDict) buildConfig.BuildArgs = list(originalBuildArgs) if config.Verbosity > 4: config.DoPrint("Package build arguments1: {0}".format( buildConfig.BuildArgs)) config.DoPrint("General build arguments2: {0}".format( originalBuildArgs)) strRunCommands = buildConfig.RunCommand runCommands = None # type: Optional[List[str]] if strRunCommands is not None: userRunCommands = shlex.split(strRunCommands) runCommands = self.__TryGenerateRunCommandForExecutable( buildContext, package, buildConfig.VariantSettingsDict, userRunCommands) if runValidationChecks: featureList = [ entry.Name for entry in package.ResolvedAllUsedFeatures ] Validate.ValidatePlatform(config, buildConfig.PlatformName, featureList, 4) self.__BuildPackage(buildContext, package, buildConfig, buildEnv, runCommands) if packageCount > 0: config.LogPrint("Build {0} packages".format(packageCount)) else: config.DoPrint("Nothing build!")