def ParsePackages(generatorContext: GeneratorContext, config: Config, toolMiniConfig: ToolMinimalConfig,
                  currentDir: str, packageFilters: PackageFilters) -> List[Package]:

    theFiles = MainFlow.DoGetFiles(config, toolMiniConfig, currentDir)
    # We set autoAddRecipeExternals to false since we are not actually interested in building this,
    # so therefore we dont want to do any checks for the externals before someone tries to build it
    return MainFlow.DoGetPackages(generatorContext, config, theFiles, packageFilters, autoAddRecipeExternals=False)
    def __ResolveAndGetTopLevelPackage(self, generatorContext: GeneratorContext, config: Config, currentDir: str,
                                       toolMiniConfig: ToolMinimalConfig, recursive: bool) -> Package:
        # Since we use this to discover filters, we just use a empty one
        noPackageFilters = PackageFilters()

        theFiles = MainFlow.DoGetFiles(config, toolMiniConfig, currentDir, recursive)
        packages = MainFlow.DoGetPackages(generatorContext, config, theFiles, noPackageFilters)
        return PackageListUtil.GetTopLevelPackage(packages)
    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))
Example #4
0
    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)
Example #5
0
    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 generator 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)

        config.LogPrint("Active platform: {0}".format(generator.PlatformName))

        packageFilters = localToolConfig.BuildPackageFilters

        theFiles = MainFlow.DoGetFiles(config, toolConfig.GetMinimalConfig(), currentDirPath, localToolConfig.Recursive)
        generatorContext = GeneratorContext(config, self.ErrorHelpManager, packageFilters.RecipeFilterManager, config.ToolConfig.Experimental, generator)
        packages = MainFlow.DoGetPackages(generatorContext, config, theFiles, packageFilters)
        #topLevelPackage = PackageListUtil.GetTopLevelPackage(packages)
        #featureList = [entry.Name for entry in topLevelPackage.ResolvedAllUsedFeatures]

        for projectContext in config.ToolConfig.ProjectInfo.Contexts:
            rootDir = self.__TryLocateRootDirectory(config.ToolConfig.RootDirectories, projectContext.Location)
            if rootDir is None:
                raise Exception("Root directory not found for location {0}".format(projectContext.Location))
            readmePath = IOUtil.Join(rootDir.ResolvedPath, "README.md")
            packageReadMeLines = TryLoadReadMe(config, readmePath)
            result = ProcessPackages(self.ToolAppContext, config, packages, rootDir, localToolConfig.ExtractArguments,
                                     toolConfig.BuildDocConfiguration, currentDirPath)
            if packageReadMeLines is not None:
                projectCaption = "# {0} {1}".format(projectContext.ProjectName, projectContext.ProjectVersion)
                packageReadMeLinesNew = TryReplaceSection(config, packageReadMeLines, "AG_PROJECT_CAPTION", [projectCaption], readmePath)
                if packageReadMeLinesNew is not None:
                    packageReadMeLines = packageReadMeLinesNew

                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))
Example #6
0
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
Example #7
0
    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)
Example #8
0
    def Process(self, currentDirPath: str, toolConfig: ToolConfig,
                localToolConfig: LocalToolConfig) -> None:
        config = Config(self.Log, toolConfig,
                        localToolConfig.PackageConfigurationType,
                        localToolConfig.BuildVariantsDict,
                        localToolConfig.AllowDevelopmentPlugins)

        packageFilters = localToolConfig.BuildPackageFilters

        buildVariantConfig = BuildVariantConfigUtil.GetBuildVariantConfig(
            localToolConfig.BuildVariantsDict)
        platform = self.ToolAppContext.PluginConfigContext.GetGeneratorPluginById(
            localToolConfig.PlatformName, localToolConfig.Generator,
            buildVariantConfig, config.ToolConfig.DefaultPackageLanguage,
            config.ToolConfig.CMakeConfiguration,
            localToolConfig.GetUserCMakeConfig(), False)
        theFiles = []  # type: List[str]
        if not localToolConfig.VoidBuild:
            theFiles = MainFlow.DoGetFiles(
                config, toolConfig.GetMinimalConfig(platform.CMakeConfig),
                currentDirPath, localToolConfig.Recursive)
        else:
            self.Log.LogPrintVerbose(1, "Doing a void build")
        generatorContext = GeneratorContext(config, self.ErrorHelpManager,
                                            packageFilters.RecipeFilterManager,
                                            config.ToolConfig.Experimental,
                                            platform)
        packages = MainFlow.DoGetPackages(generatorContext, config, theFiles,
                                          packageFilters)
        #packages = DoExperimentalGetRecipes(generatorContext, config, [])
        #topLevelPackage = PackageListUtil.GetTopLevelPackage(packages)

        builderConfig = BuilderConfig()
        builderConfig.Settings.PreDeleteBuild = localToolConfig.PreDeleteBuild
        builderConfig.Settings.PostDeleteBuild = localToolConfig.PostDeleteBuild
        builderConfig.Settings.CheckBuildCommands = localToolConfig.CheckBuildCommands
        builderConfig.Settings.ForceClaimInstallArea = localToolConfig.ForceClaimInstallArea
        builderConfig.Settings.BuildThreads = localToolConfig.BuildThreads

        RecipeBuilder.BuildPackages(self.Log, config.SDKPath, config.IsDryRun,
                                    config.ToolConfig, generatorContext,
                                    builderConfig, packages)
Example #9
0
    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)