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

        if localToolConfig.Graph:
            PluginConfig.EnableGraph()

        theFiles = MainFlow.DoGetFiles(config, toolConfig.GetMinimalConfig(),
                                       currentDirPath,
                                       localToolConfig.Recursive)

        PluginConfig.SetGeneratorType(localToolConfig.GenType)

        platformGeneratorPlugin = PluginConfig.GetGeneratorPluginById(
            localToolConfig.PlatformName, True)
        generatorContext = GeneratorContext(config,
                                            config.ToolConfig.Experimental,
                                            platformGeneratorPlugin)
        packages = MainFlow.DoGenerateBuildFiles(
            config, theFiles, platformGeneratorPlugin,
            localToolConfig.BuildPackageFilters)

        # If the platform was manually switched, then check if the build platform is supported,
        # if its not disable recipe building and log a warning
        if localToolConfig.DefaultPlatformName != localToolConfig.PlatformName:
            if not PlatformUtil.TryCheckBuildPlatform(
                    localToolConfig.PlatformName):
                self.Log.DoPrintWarning(
                    "Build recipes not supported for '{0}' on this OS".format(
                        localToolConfig.PlatformName))
                localToolConfig.DontBuildRecipes = True

        if localToolConfig.ListVariants or localToolConfig.ListBuildVariants:
            requestedFiles = None if config.IsSDKBuild else theFiles
            if not isinstance(packages, dict):
                self.__DoShowList(packages, requestedFiles,
                                  localToolConfig.ListVariants,
                                  localToolConfig.ListBuildVariants,
                                  platformGeneratorPlugin)
            else:
                for platformName, platformResult in packages.items():
                    platformPackageList = platformResult[0]
                    if len(platformPackageList) > 0:
                        self.Log.DoPrint("Generator: {0}".format(platformName))
                        try:
                            self.Log.PushIndent()
                            self.__DoShowList(
                                platformPackageList, requestedFiles,
                                localToolConfig.ListVariants,
                                localToolConfig.ListBuildVariants,
                                platformResult[1])
                        finally:
                            self.Log.PopIndent()
        elif not localToolConfig.DontBuildRecipes:
            if not isinstance(packages, dict):
                self.__DoBuildRecipes(config, generatorContext, packages,
                                      localToolConfig.ForceClaimInstallArea,
                                      localToolConfig.BuildThreads)
            else:
                for platformName, platformResult in packages.items():
                    platformPackageList = platformResult[0]
                    if len(platformPackageList
                           ) > 0 and PlatformUtil.TryCheckBuildPlatform(
                               platformName):
                        self.Log.DoPrint("Generator: {0}".format(platformName))
                        tempPlatformGeneratorPlugin = PluginConfig.GetGeneratorPluginById(
                            platformName, True)
                        tempGeneratorContext = GeneratorContext(
                            config, config.ToolConfig.Experimental,
                            tempPlatformGeneratorPlugin)
                        try:
                            self.Log.PushIndent()
                            self.__DoBuildRecipes(
                                config, tempGeneratorContext,
                                platformPackageList,
                                localToolConfig.ForceClaimInstallArea,
                                localToolConfig.BuildThreads)
                        finally:
                            self.Log.PopIndent()
Beispiel #2
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

        if localToolConfig.Graph:
            self.ToolAppContext.PluginConfigContext.EnableGraph()

        self.ToolAppContext.PluginConfigContext.SetLegacyGeneratorType(
            localToolConfig.GenType)

        buildVariantConfig = BuildVariantConfigUtil.GetBuildVariantConfig(
            localToolConfig.BuildVariantsDict)
        platformGeneratorPlugin = self.ToolAppContext.PluginConfigContext.GetGeneratorPluginById(
            localToolConfig.PlatformName, localToolConfig.Generator,
            buildVariantConfig, config.ToolConfig.DefaultPackageLanguage,
            config.ToolConfig.CMakeConfiguration,
            localToolConfig.GetUserCMakeConfig(), False)
        generatorContext = GeneratorContext(
            config, self.ErrorHelpManager,
            localToolConfig.BuildPackageFilters.RecipeFilterManager,
            config.ToolConfig.Experimental, platformGeneratorPlugin)

        theFiles = MainFlow.DoGetFiles(
            config,
            toolConfig.GetMinimalConfig(platformGeneratorPlugin.CMakeConfig),
            currentDirPath, localToolConfig.Recursive)

        packages = MainFlow.DoGenerateBuildFiles(
            self.ToolAppContext.PluginConfigContext,
            config,
            self.ErrorHelpManager,
            theFiles,
            platformGeneratorPlugin,
            localToolConfig.BuildPackageFilters,
            writeGraph=localToolConfig.Graph2)

        # If the platform was manually switched, then check if the build platform is supported,
        # if its not disable recipe building and log a warning
        if localToolConfig.DefaultPlatformName != localToolConfig.PlatformName:
            if not PlatformUtil.TryCheckBuildPlatform(
                    localToolConfig.PlatformName):
                self.Log.DoPrintWarning(
                    "Build recipes not supported for '{0}' on this OS".format(
                        localToolConfig.PlatformName))
                localToolConfig.DontBuildRecipes = True

        if localToolConfig.ListVariants or localToolConfig.ListBuildVariants:
            requestedFiles = None if config.IsSDKBuild else theFiles
            if not isinstance(packages, dict):
                self.__DoShowList(packages, requestedFiles,
                                  localToolConfig.ListVariants,
                                  localToolConfig.ListBuildVariants,
                                  platformGeneratorPlugin)
            else:
                for platformName, platformResult in packages.items():
                    platformPackageList = platformResult[0]
                    if len(platformPackageList) > 0:
                        self.Log.DoPrint("Generator: {0}".format(platformName))
                        try:
                            self.Log.PushIndent()
                            self.__DoShowList(
                                platformPackageList, requestedFiles,
                                localToolConfig.ListVariants,
                                localToolConfig.ListBuildVariants,
                                platformResult[1])
                        finally:
                            self.Log.PopIndent()
        elif not localToolConfig.DontBuildRecipes:
            self.__DoBuildRecipes(config, generatorContext, packages,
                                  localToolConfig.ForceClaimInstallArea,
                                  localToolConfig.BuildThreads)

            if generatorContext.Generator.IsCMake:
                # Ensure we do what corrosponds to a  "FslBuild -c config" for cmake generators
                if localToolConfig.BuildPackageFilters is None or localToolConfig.BuildPackageFilters.ExtensionNameList is None:
                    raise Exception(
                        "localToolConfig.BuildPackageFilters.ExtensionNameList not set"
                    )
                requestedFiles = None if config.IsSDKBuild else theFiles
                requestedPackages = BuildHelper.FindRequestedPackages(
                    config, packages, requestedFiles)

                localToolConfigCommand = CommandType.Config
                localToolConfigEnableContentBuilder = True
                localToolConfigForAllExe = None

                Builder.BuildPackages(
                    self.Log, config.GetBuildDir(), config.SDKPath,
                    config.SDKConfigTemplatePath, config.DisableWrite,
                    config.IsDryRun, toolConfig, generatorContext, packages,
                    requestedPackages, localToolConfig.BuildVariantsDict,
                    localToolConfig.RemainingArgs, localToolConfigForAllExe,
                    platformGeneratorPlugin,
                    localToolConfigEnableContentBuilder,
                    localToolConfig.ForceClaimInstallArea,
                    localToolConfig.BuildThreads, localToolConfigCommand, True)