Beispiel #1
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, config.ToolConfig.DefaultPackageLanguage,
            config.ToolConfig.CMakeConfiguration,
            localToolConfig.GetUserCMakeConfig(), False)
        PlatformUtil.CheckBuildPlatform(generator.PlatformName)

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

        packageFilters = localToolConfig.BuildPackageFilters

        minimalConfig = toolConfig.GetMinimalConfig(generator.CMakeConfig)
        theFiles = MainFlow.DoGetFiles(config, minimalConfig, 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))

            if not localToolConfig.NoMdScan:
                mdFiles = IOUtil.FindFileByExtension(
                    rootDir.ResolvedPath, ".md",
                    minimalConfig.IgnoreDirectories)
                for filename in mdFiles:
                    if filename != readmePath:
                        config.LogPrintVerbose(
                            1, "Processing file '{0}'".format(filename))
                        self.ProcessMDFile(config, filename, localToolConfig)