Esempio n. 1
0
 def __ResolvePackageDependencies(self, platformName: str, package: Package) -> None:
     for dep in package.GetDirectDependencies(platformName):
         if not dep.Name in self.OriginalPackageDict:
             raise DependencyNotFoundException(package.Name, dep.Name)
         elif package.Type != PackageType.TopLevel and not self.OriginalPackageDict[dep.Name].AllowDependencyOnThis:
             raise InvalidDependencyException(package.Name, dep.Name)
         else:
             resolvedDep = PackageDependency(self.OriginalPackageDict[dep.Name], dep.Access)
             package.ResolvedDirectDependencies.append(resolvedDep)
Esempio n. 2
0
    def __DoResolveAllPackageDependencies(self, config: Config,
                                          package: Package) -> None:
        # FIX: we are doing some of the same checks twice here
        addedDict = {}  # type: Dict[str, PackageDependency]
        # First we resolve all direct dependencies
        for dep in package.ResolvedDirectDependencies:
            if not dep.Name in addedDict:
                package.ResolvedAllDependencies.append(dep)
                addedDict[dep.Name] = dep
            else:
                # The package was already added so we need to check if this dependency is less restrictive than the old one
                oldDep = addedDict[dep.Name]
                if dep.Access < oldDep.Access:
                    package.ResolvedAllDependencies.remove(oldDep)
                    addedDict[dep.Name] = dep

        # Then we pull in the childrens dependencies
        resolvedDirectDependencies = list(package.ResolvedDirectDependencies)
        for directDep in resolvedDirectDependencies:
            for dep in directDep.Package.ResolvedAllDependencies:
                # ensure that anything we get via a non public access type keeps gets a access type that is >= directDep.Access
                if dep.Access < directDep.Access or dep.Access == AccessType.Private:
                    #dep = PackageDependency(dep.Package, directDep.Access)
                    dep = PackageDependency(dep.Package, AccessType.Link)
                if not dep.Name in addedDict:
                    package.ResolvedAllDependencies.append(dep)
                    addedDict[dep.Name] = dep
                else:
                    # The package was already added so we need to check if this dependency is less restrictive than the old one
                    oldDep = addedDict[dep.Name]
                    if dep.Access < oldDep.Access:
                        package.ResolvedAllDependencies.remove(oldDep)
                        package.ResolvedAllDependencies.append(dep)
                        addedDict[dep.Name] = dep
                        foundDep = self.__TryFindDep(
                            package.ResolvedDirectDependencies, dep)
                        if foundDep is not None:
                            config.DoPrintWarning(
                                "Requested dependency access to '{0}', overwritten by dependency from '{1}'"
                                .format(dep.Name, directDep.Name))
                            package.ResolvedDirectDependencies.remove(foundDep)
                            package.ResolvedDirectDependencies.append(dep)

        package.ResolvedDirectDependencies.sort(key=lambda s: s.Name.lower())
        package.ResolvedAllDependencies.sort(key=lambda s: s.Name.lower())
Esempio n. 3
0
 def __ResolvePackageDependencies(self, package: Package, originalPackageDict: Dict[PackageInstanceName, Package]) -> None:
     for dep in package.GetDirectDependencies():
         depPackage = self.__ResolvePackageDependency(package, dep.Name, originalPackageDict)
         package.ResolvedDirectDependencies.append(PackageDependency(depPackage, dep.Access))