コード例 #1
0
ファイル: Main.py プロジェクト: xang/gtec-demo-framework
    def __Filter(self, platformContext: PlatformContext,
                 packageFilters: PackageFilters,
                 autoAddRecipeExternals: bool,
                 sourceGenFiles: List[XmlGenFile]) -> List[XmlGenFile]:

        if not packageFilters.ContainsFilters():
            return sourceGenFiles

        self.Log.LogPrint("- Filtering")
        try:
            self.Log.PushIndent()
            packageResolver = PackageResolver(platformContext, self.Config, sourceGenFiles,
                                              autoAddRecipeExternals, False,
                                              self.MarkExternalLibFirstUse,
                                              packageFilters.RecipeFilterManager)
            packages = packageResolver.Packages

            topLevelPackage = PackageListUtil.GetTopLevelPackage(packages)
            requestedFiles = self.SourceFiles
            requestedPackages = PackageUtil.TryGetPackageListFromFilenames(topLevelPackage, requestedFiles, False)
            resolvedBuildOrder = PackageFilter.Filter(self.Log, topLevelPackage, requestedPackages, packageFilters)

            # Now do a lookup of package -> Genfile to provide a filtered gen file list
            genFileSet = set(sourceGenFiles)
            return [package.GenFile for package in resolvedBuildOrder if package.GenFile is not None and package.GenFile in genFileSet]
        finally:
            self.Log.PopIndent()
コード例 #2
0
    def __Filter(log: Log, sourcePackageBuildOrder: List[PreResolvePackageResult], packageManagerFilter: PackageManagerFilter) -> List[PreResolvePackageResult]:
        log.LogPrint("- Filtering")
        log.PushIndent()
        try:
            #topLevelPackage = PackageListUtil.GetTopLevelPackage(sourcePackageBuildOrder)
            requestedPackages = PreResolvePackageResultUtil.TryGetPackageListFromFilenames(sourcePackageBuildOrder, packageManagerFilter.RequestedFiles, False)

            # Remove all packages that were not imported because of a user requirement
            sourcePackageBuildOrder = PackageManager.__FilterNotUserRequested(log, sourcePackageBuildOrder, requestedPackages)

            if not packageManagerFilter.PackageFilters.ContainsFilters():
                return sourcePackageBuildOrder

            #requirements = RequirementFilter.GetRequirementList(topLevelPackage, None)
            requirements = RequirementFilter.GetRequirementListFromPackages(sourcePackageBuildOrder)
            return PackageFilter.Filter2(log, sourcePackageBuildOrder, requirements, requestedPackages, packageManagerFilter.PackageFilters)
        finally:
            log.PopIndent()
コード例 #3
0
    def FilterPackages(log: Log, topLevelPackage: Package,
                       specifiedPackages: List[Package],
                       scanDependencies: bool) -> List[Package]:
        """
        Implements the filtering behaviour for the FslBuildCheck commands.
        - Filter the 'ResolvedBuildOrder' package list of the topLevelPackage.
        - First the not supported packages are removed
        - then if scanDependencies is false we remove all packages not specified by the user
        """

        resolvedBuildOrder = topLevelPackage.ResolvedBuildOrder
        resolvedBuildOrder = PackageFilter.FilterNotSupported(
            log, topLevelPackage, resolvedBuildOrder)

        # Filter the package list
        specifiedPackagesSet = set(specifiedPackages)
        filteredPackageList = resolvedBuildOrder
        if not scanDependencies:
            filteredPackageList = [
                package for package in filteredPackageList
                if package in specifiedPackagesSet
            ]
        return filteredPackageList
コード例 #4
0
    def ProcessAppInfo(self, currentDirPath: str,
                       localToolConfig: LocalToolConfig,
                       appInfoChoice: int) -> None:
        requestedFileList = []  # type: List[str]
        localFile = IOUtil.Join(currentDirPath, g_InfoFilename)
        if IOUtil.IsFile(localFile):
            requestedFileList.append(localFile)

        activePlatformNameId = localToolConfig.PlatformName.lower()

        isRecursive = appInfoChoice == AppInfoChoice.Recursive
        loader = AppInfoLoader(self.Log, g_InfoFilename, requestedFileList,
                               isRecursive, currentDirPath,
                               activePlatformNameId)
        if loader.IsEmpty():
            self.Log.LogPrint("No '{0}' files found".format(g_InfoFilename))
            return

        requirementTree = AppInfoRequirementTree(self.Log, loader.GetDict(),
                                                 activePlatformNameId)

        if localToolConfig.BuildPackageFilters is None or localToolConfig.BuildPackageFilters.ExtensionNameList is None:
            raise Exception("BuildPackageFilters.ExtensionNameList is invalid")

        # Now we basically need to apply the same filters as the other build tools
        completePackageList = [
            AppInfoPackage(self.Log, appInfo, filename)
            for filename, appInfo in loader.GetDict().items()
        ]
        completePackageList.sort(key=lambda s: s.Name.lower())
        filteredPackageList = PackageFilter.FilterAppInfo(
            self.Log, completePackageList, requirementTree.GlobalTree,
            localToolConfig.BuildPackageFilters)

        # Then its time to run the the packages that are left
        self.__RunPackages(filteredPackageList, localToolConfig.RemainingArgs,
                           localToolConfig.BuildVariantsDict)
コード例 #5
0
    def __init__(self, generatorContext: GeneratorContext, config: Config,
                 topLevelPackage: Package, buildConfig: BuildConfigRecord,
                 enableContentBuilder: bool,
                 forceClaimInstallArea: bool) -> None:
        super().__init__()
        self.Log = config

        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
            self.__AddCustomVariables(generatorConfigReport.VariableReport,
                                      config.ToolConfig.ProjectInfo)

            self.__ConfigureBuild(generatorConfigReport, buildConfig)
            masterBuildReport = generatorConfigReport.MasterBuildReport
            masterBuildVariableReport = generatorConfigReport.MasterBuildVariableReport
            if masterBuildVariableReport is not None:
                self.__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:
                self.__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 generatorContext.Generator.IsCMake and buildConfig.BuildCommand == CommandType.Clean:
            self.Log.DoPrint(
                "*** To do a full cmake clean build delete the out of source build folder ***"
            )
        if not generatorContext.Generator.SupportCommandClean and buildConfig.BuildCommand == CommandType.Clean:
            self.Log.DoPrint("*** clean not supported by this builder ***")
        if not generatorContext.Generator.SupportCommandInstall and buildConfig.BuildCommand == CommandType.Install:
            self.Log.DoPrint("*** install not supported by this builder ***")
コード例 #6
0
    def __init__(self, generatorContext: GeneratorContext, config: Config,
                 topLevelPackage: Package, buildConfig: BuildConfigRecord,
                 enableContentBuilder: bool,
                 forceClaimInstallArea: bool) -> None:
        super(Builder, self).__init__()
        self.Log = config

        localPlatformBuildContext = LocalPlatformBuildContext(
            config, generatorContext.Generator.OriginalName,
            buildConfig.BuildCommand, 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(config.SDKConfigTemplatePath,
                                          config.ToolConfig)
        generatorReportDict = generatorContext.Generator.GenerateReport(
            self.Log, generatorConfig, resolvedBuildOrderBuildable)

        packageCount = len(resolvedBuildOrderBuildable)

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

        originalBuildArgs = buildConfig.BuildArgs

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

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

        buildContext = LocalBuildContext(config, localPlatformBuildContext,
                                         generatorReportDict,
                                         generatorContext.GeneratorName)
        for package in resolvedBuildOrderBuildable:
            config.LogPrint("Building package: {0}".format(package.Name))
            config.LogPrint("Package location: {0}".format(
                package.AbsolutePath))
            if not config.IsDryRun:
                buildEnv = os.environ.copy()  # type: Dict[str, str]
                buildEnv[CONFIG_FSLBUILDCONTENT_ENABLED] = "false"
                BuildVariantUtil.ExtendEnvironmentDictWithVariants(
                    config, buildEnv, package, buildConfig.VariantSettingsDict)
                buildConfig.BuildArgs = list(originalBuildArgs)
                if config.Verbosity > 4:
                    config.DoPrint("Package build arguments1: {0}".format(
                        buildConfig.BuildArgs))
                    config.DoPrint("General build arguments2: {0}".format(
                        originalBuildArgs))
                strRunCommands = buildConfig.RunCommand
                runCommands = None  # type: Optional[List[str]]
                if strRunCommands is not None:
                    userRunCommands = shlex.split(strRunCommands)
                    runCommands = self.__TryGenerateRunCommandForExecutable(
                        buildContext, package, buildConfig.VariantSettingsDict,
                        userRunCommands)
                if runValidationChecks:
                    featureList = [
                        entry.Name for entry in package.ResolvedAllUsedFeatures
                    ]
                    Validate.ValidatePlatform(config, buildConfig.PlatformName,
                                              featureList, 4)
                self.__BuildPackage(buildContext, package, buildConfig,
                                    buildEnv, runCommands)

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