def __GenerateBuildScript(self, config: Config, package: Package, template: str, buildBasePath: str) -> None: if package.AbsolutePath is None or package.ResolvedBuildPath is None: raise Exception("Invalid package") strContent = "" for depPackage in package.ResolvedBuildOrder: if not depPackage.IsVirtual: if depPackage.AbsolutePath is None or depPackage.ResolvedBuildPath is None: raise Exception("Invalid package") path = IOUtil.Join(depPackage.AbsolutePath, depPackage.ResolvedBuildPath) path = config.ToBashPath(path) strContent += "pushd " + path + " > /dev/null\n" strContent += 'make "$@"\n' strContent += "popd > /dev/null\n" path = IOUtil.Join(package.AbsolutePath, package.ResolvedBuildPath) path = config.ToBashPath(path) strContent += 'pushd '+ path +' > /dev/null\n' strContent += 'make "$@"\n' strContent += "popd > /dev/null\n" build = template build = build.replace("##PACKAGE_BUILD_COMMANDS##", strContent) # This file has been superseded by the 'FslBuild.py' script # so for now we just write it inside the build dir to keep it around if needed dstFile = IOUtil.Join(buildBasePath, "build_qnx.sh") #dstFile = IOUtil.Join(package.AbsolutePath, "build_qnx.sh") if not config.DisableWrite: IOUtil.WriteFileIfChanged(dstFile, build) IOUtil.SetFileExecutable(dstFile)
def Build(config: Config, packagePath: PackagePath, featureList: List[str], outputPath: Optional[str] = None) -> None: currentPath = packagePath.AbsoluteDirPath contentBuildDir = ToolSharedValues.CONTENT_BUILD_FOLDER_NAME contentBuildPath = IOUtil.Join(currentPath, contentBuildDir) contentOutputPath = GetContentOutputPath( packagePath) if outputPath is None else outputPath if not IOUtil.IsDirectory(contentBuildPath): config.LogPrintVerbose( 1, "No '{0}' directory present at '{1}' so there is no content to process." .format(contentBuildDir, currentPath)) return packageBuildPath = IOUtil.Join(currentPath, config.GetBuildDir()) if not config.DisableWrite: IOUtil.SafeMakeDirs(packageBuildPath) contentProcessorManager = GetContentProcessorManager(config, featureList) Builder(config, packageBuildPath, contentBuildPath, contentOutputPath, contentProcessorManager)
def __TryTargetIncludeDirectoriesGetExternalDependencyString(config: Config, package: Package, directExternalDeps: Union[PackageExternalDependency, PackagePlatformExternalDependency], templatePackageTargetIncludeDirEntry: str, templatePackageTargetIncludeDirVirtualEntry: str, pathType: int) -> Optional[str]: add = None # type: Optional[str] relativeCurrentIncDir = None # type: Optional[str] if directExternalDeps.Type != ExternalDependencyType.Find: currentIncDir = directExternalDeps.Include if currentIncDir is not None: if package.AbsolutePath is None: raise Exception("Invalid package") packageRootPath = config.ToPath(package.AbsolutePath) if currentIncDir.startswith(packageRootPath): relativeCurrentIncDir = currentIncDir[len(packageRootPath)+1:] if pathType == CMakePathType.LocalRelative else Util.ChangeToCMakeVariables(currentIncDir) add = "\n" + __GenerateDirEntryString(GetAccessTypeString(package, directExternalDeps.Access), relativeCurrentIncDir, templatePackageTargetIncludeDirEntry) else: currentTemplate = templatePackageTargetIncludeDirEntry relativeCurrentIncDir = config.TryToPath(currentIncDir) if relativeCurrentIncDir is None: relativeCurrentIncDir = currentIncDir if pathType != CMakePathType.LocalRelative: relativeCurrentIncDir = Util.ChangeToCMakeVariables(relativeCurrentIncDir) else: relativeCurrentIncDir = Util.ChangeToCMakeEnvVariables(relativeCurrentIncDir) currentTemplate = templatePackageTargetIncludeDirVirtualEntry add = "\n" + __GenerateDirEntryString(GetAccessTypeString(package, directExternalDeps.Access), relativeCurrentIncDir, currentTemplate) else: add = "\n %s ${%s_INCLUDE_DIRS}" % (GetAccessTypeString(package, directExternalDeps.Access), directExternalDeps.Name) return add
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 __DiscoverMissingPackages( self, config: Config, activePlatform: GeneratorPluginBase, packageDict: Dict[str, List[XmlGenFile]], genFiles: List[XmlGenFile]) -> Dict[str, XmlGenFile]: """ Create a dict where the key is the name of the missing package and the value is the xmlGenFile that first requested it """ missingPackages = {} # type: Dict[str, XmlGenFile] for entry in genFiles: for dep in entry.DirectDependencies: if not dep.Name in packageDict: if not dep.Name in missingPackages: missingPackages[dep.Name] = entry if config.Verbosity > 1: config.LogPrint(".. {0} missing {1}".format( entry.Name, dep.Name)) for platform in list(entry.Platforms.values()): if activePlatform.Id == PluginSharedValues.PLATFORM_ID_ALL or platform.Name == activePlatform.Name: for dep in platform.DirectDependencies: if not dep.Name in packageDict: if not dep.Name in missingPackages: missingPackages[dep.Name] = entry if config.Verbosity >= 2 and config.Verbosity < 4: config.LogPrint( ".. Platform {0} package {1} missing {2}" .format(platform.Name, entry.Name, dep.Name)) if config.Verbosity >= 4: config.LogPrint( ".. Platform {0} package {1} missing {2}". format(platform.Name, entry.Name, dep.Name)) return missingPackages
def Process(self, currentDirPath: str, toolConfig: ToolConfig, localToolConfig: LocalToolConfig) -> None: # Check if a environment variable has been set to disable this tool # This is for example done by FslBuild to prevent multiple executions of content building. toolEnabled = IOUtil.TryGetEnvironmentVariable(CONFIG_FSLBUILDCONTENT_ENABLED) featureList = localToolConfig.BuildPackageFilters.FeatureNameList config = Config(self.Log, toolConfig, localToolConfig.PackageConfigurationType, localToolConfig.BuildVariantsDict, localToolConfig.AllowDevelopmentPlugins) # Get the platform and see if its supported buildVariantConfig = BuildVariantConfigUtil.GetBuildVariantConfig(localToolConfig.BuildVariantsDict) generator = self.ToolAppContext.PluginConfigContext.GetGeneratorPluginById(localToolConfig.PlatformName, localToolConfig.Generator, buildVariantConfig, False, config.ToolConfig.CMakeConfiguration, localToolConfig.GetUserCMakeConfig()) PlatformUtil.CheckBuildPlatform(generator.PlatformName) generatorContext = GeneratorContext(config, self.ErrorHelpManager, localToolConfig.BuildPackageFilters.RecipeFilterManager, config.ToolConfig.Experimental, generator) config.LogPrint("Active platform: {0}".format(generator.PlatformName)) discoverFeatureList = '*' in featureList topLevelPackage = None if discoverFeatureList or localToolConfig.Project is None: if discoverFeatureList: config.LogPrint("No features specified, so using package to determine them") topLevelPackage = self.__ResolveAndGetTopLevelPackage(generatorContext, config, currentDirPath, toolConfig.GetMinimalConfig(), localToolConfig.Recursive) if discoverFeatureList: featureList = [entry.Name for entry in topLevelPackage.ResolvedAllUsedFeatures] #if localToolConfig.Project is None: # executeablePackage = PackageListUtil.FindFirstExecutablePackage(packages) # localToolConfig.Project = executeablePackage.ShortName if localToolConfig.Validate: Validate.ValidatePlatform(config, localToolConfig.PlatformName, featureList) if topLevelPackage is None: topLevelPackage = self.__ResolveAndGetTopLevelPackage(generatorContext, config, currentDirPath, toolConfig.GetMinimalConfig(), localToolConfig.Recursive) RecipeBuilder.ValidateInstallationForPackages(config, generatorContext, topLevelPackage.ResolvedBuildOrder) if toolEnabled is not None and not ParseUtil.ParseBool(toolEnabled): if self.Log.Verbosity > 0: print("FslBuildContent has been disabled by environment variable {0} set to {1}".format(CONFIG_FSLBUILDCONTENT_ENABLED, toolEnabled)) return locations = toolConfig.PackageConfiguration[localToolConfig.PackageConfigurationType].Locations if not localToolConfig.Recursive or topLevelPackage is None: location = self.__TryFindLocation(locations, currentDirPath) if location is None: raise Exception("Could not locate location for {0}".format(currentDirPath)) packagePath = PackagePath(currentDirPath, location) ContentBuilder.Build(config, packagePath, featureList, localToolConfig.Output) else: # Location not found, but its ok since '-r' was specified and we have a top level package for foundPackage in topLevelPackage.ResolvedBuildOrder: if foundPackage.Type == PackageType.Executable: foundFeatureList = [entry.Name for entry in foundPackage.ResolvedAllUsedFeatures] if foundPackage.Path is None: raise Exception("Invalid package") ContentBuilder.Build(config, foundPackage.Path, foundFeatureList)
def Process(self, currentDirPath: str, toolConfig: ToolConfig, localToolConfig: LocalToolConfig) -> None: config = Config(self.Log, toolConfig, localToolConfig.PackageConfigurationType, localToolConfig.BuildVariantsDict, localToolConfig.AllowDevelopmentPlugins) #if localToolConfig.DryRun: # config.ForceDisableAllWrite() if localToolConfig.IgnoreNotSupported: config.IgnoreNotSupported = True self.Log.PrintTitle() packageFilters = localToolConfig.BuildPackageFilters buildVariantConfig = BuildVariantConfigUtil.GetBuildVariantConfig(localToolConfig.BuildVariantsDict) generator = self.ToolAppContext.PluginConfigContext.GetGeneratorPluginById(localToolConfig.PlatformName, localToolConfig.Generator, buildVariantConfig, config.ToolConfig.DefaultPackageLanguage, config.ToolConfig.CMakeConfiguration, localToolConfig.GetUserCMakeConfig(), False) theFiles = MainFlow.DoGetFiles(config, toolConfig.GetMinimalConfig(generator.CMakeConfig), currentDirPath, localToolConfig.Recursive) generatorContext = GeneratorContext(config, self.ErrorHelpManager, packageFilters.RecipeFilterManager, config.ToolConfig.Experimental, generator) packages = MainFlow.DoGetPackages(generatorContext, config, theFiles, packageFilters, autoAddRecipeExternals=False) topLevelPackage = PackageListUtil.GetTopLevelPackage(packages) requestedFiles = None if config.IsSDKBuild else theFiles if localToolConfig.SaveJson is not None: if localToolConfig.BuildPackageFilters.ExtensionNameList is None: raise Exception("Invalid config missing ExtensionNameList filters") config.LogPrint("Saving to json file '{0}'".format(localToolConfig.SaveJson)) generatorConfig = GeneratorConfig(generator.PlatformName, config.SDKConfigTemplatePath, config.ToolConfig, 1, CommandType.Build) InfoSaver.SavePackageMetaDataToJson(generatorContext, generatorConfig, localToolConfig.SaveJson, config, topLevelPackage, localToolConfig.PackageTypeList, localToolConfig.IncludeGeneratorReport) if localToolConfig.ListFeatures: Builder.ShowFeatureList(self.Log, topLevelPackage, requestedFiles) if localToolConfig.ListVariants: requestedFiles = None if config.IsSDKBuild else theFiles Builder.ShowVariantList(self.Log, topLevelPackage, requestedFiles, generator) if localToolConfig.ListBuildVariants: Builder.ShowBuildVariantList(self.Log, generator) if localToolConfig.ListExtensions: Builder.ShowExtensionList(self.Log, topLevelPackage, requestedFiles) if localToolConfig.ListRequirements: Builder.ShowRequirementList(self.Log, topLevelPackage, requestedFiles) if localToolConfig.ListRecipes: RecipeInfo.ShowRecipeList(self.Log, topLevelPackage, requestedFiles) if localToolConfig.Stats: self.__ShowStats(topLevelPackage)
def DoGenerateBuildFiles( pluginConfigContext: PluginConfigContext, config: Config, errorHelpManager: ErrorHelpManager, files: List[str], platformGeneratorPlugin: GeneratorPlugin, packageFilters: PackageFilters ) -> Union[List[Package], MultiPlatformPackageResultType]: config.LogPrint("- Generating build files") isSDKBuild = len(files) <= 0 packageLoader = PackageLoader(config, files, platformGeneratorPlugin) res = [] # type: Union[List[Package], MultiPlatformPackageResultType] if platformGeneratorPlugin.PlatformId == PluginSharedValues.PLATFORM_ID_ALL: resDict = {} # type: MultiPlatformPackageResultType for entry in pluginConfigContext.GetGeneratorPlugins(): if not config.IsTestMode or not entry.InDevelopment: packages = __ResolveAndGenerate(config, errorHelpManager, entry, copy.deepcopy(packageLoader), packageFilters, isSDKBuild) resDict[entry.PlatformName] = (packages, entry) res = resDict else: res = __ResolveAndGenerate(config, errorHelpManager, platformGeneratorPlugin, packageLoader, packageFilters, isSDKBuild) return res
def DoGenerate(self, platformContext: PlatformContext, config: Config, packages: List[Package]) -> List[Package]: generator = None # type: Optional[GeneratorBase] topLevelPackage = PackageListUtil.GetTopLevelPackage(packages) androidABIList = self.OptionAndroidABI_all if GEN_MAGIC_VARIANT_ANDROID_ABI in config.VariantsDict: androidABI = config.VariantsDict[GEN_MAGIC_VARIANT_ANDROID_ABI] if androidABI != 'all': if not androidABI in self.VariantAndroidABI.Options: raise Exception( "'{0}' is not a valid option expected one of these {1}" .format(androidABI, self.VariantAndroidABI.Options)) androidABIList = [androidABI] # remove unsupported ABI's if there are others available to build if self.__ContainsFeature(topLevelPackage.ResolvedAllUsedFeatures, "vulkan"): if len( androidABIList ) > 1 and AndroidABIOption.DeprecatedArmeAbi in androidABIList: config.LogPrint( "INFO: Vulkan does not support ANDROID_ABI '{0}' removing the ABI and building the rest" .format(AndroidABIOption.DeprecatedArmeAbi)) androidABIList.remove(AndroidABIOption.DeprecatedArmeAbi) generator = GeneratorAndroidGradleCMake(config, packages, self.Name, androidABIList) return self.GenerateDone(config, packages, self.Name, generator)
def __ResolveAndGenerate(config: Config, errorHelpManager: ErrorHelpManager, platformGeneratorPlugin: GeneratorPlugin, packageLoader: PackageLoader, packageFilters: PackageFilters, isSDKBuild: bool, writeGraph: bool) -> List[Package]: generatorContext = GeneratorContext(config, errorHelpManager, packageFilters.RecipeFilterManager, config.ToolConfig.Experimental, platformGeneratorPlugin) process = PackageLoadAndResolveProcess(config, packageLoader, platformGeneratorPlugin, writeGraph=writeGraph) process.Resolve(generatorContext, packageFilters) if not isSDKBuild: for package in process.Packages: if not package.ResolvedPlatformSupported and package.Type != PackageType.TopLevel: notSupported = LocalUtil.BuildListOfDirectlyNotSupported( package) notSupportedNames = Util.ExtractNames(notSupported) config.DoPrintWarning( "{0} was marked as not supported on this platform by package: {1}" .format(package.Name, notSupportedNames)) return platformGeneratorPlugin.Generate(generatorContext, config, process.Packages)
def ExtractArguments(toolAppContext: ToolAppContext, config: Config, exePackages: List[Package], extractArguments: str, currentDir: str) -> Dict[Package, JsonDictType]: config.LogPrint("Building all executable packages to extract their command line arguments") filterDir = None if extractArguments == '*' else currentDir res = {} # type: Dict[Package, JsonDictType] for package in exePackages: if filterDir is None or package.AbsolutePath == filterDir: config.LogPrint("- Building and running {0}".format(package.Name)) arguments = TryBuildAndRun(toolAppContext, config, package) if arguments is not None: res[package] = arguments # quick exit #return res return res
def DoGetFiles(config: Config, toolMiniConfig: ToolMinimalConfig, currentDir: str, allowRecursiveScan: bool = False) -> List[str]: """ :param currentDir: currentDir must be part of a package root :param allowRecursiveScan: if True and not a sdk build all subdirectories will be scanned """ if allowRecursiveScan and config.IsSDKBuild: config.DoPrintWarning("recursive is ignored for sdk builds") if ToolConfigPackageRootUtil.TryFindRootDirectory( toolMiniConfig.RootDirectories, currentDir) is None: raise UsageErrorException( "the folder '{0}' does not reside inside one of the root dirs". format(currentDir)) theFiles = [] # type: List[str] if not config.IsSDKBuild: if allowRecursiveScan: theFiles += IOUtil.FindFileByName(currentDir, config.GenFileName, toolMiniConfig.IgnoreDirectories) else: theFile = IOUtil.Join(currentDir, config.GenFileName) if not os.path.isfile(theFile): raise Exception("File not found: '{0}'".format(theFile)) theFiles.append(theFile) return theFiles
def TryBuildAndRun(toolAppContext: ToolAppContext, config: Config, package: Package) -> Optional[JsonDictType]: if package.ResolvedPlatformNotSupported: return None if package.AbsolutePath is None: raise Exception("Invalid package") workDir = package.AbsolutePath tmpOutputFilename = IOUtil.Join(workDir, 'FslBuildDoc_AppArguments.json') try: # FslBuild.py --ForAllExe "(EXE) --System.Arguments.Save <filename>" toolFlowConfig = ToolFlowBuild.GetDefaultLocalConfig() toolFlowConfig.SetToolAppConfigValues(toolAppContext.ToolAppConfig) toolFlowConfig.ForAllExe = '(EXE) --System.Arguments.Save {0} -h'.format( tmpOutputFilename) buildFlow = ToolFlowBuild.ToolFlowBuild(toolAppContext) buildFlow.Process(workDir, config.ToolConfig, toolFlowConfig) return ReadJsonFile(tmpOutputFilename) except (Exception) as ex: if toolAppContext.LowLevelToolConfig.DebugEnabled: raise config.LogPrint( "Failed to build and run '{0}' due to exception {1}".format( package.Name, ex)) return None finally: IOUtil.RemoveFile(tmpOutputFilename)
def __patchABIList(self, config: Config, package: Package, androidABIList: List[str]) -> List[str]: if not AndroidABIOption.DeprecatedArmeAbi in androidABIList and not AndroidABIOption.DeprecatedMips in androidABIList and not AndroidABIOption.DeprecatedMips64 in androidABIList: return androidABIList removed = [] result = list(androidABIList) for depPackage in package.ResolvedBuildOrder: if depPackage.Name.lower() == "assimp": if AndroidABIOption.DeprecatedArmeAbi in androidABIList: result.remove(AndroidABIOption.DeprecatedArmeAbi) removed.append(AndroidABIOption.DeprecatedArmeAbi) if AndroidABIOption.DeprecatedMips in androidABIList: result.remove(AndroidABIOption.DeprecatedMips) removed.append(AndroidABIOption.DeprecatedMips) if AndroidABIOption.DeprecatedMips64 in androidABIList: result.remove(AndroidABIOption.DeprecatedMips64) removed.append(AndroidABIOption.DeprecatedMips64) # If all would be removed by this patch, dont remove anything and let the checker catch incompatibility issue so its reported if len(result) <= 0: return androidABIList if len(removed) > 0: config.LogPrint("Removed incompatible assimp ABI's: %s" % (removed)) return result
def SimpleTestHookGetPackageLoaderOneFileEx( file: str, config: Config) -> List[PackageLoader]: config.ForceDisableAllWrite() theFiles = ToUnitTestPaths(config, [file]) res = [] # type: List[PackageLoader] for platformId in PackageConfig.APPROVED_PLATFORM_NAMES: res.append(__TestGetPackageLoader(config, theFiles, platformId)) return res
def Process(self, currentDirPath: str, toolConfig: ToolConfig, localToolConfig: LocalToolConfig) -> None: config = Config(self.Log, toolConfig, localToolConfig.PackageConfigurationType, localToolConfig.BuildVariantsDict, localToolConfig.AllowDevelopmentPlugins) if localToolConfig.DryRun: config.ForceDisableAllWrite() if localToolConfig.IgnoreNotSupported: config.IgnoreNotSupported = True # Get the platform and see if its supported platformGeneratorPlugin = PluginConfig.GetGeneratorPluginById(localToolConfig.PlatformName, localToolConfig.Generator, False, config.ToolConfig.CMakeConfiguration, localToolConfig.GetUserCMakeConfig()) PlatformUtil.CheckBuildPlatform(platformGeneratorPlugin.PlatformName) config.LogPrint("Active platform: {0}".format(platformGeneratorPlugin.PlatformName)) theFiles = MainFlow.DoGetFiles(config, toolConfig.GetMinimalConfig(), currentDirPath, localToolConfig.Recursive) generatorContext = GeneratorContext(config, localToolConfig.BuildPackageFilters.RecipeFilterManager, config.ToolConfig.Experimental, platformGeneratorPlugin) PluginConfig.SetLegacyGeneratorType(localToolConfig.GenType) packageFilters = localToolConfig.BuildPackageFilters packages = MainFlow.DoGenerateBuildFilesNoAll(config, theFiles, platformGeneratorPlugin, packageFilters) topLevelPackage = PackageListUtil.GetTopLevelPackage(packages) requestedFiles = None if config.IsSDKBuild else theFiles # We need the generator to be able to examine its support if localToolConfig.ListFeatures or localToolConfig.ListVariants or localToolConfig.ListExtensions or localToolConfig.ListRequirements: if localToolConfig.ListFeatures: Builder.ShowFeatureList(self.Log, config, topLevelPackage, requestedFiles) if localToolConfig.ListVariants: Builder.ShowVariantList(self.Log, topLevelPackage, requestedFiles, platformGeneratorPlugin) if localToolConfig.ListExtensions: Builder.ShowExtensionList(self.Log, topLevelPackage, requestedFiles) if localToolConfig.ListRequirements: Builder.ShowRequirementList(self.Log, config, topLevelPackage, requestedFiles) else: if localToolConfig.BuildPackageFilters is None or localToolConfig.BuildPackageFilters.ExtensionNameList is None: raise Exception("localToolConfig.BuildPackageFilters.ExtensionNameList not set") Builder.BuildPackages(generatorContext, config, packages, localToolConfig.BuildVariantsDict, localToolConfig.RemainingArgs, localToolConfig.ForAllExe, platformGeneratorPlugin, localToolConfig.EnableContentBuilder, localToolConfig.ForceClaimInstallArea, localToolConfig.BuildThreads, localToolConfig.Command)
def __ToolMainListTemplates(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.PrintTitle() sortedLanguages = list(templateDict.keys()) sortedLanguages.sort(key=lambda s: s.lower()) for language in sortedLanguages: sortedTemplateEntries = list(templateDict[language]) sortedTemplateEntries.sort(key=lambda s: s.Id.lower()) print("Language: {0}".format(language)) for templateEntry in sortedTemplateEntries: print("- {0}".format(templateEntry.Name))
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 Process(self, currentDirPath: str, toolConfig: ToolConfig, localToolConfig: LocalToolConfig) -> None: config = Config(self.Log, toolConfig, localToolConfig.PackageConfigurationType, localToolConfig.BuildVariantsDict, localToolConfig.AllowDevelopmentPlugins) # Disable downloads and writes if config.ToolConfig.Experimental is not None: config.ToolConfig.Experimental.AllowDownloads = False config.ForceDisableAllWrite() if localToolConfig.IgnoreNotSupported: config.IgnoreNotSupported = True self.Log.PrintTitle() if not localToolConfig.ForceYes and not self.__AskYesNo("Delete all build directories"): return packageFilters = localToolConfig.BuildPackageFilters generator = PluginConfig.GetGeneratorPluginById(localToolConfig.PlatformName, False) theFiles = MainFlow.DoGetFiles(config, toolConfig.GetMinimalConfig(), currentDirPath, localToolConfig.Recursive) generatorContext = GeneratorContext(config, config.ToolConfig.Experimental, generator) packages = MainFlow.DoGetPackages(generatorContext, config, theFiles, packageFilters, autoAddRecipeExternals=False) topLevelPackage = PackageListUtil.GetTopLevelPackage(packages) requestedFiles = None if config.IsSDKBuild else theFiles self.Log.LogPrint("Deleting package build directories") for package in topLevelPackage.ResolvedBuildOrder: if package.AbsoluteBuildPath is not None: # While the path is most likely normalized we force it here removePath = IOUtil.NormalizePath(package.AbsoluteBuildPath) if IOUtil.IsDirectory(removePath): self.Log.LogPrint("- Deleting '{0}'".format(removePath)) drive, tail = os.path.splitdrive(removePath) driveId = IOUtil.NormalizePath(drive).lower() removePathId = removePath.lower() # some basic checks to prevent deletes of '/' or a drive letter. if ('../' in removePath or '/..' in removePath or removePath == '/' or removePath == '..' or len(removePath) <= 0 or removePathId==driveId or removePath.endswith('/')): raise Exception("Invalid path format '{0}'".format(removePath)) IOUtil.SafeRemoveDirectoryTree(removePath)
def DoGenerateBuildFilesNoAll(config: Config, errorHelpManager: ErrorHelpManager, files: List[str], platformGeneratorPlugin: GeneratorPlugin, packageFilters: PackageFilters) -> List[Package]: config.LogPrint("- Generating build files") isSDKBuild = len(files) <= 0 packageLoader = PackageLoader(config, files, platformGeneratorPlugin) return __ResolveAndGenerate(config, errorHelpManager, platformGeneratorPlugin, packageLoader, packageFilters, isSDKBuild, False)
def __RunToolMainForSanityCheck(self, currentDir: str, toolConfig: ToolConfig, localToolConfig: LocalToolConfig, templateDict: Dict[str, List[XmlNewTemplateFile]], debugMode: bool, templateList: List[str]) -> None: currentDir = IOUtil.Join(currentDir, GlobalStrings.SanityCheckDir) IOUtil.SafeMakeDirs(currentDir) if not IOUtil.IsDirectory(currentDir): raise Exception("could not create work directory: '{0}'".format(currentDir)) isBuilding = False try: for currentTemplateName in templateList: if currentTemplateName == '*' or currentTemplateName.startswith('/') or '..' in currentTemplateName: raise Exception("Usage error") localToolConfig.Template = currentTemplateName localToolConfig.ProjectName = "{0}_{1}".format(GlobalStrings.SanityCheckProjectName, localToolConfig.Template) localToolConfig.Force = True if debugMode: generatedDir = IOUtil.Join(currentDir, localToolConfig.ProjectName) if IOUtil.IsDirectory(generatedDir): continue print(("Generating sanity project for template '{0}' begin".format(localToolConfig.Template))) self.__ToolMainEx(currentDir, toolConfig, localToolConfig, templateDict, False) print(("Generating sanity project for template '{0}' ended successfully".format(localToolConfig.Template))) isBuilding = True config = Config(self.Log, toolConfig, 'sdk', localToolConfig.BuildVariantsDict, localToolConfig.AllowDevelopmentPlugins) print(("Building sanity projects for all template begin {0}".format(localToolConfig.Template))) self.__BuildNow(config, currentDir, True) print(("Building sanity project for template end {0}".format(localToolConfig.Template))) except: if not isBuilding: print("Sanity check of template '{0}' failed".format(localToolConfig.Template)) else: print("Sanity build of templates failed") raise finally: if not debugMode: for currentTemplateName in templateList: if currentTemplateName == '*' or currentTemplateName.startswith('/') or '..' in currentTemplateName: raise Exception("Usage error") projectName = "{0}_{1}".format(GlobalStrings.SanityCheckProjectName, currentTemplateName) projectDir = IOUtil.Join(currentDir, projectName) if IOUtil.IsDirectory(projectDir): shutil.rmtree(projectDir)
def Build(config: Config, currentPath: str, featureList: List[str]) -> None: contentBuildDir = __CONTENT_BUILD_DIR contentOutputDir = __CONTENT_OUTPUT_DIR contentBuildPath = IOUtil.Join(currentPath, contentBuildDir) contentOutputPath = IOUtil.Join(currentPath, contentOutputDir) if not IOUtil.IsDirectory(contentBuildPath): config.LogPrintVerbose( 1, "No '{0}' directory present at '{1}' so there is no content to process." .format(contentBuildDir, currentPath)) return packageBuildPath = IOUtil.Join(currentPath, config.GetBuildDir()) if not config.DisableWrite: IOUtil.SafeMakeDirs(packageBuildPath) toolFinder = ToolFinder(config) features = Features(config, featureList) Builder(config, packageBuildPath, contentBuildPath, contentOutputPath, features, toolFinder)
def __init__(self, config: Config, platformName: str, generatorInfo: GeneratorInfo, genFiles: List[XmlGenFile], logVerbosity: int = 1) -> None: super().__init__() # create top level package and resolve build order config.LogPrintVerbose(logVerbosity, "Validating dependencies") packageManager = PackageManager(config, platformName, generatorInfo, genFiles) packages = packageManager.Packages # Build a graph containing all packages graph = DependencyGraph(None) #, True) for package in packages: graph.AddNode(package) graph.Finalize() # Extract the top level nodes nodes = graph.GetNodesWithNoIncomingDependencies() #useFallback = True if len(nodes) > 0: topLevelGenFile = XmlGenFile( config, config.ToolConfig.DefaultPackageLanguage) topLevelGenFile.Name = PackageNameMagicString.TopLevelName topLevelGenFile.SetType(PackageType.TopLevel) for entry in nodes: topLevelGenFile.DirectDependencies.append( FakeXmlGenFileDependency(config, entry.Name, AccessType.Public)) topLevelGenFile.DirectDependencies.sort( key=lambda s: s.Name.lower()) else: # We have circular dependencies and couldnt find any starting nodes # so generate a empty top level node and expect a circular dependency # error to be caught topLevelGenFile = XmlGenFile( config, config.ToolConfig.DefaultPackageLanguage) topLevelGenFile.Name = PackageNameMagicString.TopLevelName topLevelGenFile.SetType(PackageType.TopLevel) topLevelPackage = packageManager.CreatePackage(config, platformName, topLevelGenFile, True) graph.AddNodeAndEdges(topLevelPackage) # Since we need to resolve the build order we might as well verify dependencies at the same time self.__ValidateDependencies(config, packages) self.AllPackages = packages # type: List[Package] self.TopLevelPackage = topLevelPackage self.__ResolveAllPackageDependencies(config, topLevelPackage)
def Process(self, currentDirPath: str, toolConfig: ToolConfig, localToolConfig: LocalToolConfig) -> None: config = Config(self.Log, toolConfig, localToolConfig.PackageConfigurationType, localToolConfig.BuildVariantsDict, localToolConfig.AllowDevelopmentPlugins) # Disable downloads and writes if config.ToolConfig.Experimental is not None: config.ToolConfig.Experimental.AllowDownloads = False config.ForceDisableAllWrite() if localToolConfig.IgnoreNotSupported: config.IgnoreNotSupported = True self.Log.PrintTitle() if not localToolConfig.ForceYes and not self.__AskYesNo("Delete all build directories"): return packageFilters = localToolConfig.BuildPackageFilters buildVariantConfig = BuildVariantConfigUtil.GetBuildVariantConfig(localToolConfig.BuildVariantsDict) generator = self.ToolAppContext.PluginConfigContext.GetGeneratorPluginById(localToolConfig.PlatformName, localToolConfig.Generator, buildVariantConfig, config.ToolConfig.DefaultPackageLanguage, config.ToolConfig.CMakeConfiguration, localToolConfig.GetUserCMakeConfig(), False) theFiles = MainFlow.DoGetFiles(config, toolConfig.GetMinimalConfig(generator.CMakeConfig), currentDirPath, localToolConfig.Recursive) generatorContext = GeneratorContext(config, self.ErrorHelpManager, packageFilters.RecipeFilterManager, config.ToolConfig.Experimental, generator) packages = MainFlow.DoGetPackages(generatorContext, config, theFiles, packageFilters, autoAddRecipeExternals=False) topLevelPackage = PackageListUtil.GetTopLevelPackage(packages) #requestedFiles = None if config.IsSDKBuild else theFiles self.Log.LogPrint("Deleting package build directories") for package in topLevelPackage.ResolvedBuildOrder: if package.AbsoluteBuildPath is not None: # While the path is most likely normalized we force it here removePath = IOUtil.NormalizePath(package.AbsoluteBuildPath) if IOUtil.IsDirectory(removePath): self.Log.LogPrint("- Deleting '{0}'".format(removePath)) if IOUtil.IsDriveRootPath(removePath): raise Exception("Invalid path format '{0}'".format(removePath)) IOUtil.SafeRemoveDirectoryTree(removePath)
def DoGenerateBuildFilesNoAll(config: Config, files: List[str], platformGeneratorPlugin: GeneratorPlugin, packageFilters: PackageFilters) -> List[Package]: config.LogPrint("- Generating build files") if platformGeneratorPlugin.Id == PluginSharedValues.PLATFORM_ID_ALL: raise Exception("Can not use PLATFORM_ID_ALL") isSDKBuild = len(files) <= 0 packageLoader = PackageLoader(config, files, platformGeneratorPlugin) return __ResolveAndGenerate(config, platformGeneratorPlugin, packageLoader, packageFilters, isSDKBuild)
def ForceCheckBuildTools(configToolCheck: Config, generatorContext: GeneratorContext, toolPackageNames: List[str]) -> PackageRecipeResultManager: configToolCheck.LogPrint("BuildTools check"); plugin = generatorContext.Platform filePathList = [] # type: List[str] packageFilters = PackageFilters() packages = MainFlow.DoGetPackages(generatorContext, configToolCheck, filePathList, packageFilters, forceImportPackageNames=toolPackageNames) packageRecipeResultManager = PackageRecipeResultManager(configToolCheck); builderConfig = BuilderConfig() builderConfig.Settings.CheckBuildCommands = True RecipeBuilder.BuildPackages(configToolCheck, generatorContext, builderConfig, packages, packageRecipeResultManager) return packageRecipeResultManager
def __GetStaticLibsPaths(self, config: Config, package: Package, relativePathBuildLib: str) -> List[str]: """ return list of unique directories for dependencies. folders are SDK-root based """ libDirs = [] # type: List[str] for entry in package.ResolvedBuildOrder: if entry.Type == PackageType.Library: if entry.AbsolutePath != package.AbsolutePath and entry.AbsolutePath is not None: #skip package own directory # FIX: for proper variant support use "package.ResolvedMakeObjectPath" instead of the line below fullPath = IOUtil.Join(entry.AbsolutePath, relativePathBuildLib) fullPathSDK = config.ToPath(fullPath) # convert to SDK-based path if fullPathSDK not in libDirs: #append only unique paths libDirs.append(fullPathSDK) return libDirs
def Process(self, currentDirPath: str, toolConfig: ToolConfig, localToolConfig: LocalToolConfig) -> None: config = Config(self.Log, toolConfig, 'sdk', localToolConfig.BuildVariantsDict, localToolConfig.AllowDevelopmentPlugins) if localToolConfig.DryRun: config.ForceDisableAllWrite() if localToolConfig.ToCDepth < 1: localToolConfig.ToCDepth = 1 elif localToolConfig.ToCDepth > 4: localToolConfig.ToCDepth = 4 config.PrintTitle() # Get the platform and see if its supported platform = PluginConfig.GetGeneratorPluginById( localToolConfig.PlatformName, False) PlatformUtil.CheckBuildPlatform(platform.Name) config.LogPrint("Active platform: {0}".format(platform.Name)) packageFilters = localToolConfig.BuildPackageFilters theFiles = MainFlow.DoGetFiles(config, toolConfig.GetMinimalConfig(), currentDirPath, localToolConfig.Recursive) generatorContext = GeneratorContext(config, config.ToolConfig.Experimental, platform) packages = MainFlow.DoGetPackages(generatorContext, config, theFiles, packageFilters) #topLevelPackage = PackageListUtil.GetTopLevelPackage(packages) #featureList = [entry.Name for entry in topLevelPackage.ResolvedAllUsedFeatures] for rootDir in config.ToolConfig.RootDirectories: readmePath = IOUtil.Join(rootDir.ResolvedPath, "README.md") packageReadMeLines = TryLoadReadMe(config, readmePath) result = ProcessPackages(self.ToolAppContext, config, packages, rootDir, localToolConfig.ExtractArguments, toolConfig.BuildDocConfiguration) if packageReadMeLines is not None: packageReadMeLinesNew = TryReplaceSection( config, packageReadMeLines, "AG_DEMOAPPS", result, readmePath) if packageReadMeLinesNew is not None: packageReadMeLines = packageReadMeLinesNew packageReadMeLinesNew = TryInsertTableOfContents( config, packageReadMeLines, localToolConfig.ToCDepth, readmePath) if packageReadMeLinesNew is not None: packageReadMeLines = packageReadMeLinesNew SaveReadMe(config, readmePath, packageReadMeLines) elif config.Verbosity > 2: config.LogPrintWarning("No README.md found in {0}".format( rootDir.ResolvedPath))
def DoGenerateBuildFiles3(config: Config, files: List[str], platformGeneratorPlugin: GeneratorPlugin, packageFilters: PackageFilters) -> MultiPlatformPackageResultType: config.LogPrint("- Generating build files") isSDKBuild = len(files) <= 0 packageLoader = PackageLoader(config, files, platformGeneratorPlugin) if platformGeneratorPlugin.Id != PluginSharedValues.PLATFORM_ID_ALL: raise Exception("This requires: PLATFORM_ID_ALL") resDict = {} # type: MultiPlatformPackageResultType for entry in PluginConfig.GetGeneratorPlugins(config.AllowDevelopmentPlugins): if not config.IsTestMode or not entry.InDevelopment: packages = __ResolveAndGenerate(config, entry, copy.deepcopy(packageLoader), packageFilters, isSDKBuild) resDict[entry.Name] = (packages, entry) return resDict
def __init__(self, config: Config, packageBuildPath: str, contentBuildPath: str, contentOutputPath: str, features: Features, toolFinder: ToolFinder) -> None: super(Builder, self).__init__() configPathVariables = PathVariables(config, packageBuildPath, contentBuildPath, contentOutputPath) commandFilename = IOUtil.Join(contentBuildPath, "Content.json") commandFile = ContentBuildCommandFile(config, commandFilename, configPathVariables) # We don't include the files at 'Content' (contentOutputPath) sourceContent = SourceContent(config, contentOutputPath, contentBuildPath, commandFile, False, commandFilename) contentProcessors = [] # type: List[BasicContentProcessor] # contentProcessors = [VulkanContentProcessor()] contentProcessors += self.__AddBasicContentProcessors( config, toolFinder, config.ToolConfig.ContentBuilderConfiguration) contentProcessors = self.__FilterProcessorsBasedOnFeatures( contentProcessors, features) absoluteCacheFileName = IOUtil.Join(packageBuildPath, "_ContentBuildCache.fsl") absoluteOutputCacheFileName = IOUtil.Join( packageBuildPath, "_ContentBuildCacheOutput.fsl") srcsSyncState = BuildState.GenerateSyncState( config, absoluteCacheFileName, sourceContent.AllContentSource, True) outputSyncState = BuildState.GenerateOutputSyncState( config, absoluteOutputCacheFileName, contentOutputPath, True) if sourceContent.IsEmpty: config.LogPrint("No files found") return if not config.DisableWrite: IOUtil.SafeMakeDirs(contentOutputPath) self.__ProcessSyncFiles(config, contentBuildPath, contentOutputPath, sourceContent.ContentSource, srcsSyncState, outputSyncState) self.__ProcessContentFiles(config, contentBuildPath, contentOutputPath, toolFinder, contentProcessors, sourceContent.ContentBuildSource, srcsSyncState, outputSyncState) srcsSyncState.Save() outputSyncState.Save()