예제 #1
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)
    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()
예제 #3
0
    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)