Beispiel #1
0
    def Process(log: Log, toolConfig: ToolConfig, customPackageFileFilter: Optional[CustomPackageFileFilter],
                clangFormatConfiguration: ClangFormatConfiguration, cmakeConfig: GeneratorCMakeConfig,
                clangFormatExeInfo: ClangExeInfo, ninjaExeInfo: ClangExeInfo, sortedPackageList: List[Package],
                repairEnabled: bool, numBuildThreads: int) -> int:
        totalProcessedCount = 0

        logOutput = False
        currentWorkingDirectory = BuildUtil.GetBuildDir(log, toolConfig, cmakeConfig.CheckDir)
        currentWorkingDirectory = IOUtil.Join(currentWorkingDirectory, "format")
        ninjaOutputFile =  IOUtil.Join(currentWorkingDirectory, "build.ninja")
        toolVersionOutputFile =  IOUtil.Join(currentWorkingDirectory, "ToolVersions.txt")
        IOUtil.SafeMakeDirs(currentWorkingDirectory)

        log.LogPrint("Using path: '{0}'".format(currentWorkingDirectory))

        log.LogPrint("Storing tool versions.")
        PerformClangFormatHelper2.WriteToolVersionFile(log, toolVersionOutputFile, clangFormatExeInfo, ninjaExeInfo)

        log.LogPrint("Generating ninja format file.")
        #foundFixes = PerformClangTidyHelper2.FindFixes(log, clangTidyFixOutputFolder)
        #if len(foundFixes) > 0:
        #    PerformClangTidyHelper2.DeleteFixes(log, clangTidyFixOutputFolder, foundFixes)

        totalProcessedCount = PerformClangFormatHelper2.GenerateNinjaTidyFile(log, toolConfig, ninjaOutputFile, currentWorkingDirectory,
                                                                              toolVersionOutputFile, clangFormatExeInfo, customPackageFileFilter,
                                                                              clangFormatConfiguration, sortedPackageList, repairEnabled)
        log.LogPrint("Executing ninja format file.")

        RunHelper.RunNinja(log, ninjaExeInfo, ninjaOutputFile, currentWorkingDirectory, numBuildThreads, logOutput)

        return totalProcessedCount
Beispiel #2
0
    def _DoTryGenerateConfigReport(
            self, log: Log, generatorConfig: GeneratorConfig,
            topLevelPackage: Package
    ) -> Optional[PackageGeneratorConfigReport]:
        if self.CMakeConfig is None:
            raise Exception("internal error generator not configured")

        configVariant = self.GeneratorVariants[ToolAddedVariant.CONFIG]
        cmakeBuildPackageDir = BuildUtil.GetBuildDir(
            generatorConfig.ToolConfig.ProjectInfo, self.CMakeConfig.CacheDir)

        return GeneratorCMake.GenerateGeneratorBuildConfigReport(
            log, generatorConfig, self.CMakeConfig, cmakeBuildPackageDir,
            topLevelPackage, configVariant.Options)
Beispiel #3
0
    def DoGenerate(self, platformContext: PlatformContext, config: Config,
                   packages: List[Package]) -> List[Package]:
        if self.CMakeConfig is None:
            raise Exception("Internal error no CMakeConfig set")

        log = config  # type: Log
        toolConfig = config.ToolConfig
        cmakeBuildPackageDir = BuildUtil.GetBuildDir(toolConfig.ProjectInfo,
                                                     self.CMakeConfig.CacheDir)

        generator = GeneratorCMake(
            log, toolConfig, packages, self.PlatformName,
            self.__CMakeTemplateName, self.__CMakeOverrideTemplateName,
            cmakeBuildPackageDir, config.SDKConfigTemplatePath,
            config.DisableWrite, self.__CMakeGeneratorMode)
        return self.GenerateDone(config, packages, self.PlatformName,
                                 generator)
Beispiel #4
0
    def _DoGenerateReport(
            self, log: Log, generatorConfig: GeneratorConfig,
            packageList: List[Package]) -> TheGeneratorBuildReport:
        if self.CMakeConfig is None:
            raise Exception("internal error generator not configured")

        cmakeBuildPackageDir = BuildUtil.GetBuildDir(
            generatorConfig.ToolConfig.ProjectInfo, self.CMakeConfig.CacheDir)

        configVariant = self.GeneratorVariants[ToolAddedVariant.CONFIG]
        resultDict = {}  # type: Dict[Package, PackageGeneratorReport]
        for package in packageList:
            buildReport = GeneratorCMake.TryGenerateGeneratorPackageReport(
                log, generatorConfig, self.CMakeConfig, cmakeBuildPackageDir,
                package, configVariant.Options)
            if buildReport is not None:
                resultDict[package] = buildReport
        return TheGeneratorBuildReport(resultDict)
    def __init__(self, generatorContext: GeneratorContext, config: Config,
                 topLevelPackage: Package, buildConfig: BuildConfigRecord,
                 enableContentBuilder: bool,
                 forceClaimInstallArea: bool) -> None:
        super().__init__()
        self.Log = config
        self.UsedGeneratorConfig = None  # type: Optional[GeneratorConfig]
        self.UsedBuildContext = None  # type: Optional[LocalBuildContext]

        localPlatformBuildContext = LocalPlatformBuildContext(
            config, generatorContext.Generator.OriginalPlatformName,
            generatorContext.Generator.IsCMake, buildConfig.BuildThreads)

        # Do a final filter that removes all unsupported packages
        resolvedBuildOrder = topLevelPackage.ResolvedBuildOrder
        resolvedBuildOrder = PackageFilter.FilterNotSupported(
            self.Log, topLevelPackage, resolvedBuildOrder)
        if not PackageFilter.WasThisAExecutableBuildAndAreThereAnyLeft(
                topLevelPackage.ResolvedBuildOrder, resolvedBuildOrder):
            self.Log.DoPrint("No executables left, skipping all")
            return

        # Run the recipe builder on the packages we have left
        # We run the recipe builder on the resolvedBuildOrder since it all required packages, not just the ones we need to build as libs and executables
        builderSettings = BuilderSettings()
        builderSettings.ForceClaimInstallArea = forceClaimInstallArea
        builderSettings.BuildThreads = buildConfig.BuildThreads
        RecipeBuilder.BuildPackagesInOrder(config, generatorContext,
                                           resolvedBuildOrder, builderSettings)

        resolvedBuildOrderBuildable = PackageFilter.FilterBuildablePackages(
            resolvedBuildOrder)
        if len(resolvedBuildOrderBuildable) == 0:
            config.DoPrint("Nothing to build!")
            return

        generatorConfig = GeneratorConfig(
            generatorContext.PlatformName, config.SDKConfigTemplatePath,
            config.ToolConfig, localPlatformBuildContext.NumBuildThreads,
            buildConfig.BuildCommand)
        generatorConfigReport = generatorContext.Generator.TryGenerateConfigReport(
            self.Log, generatorConfig, topLevelPackage)

        packageCount = len(resolvedBuildOrderBuildable)

        resolvedBuildOrderBuildable = self.__ApplyPlatformOrderChanges(
            resolvedBuildOrderBuildable, buildConfig.PlatformName)
        originalBuildArgs = buildConfig.BuildArgs

        # Handle the configure step
        masterBuildReport = None  # type: Optional[GeneratorBuildReport]
        masterBuildVariableReport = None  # type: Optional[GeneratorVariableReport]
        if generatorConfigReport is not None:
            # Setup some extra variables for configure
            BuildUtil.AddCustomVariables(generatorConfigReport.VariableReport,
                                         config.ToolConfig.ProjectInfo)

            self.__ConfigureBuild(
                generatorConfigReport, buildConfig,
                generatorContext.CMakeConfig.AllowFindPackage)
            masterBuildReport = generatorConfigReport.MasterBuildReport
            masterBuildVariableReport = generatorConfigReport.MasterBuildVariableReport
            if masterBuildVariableReport is not None:
                BuildUtil.AddCustomVariables(masterBuildVariableReport,
                                             config.ToolConfig.ProjectInfo)

        # Acquire information about the build step
        generatorReport = generatorContext.Generator.GenerateReport(
            self.Log, generatorConfig, resolvedBuildOrderBuildable)
        generatorReportDict = generatorReport.PackageReportDict
        for generatorEntry in generatorReportDict.values():
            if generatorEntry.VariableReport is not None:
                BuildUtil.AddCustomVariables(generatorEntry.VariableReport,
                                             config.ToolConfig.ProjectInfo)

        # Default content building for all platform (for those generators that don't add it to the build file)
        builderCanBuildContent = (generatorConfigReport is not None
                                  and generatorConfigReport.CanBuildContent)
        if enableContentBuilder and not builderCanBuildContent:
            for package in resolvedBuildOrderBuildable:
                if package.Type == PackageType.Executable:
                    featureList = [
                        entry.Name for entry in package.ResolvedAllUsedFeatures
                    ]
                    if package.Path is None:
                        raise Exception("Invalid package")
                    ContentBuilder.Build(config, package.Path, featureList)

        # Windows runs its validation checks slightly differently
        runValidationChecks = (buildConfig.PlatformName !=
                               PlatformNameString.WINDOWS)

        buildContext = LocalBuildContext(config, localPlatformBuildContext,
                                         generatorReportDict,
                                         generatorContext.GeneratorName)

        if masterBuildReport is not None:
            if masterBuildVariableReport is None:
                raise Exception("master-build must have a variable report")
            self.__BuildMaster(buildConfig, buildContext, masterBuildReport,
                               masterBuildVariableReport, topLevelPackage,
                               originalBuildArgs, builderCanBuildContent,
                               runValidationChecks, config.IsDryRun)

        # Build and run all the packages in the resolvedBuildOrderBuildable
        self.__BuildAndRunPackages(config, buildConfig, buildContext,
                                   resolvedBuildOrderBuildable,
                                   originalBuildArgs, builderCanBuildContent,
                                   runValidationChecks,
                                   masterBuildReport is None, config.IsDryRun,
                                   generatorConfig)

        if packageCount > 0:
            config.LogPrint("Build {0} packages".format(packageCount))
        else:
            config.DoPrint("Nothing build!")

        if buildConfig.BuildCommand == CommandType.Clean:
            if generatorContext.Generator.IsCMake:
                self.Log.DoPrint(
                    "*** To do a full cmake clean build delete the out of source build folder ***"
                )
            if not generatorContext.Generator.SupportCommandClean:
                raise Exception("*** clean not supported by this builder ***")
        if buildConfig.BuildCommand == CommandType.Install and not generatorContext.Generator.SupportCommandInstall:
            raise Exception("*** install not supported by this builder ***")
        if buildConfig.BuildCommand == CommandType.Open and not generatorContext.Generator.SupportCommandOpen:
            errorMessage = "open is not supported by this builder."
            if len(generatorContext.Generator.SupportCommandOpenHintMessage
                   ) > 0:
                errorMessage = "{0} {1}".format(
                    errorMessage,
                    generatorContext.Generator.SupportCommandOpenHintMessage)
            raise Exception(errorMessage)

        self.UsedGeneratorConfig = generatorConfig
        self.UsedBuildContext = buildContext
Beispiel #6
0
 def GetIgnoreDirs(projectInfo: ToolConfigProjectInfo, cmakeConfig: GeneratorCMakeConfig, defaultBuildDir: str) -> List[str]:
     return [BuildUtil.GetBuildDir(projectInfo, defaultBuildDir), BuildUtil.GetBuildDir(projectInfo, cmakeConfig.BuildDir),
             BuildUtil.GetBuildDir(projectInfo, cmakeConfig.CacheDir), BuildUtil.GetBuildDir(projectInfo, cmakeConfig.CheckDir)]