コード例 #1
0
 def __init__(self, log: Log, generatorOriginalName: str,
              isCMakeGenerator: bool, buildThreads: int) -> None:
     self.Log = log
     self.AdditionalBuildArguments = []  # type: List[str]
     # The CMake generator adds the necessary parameters automatically
     # A future pass on this code should move the AddBuildThreads arguments to the generators instead as its more appropriate.
     numBuildThreads = 1
     if not isCMakeGenerator:
         numBuildThreads = PlatformBuildUtil.AddBuildThreads(
             log, self.AdditionalBuildArguments, generatorOriginalName,
             buildThreads)
     else:
         numBuildThreads = PlatformBuildUtil.GetRecommendedBuildThreads(
             buildThreads)
     self.NumBuildThreads = numBuildThreads
コード例 #2
0
    def Run(log: Log, toolConfig: ToolConfig, formatPackageList: List[Package],
            customPackageFileFilter: Optional[CustomPackageFileFilter],
            packageRecipeResultManager: PackageRecipeResultManager,
            clangFormatConfiguration: ClangFormatConfiguration,
            cmakeConfig: GeneratorCMakeConfig, repairEnabled: bool,
            buildThreads: int, useLegacyTidyMethod: bool) -> None:
        """ RunClangFormat on a package at a time """

        # Lookup the recommended build threads using the standard build algorithm
        numBuildThreads = PlatformBuildUtil.GetRecommendedBuildThreads(
            buildThreads)

        clangExeInfo = PerformClangUtil.LookupRecipeResults(
            packageRecipeResultManager,
            clangFormatConfiguration.RecipePackageName,
            MagicValues.ClangFormatCommand)
        ninjaExeInfo = PerformClangUtil.LookupRecipeResults(
            packageRecipeResultManager,
            clangFormatConfiguration.NinjaRecipePackageName,
            MagicValues.NinjaCommand)

        log.LogPrint("ClangFormat version: {0}".format(clangExeInfo.Version))
        log.LogPrint("Ninja version: {0}".format(ninjaExeInfo.Version))

        log.LogPrint("Running clang-format")

        # Filter the package list so it only contains things we can process
        finalPackageList = [
            package for package in formatPackageList
            if PerformClangUtil.CanProcessPackage(package)
        ]

        sortedPackages = list(finalPackageList)
        sortedPackages.sort(key=lambda s: s.Name.lower())

        #test = set()
        #for entry in sortedPackages:
        #    if entry.Name in test:
        #        raise Exception("duplicated package")
        #    else:
        #       test.add(entry.Name)

        if useLegacyTidyMethod:
            count = PerformClangFormatHelper.Process(
                log, toolConfig, customPackageFileFilter,
                clangFormatConfiguration, clangExeInfo, sortedPackages,
                repairEnabled, numBuildThreads)
        else:
            count = PerformClangFormatHelper2.Process(
                log, toolConfig, customPackageFileFilter,
                clangFormatConfiguration, cmakeConfig, clangExeInfo,
                ninjaExeInfo, sortedPackages, repairEnabled, numBuildThreads)

        if count == 0:
            if customPackageFileFilter is None:
                log.DoPrintWarning("No files processed")
            else:
                log.DoPrintWarning(
                    "No files processed, could not find a package that matches {0}"
                    .format(customPackageFileFilter))
コード例 #3
0
    def Run(log: Log, toolConfig: ToolConfig, formatPackageList: List[Package],
            customPackageFileFilter: Optional[CustomPackageFileFilter],
            packageRecipeResultManager: PackageRecipeResultManager,
            clangFormatConfiguration: ClangFormatConfiguration, repairEnabled: bool, buildThreads: int) -> None:
        """ RunClangFormat on a package at a time """

        # Lookup the recommended build threads using the standard build algorithm
        buildThreads = PlatformBuildUtil.GetRecommendedBuildThreads(buildThreads)

        clangExeInfo = PerformClangUtil.LookupRecipeResults(packageRecipeResultManager, clangFormatConfiguration.RecipePackageName,
                                                            MagicValues.ClangFormatCommand)

        if log.Verbosity >= 1:
            PerformClangUtil.ShowVersion(log, clangExeInfo)

        log.LogPrint("Running clang-format")

        # Filter the package list so it only contains things we can process
        finalPackageList = [package for package in formatPackageList if PerformClangUtil.CanProcessPackage(package)]

        sortedPackages = list(finalPackageList)
        sortedPackages.sort(key=lambda s: s.Name.lower())

        count = PerformClangFormatHelper.Process(log, toolConfig, customPackageFileFilter, clangFormatConfiguration, clangExeInfo, sortedPackages,
                                                 repairEnabled, buildThreads)
        if count == 0:
            if customPackageFileFilter is None:
                log.DoPrintWarning("No files processed")
            else:
                log.DoPrintWarning("No files processed, could not find a package that matches {0}".format(customPackageFileFilter))
コード例 #4
0
 def __init__(self, log: Log, generatorOriginalName: str, buildCommand: int,
              buildThreads: int) -> None:
     self.Log = log
     self.AdditionalBuildArguments = []  # type: List[str]
     PlatformBuildUtil.AddBuildThreads(log, self.AdditionalBuildArguments,
                                       generatorOriginalName, buildThreads)
     if buildCommand == CommandType.Clean:
         self.__HandleCleanBuilds(self.AdditionalBuildArguments,
                                  generatorOriginalName)
コード例 #5
0
    def __init__(self, generatorContext: GeneratorContext, buildThreads: int,
                 buildTypeInfo: PlatformBuildTypeInfo) -> None:
        super().__init__()
        self.Context = generatorContext
        self.BasicConfig = generatorContext.BasicConfig
        # Builders like ninja and make only contains a single configuration
        self.IsSingleConfiguration = False
#        #self.__ConfigureForPlatform(generatorContext)
        self.BuilderThreadArguments = [] # type: List[str]
        self.NumBuildThreads = PlatformBuildUtil.AddBuildThreads(generatorContext.Log, self.BuilderThreadArguments, generatorContext.PlatformName,
                                                                 buildThreads, buildTypeInfo, generatorContext.CMakeConfig, True)
コード例 #6
0
    def Run(log: Log, toolConfig: ToolConfig, platformId: str,
            topLevelPackage: Package, tidyPackageList: List[Package],
            userBuildVariantsDict: Dict[str, str], pythonScriptRoot: str,
            generatorContext: GeneratorContext, sdkConfigTemplatePath: str,
            packageRecipeResultManager: PackageRecipeResultManager,
            performClangTidyConfig: PerformClangTidyConfig,
            customPackageFileFilter: Optional[CustomPackageFileFilter],
            clangFormatFilename: Optional[str], buildThreads: int) -> None:
        """
        RunClangTidy on a package at a time
        :param topLevelPackage: the top level system package
        :param tidyPackageList: the packages to 'tidy'
        :param userBuildVariantsDict: the variant configuration supplied by the user
        :param performClangTidyConfig:
        :param customPackageFileFilter:
        :param clangFormatFilename:
        :param repairEnabled:
        """

        # Lookup the recommended build threads using the standard build algorithm
        buildThreads = PlatformBuildUtil.GetRecommendedBuildThreads(
            buildThreads)

        clangExeInfo = PerformClangUtil.LookupRecipeResults(
            packageRecipeResultManager,
            performClangTidyConfig.ClangTidyConfiguration.RecipePackageName,
            MagicValues.ClangTidyCommand)

        BuildVariantUtil.ValidateUserVariantSettings(log, topLevelPackage,
                                                     userBuildVariantsDict)
        BuildVariantUtil.LogVariantSettings(log, userBuildVariantsDict)
        resolvedVariantSettingsDict = BuildVariantUtil.CreateCompleteStaticVariantSettings(
            topLevelPackage.ResolvedAllVariantDict, userBuildVariantsDict)

        if log.Verbosity >= 1:
            PerformClangUtil.ShowVersion(log, clangExeInfo)
        log.LogPrint("Running clang-tidy")

        # Filter the package list so it only contains things we can process
        finalPackageList = [
            package for package in tidyPackageList
            if PerformClangUtil.CanProcessPackage(package)
        ]

        generatorConfig = GeneratorConfig(sdkConfigTemplatePath, toolConfig)
        generatorReportDict = generatorContext.Generator.GenerateReport(
            log, generatorConfig, finalPackageList)

        # Validate report dict
        for package in finalPackageList:
            if package not in generatorReportDict:
                raise Exception(
                    "Generator report is missing information for package '{0}'"
                    .format(package.Name))

        localVariantInfo = LocalVariantInfo(resolvedVariantSettingsDict,
                                            generatorReportDict,
                                            pythonScriptRoot)

        count = PerformClangTidyHelper.ProcessAllPackages(
            log, toolConfig, platformId, pythonScriptRoot,
            performClangTidyConfig, clangExeInfo, finalPackageList,
            customPackageFileFilter, localVariantInfo, buildThreads)
        if count == 0:
            if customPackageFileFilter is None:
                log.DoPrintWarning("No files processed")
            else:
                log.DoPrintWarning(
                    "No files processed, could not find a package that matches {0}"
                    .format(customPackageFileFilter))