Beispiel #1
0
    def GetDirectDependencies(self,
                              platformName: str) -> List[XmlGenFileDependency]:
        directDependencies = self.GenFile.DirectDependencies
        if (self.Type == PackageType.ExternalLibrary
                and platformName == PlatformNameString.ANDROID
                and PlatformUtil.DetectBuildPlatformType()
                == BuildPlatformType.Windows and
                self.__TryGetExperimentaleRecipe(platformName) is not None):
            directDependencies += [
                FakeXmlGenFileDependency(self._BasicConfig,
                                         "Recipe.BuildTool.ninja",
                                         AccessType.Public)
            ]
        if not platformName in self.Platforms:
            return directDependencies

        for basePackage in self.ProjectContext.BasePackages:
            if self.Name != basePackage.Name and not self.__ContainsDependency(
                    directDependencies,
                    basePackage.Name) and self.Type != PackageType.ToolRecipe:
                directDependencies += [
                    FakeXmlGenFileDependency(self._BasicConfig,
                                             basePackage.Name,
                                             AccessType.Public)
                ]

        return directDependencies + self.Platforms[
            platformName].DirectDependencies
Beispiel #2
0
    def __init__(self,
                 config: Config,
                 platformName: str,
                 generatorInfo: GeneratorInfo,
                 genFiles: List[XmlGenFile],
                 logVerbosity: int = 1) -> None:
        super().__init__()

        # create top level package and resolve build order
        config.LogPrintVerbose(logVerbosity, "Validating dependencies")

        packageManager = PackageManager(config, platformName, generatorInfo,
                                        genFiles)
        packages = packageManager.Packages

        # Build a graph containing all packages
        graph = DependencyGraph(None)  #, True)
        for package in packages:
            graph.AddNode(package)
        graph.Finalize()

        # Extract the top level nodes
        nodes = graph.GetNodesWithNoIncomingDependencies()
        #useFallback = True
        if len(nodes) > 0:
            topLevelGenFile = XmlGenFile(
                config, config.ToolConfig.DefaultPackageLanguage)
            topLevelGenFile.Name = PackageNameMagicString.TopLevelName
            topLevelGenFile.SetType(PackageType.TopLevel)
            for entry in nodes:
                topLevelGenFile.DirectDependencies.append(
                    FakeXmlGenFileDependency(config, entry.Name,
                                             AccessType.Public))

            topLevelGenFile.DirectDependencies.sort(
                key=lambda s: s.Name.lower())
        else:
            # We have circular dependencies and couldnt find any starting nodes
            # so generate a empty top level node and expect a circular dependency
            # error to be caught
            topLevelGenFile = XmlGenFile(
                config, config.ToolConfig.DefaultPackageLanguage)
            topLevelGenFile.Name = PackageNameMagicString.TopLevelName
            topLevelGenFile.SetType(PackageType.TopLevel)

        topLevelPackage = packageManager.CreatePackage(config, platformName,
                                                       topLevelGenFile, True)
        graph.AddNodeAndEdges(topLevelPackage)

        # Since we need to resolve the build order we might as well verify dependencies at the same time
        self.__ValidateDependencies(config, packages)
        self.AllPackages = packages  # type: List[Package]
        self.TopLevelPackage = topLevelPackage
        self.__ResolveAllPackageDependencies(config, topLevelPackage)