Exemple #1
0
    def __BuildDirectDependencies(
        createContext: FactoryCreateContext,
        packageProjectContext: PackageProjectContext,
        packageName: PackageInstanceName, packageType: PackageType,
        directDependencies: List[UnresolvedPackageDependency],
        directExperimentalRecipe: Optional[XmlExperimentalRecipe],
        resolvedPlatform: PackagePlatform
    ) -> List[UnresolvedPackageDependency]:
        if (packageType == PackageType.ExternalLibrary
                and resolvedPlatform.Name
                == PackageConfig.PlatformNameString.ANDROID
                and createContext.IsWindows
                and directExperimentalRecipe is not None
                and not UnresolvedFactory.__ContainsDependency(
                    directDependencies,
                    createContext.NinjaRecipePackageName.Value)):
            directDependencies += [
                UnresolvedPackageDependency(
                    createContext.NinjaRecipePackageName, AccessType.Public)
            ]

        for basePackage in packageProjectContext.BasePackages:
            if packageType != PackageType.ToolRecipe and packageName.Value != basePackage.Name and not UnresolvedFactory.__ContainsDependency(
                    directDependencies, basePackage.Name):
                directDependencies += [
                    UnresolvedPackageDependency(
                        UnresolvedPackageName(basePackage.Name),
                        AccessType.Public)
                ]

        return directDependencies + resolvedPlatform.DirectDependencies
Exemple #2
0
    def __CreateTopLevelPackage(log: Log,
                                graph: DependencyGraph) -> EvaluationPackage:
        # Extract the top level nodes and add them as direct dependencies to a 'top level node' (so we can determine the global build order)
        topLevelNodes = graph.FindNodesWithNoIncomingDependencies(
        )  # type: List[DependencyGraphNode]

        if len(topLevelNodes) < 1:
            raise Exception(
                "Internal error, no top level nodes found, so either no packages are available or there is a circular dependency"
            )

        # If there are no top level nodes, that means we are likely to have a circular dependency
        # so we just rely on the circular dependency detection to handle it
        log.LogPrintVerbose(LocalVerbosityLevel.Info,
                            "Main packages: {0}".format(len(topLevelNodes)))

        unresolvedDirectDependencies = [
        ]  # type: List[UnresolvedPackageDependency]
        packageDirectDependencies = [
        ]  # type: List[EvaluationPackage.DependencyRecord]
        for package in topLevelNodes:
            packageDirectDependencies.append(
                EvaluationPackage.DependencyRecord(package.Source, None))
            unresolvedDirectDependencies.append(
                UnresolvedPackageDependency(
                    package.Source.Name,
                    AccessType.Public,
                ))
        newTopLevel = UnresolvedBasicPackage(
            UnresolvedPackageName(PackageNameMagicString.TopLevelName),
            PackageType.TopLevel, unresolvedDirectDependencies, [])
        return EvaluationPackage(newTopLevel.Name, newTopLevel,
                                 packageDirectDependencies)
Exemple #3
0
 def ToUnresolvedPackageDependency(
         xmlValue: XmlGenFileDependency,
         allowInternalNames: bool) -> UnresolvedPackageDependency:
     unresolvedPackageName = UnresolvedPackageName(xmlValue.Name,
                                                   allowInternalNames)
     flavorConstraints = XmlConvert.__ToPackageFlavorSelections(
         xmlValue.Flavor)
     return UnresolvedPackageDependency(unresolvedPackageName,
                                        xmlValue.Access, flavorConstraints,
                                        xmlValue.IfCondition)
Exemple #4
0
 def __ToUnresolvedBasicPackages(
         allPackages: List[UnresolvedPackage]
 ) -> List[UnresolvedBasicPackage]:
     allUnresolvedPackages = []  # type: List[UnresolvedBasicPackage]
     for package in allPackages:
         directDependencies = package.DirectDependencies
         flavors = package.ResolvedPlatform.Flavors
         unresolvedBasicPackage = UnresolvedBasicPackage(
             UnresolvedPackageName(package.NameInfo.FullName.Value),
             package.Type, directDependencies, flavors)
         allUnresolvedPackages.append(unresolvedBasicPackage)
     return allUnresolvedPackages
Exemple #5
0
 def __GenerateFlavors(
         createContext: FactoryCreateContext,
         xmlFlavors: List[XmlGenFileFlavor]
 ) -> List[UnresolvedPackageFlavor]:
     res = []  # type: List[UnresolvedPackageFlavor]
     for xmlFlavor in xmlFlavors:
         options = XmlConvert.__GenerateFlavorOptions(
             createContext, xmlFlavor.Options)
         flavor = UnresolvedPackageFlavor(
             PackageFlavorName(xmlFlavor.Name),
             UnresolvedPackageName(xmlFlavor.IntroducedByPackageName),
             options)
         res.append(flavor)
     return res
Exemple #6
0
    def ResolveBuildOrder(
        log: Log, allPackages: List[UnresolvedBasicPackage]
    ) -> List[UnresolvedBasicPackage]:
        log.LogPrintVerbose(LocalVerbosityLevel.Info, "Resolve build order")
        log.PushIndent()
        try:

            finalBuildOrder = []  # type: List[UnresolvedBasicPackage]
            if len(allPackages) <= 0:
                log.LogPrintVerbose(LocalVerbosityLevel.Info,
                                    "No packages supplied")
                finalBuildOrder.append(
                    UnresolvedBasicPackage.Create2(
                        UnresolvedPackageName(
                            PackageNameMagicString.TopLevelName),
                        PackageType.TopLevel))
            else:
                evaluationPackages = PackageBuildOrder.__ResolveEvaluationPackages(
                    log, allPackages)  # type: List[EvaluationPackage]

                PackageBuildOrder.__ValidateDependencies(
                    log, evaluationPackages)

                log.LogPrintVerbose(
                    LocalVerbosityLevel.Info,
                    "Determining build order for {0} packages".format(
                        len(allPackages)))

                graph, topLevelNode = PackageBuildOrder.__CreateDependencyGraph(
                    log, evaluationPackages)

                buildOrder = graph.DetermineBuildOrder(topLevelNode.Source)
                for entry in buildOrder:
                    finalBuildOrder.append(entry.SourcePackage)
                finalBuildOrder.append(topLevelNode.Source.SourcePackage)

            PackageBuildOrder.__ValidateConstraints(log, finalBuildOrder)
            return finalBuildOrder
        finally:
            log.PopIndent()
Exemple #7
0
 def __GenerateFlavorOptions(
     createContext: FactoryCreateContext,
     xmlFlavorOptions: List[XmlGenFileFlavorOption]
 ) -> List[UnresolvedPackageFlavorOption]:
     res = []  # type: List[UnresolvedPackageFlavorOption]
     for xmlFlavorOption in xmlFlavorOptions:
         name = PackageFlavorOptionName(xmlFlavorOption.Name)
         introducedByPackageName = UnresolvedPackageName(
             xmlFlavorOption.IntroducedByPackageName)
         directRequirements = XmlConvert.ToUnresolvedPackageRequirementList(
             xmlFlavorOption.DirectRequirements)
         directDependencies = XmlConvert.ToUnresolvedPackageDependencyList(
             xmlFlavorOption.DirectDependencies, False)
         externalDependencies = XmlConvert.ToUnresolvedExternalDependencyList(
             xmlFlavorOption.ExternalDependencies)
         directDefines = XmlConvert.ToUnresolvedPackageDefineList(
             xmlFlavorOption.DirectDefines)
         flavorOption = UnresolvedFactory.CreateUnresolvedPackageFlavorOption(
             createContext, name, introducedByPackageName,
             directRequirements, directDependencies, externalDependencies,
             directDefines)
         res.append(flavorOption)
     return res
Exemple #8
0
 def __CreateFactoryCreateContext(log: Log, toolConfig: ToolConfig, generatorInfo: GeneratorInfo) -> FactoryCreateContext:
     ninjaRecipePackageName = UnresolvedPackageName(toolConfig.CMakeConfiguration.NinjaRecipePackageName)
     isWindows = PlatformUtil.DetectBuildPlatformType() == BuildPlatformType.Windows
     return FactoryCreateContext(log, generatorInfo, ninjaRecipePackageName, isWindows)