INNER CODE UNIT · Swift
recursivePackageDependencies
skiptools/skip · Plugins/SkipPlugin/SkipPlugin.swift:137
func recursivePackageDependencies(for package: Package) -> [PackageDependency] {
package.dependencies.flatMap { dependency in
guard visitedPackageIDs.insert(dependency.package.id).inserted else {
return [] as [PackageDependency]
}
return [dependency] + recursivePackageDependencies(for: dependency.package)
}
}
let packageDeps = recursivePackageDependencies(for: context.package)
// create a lookup table from the (arbitrary but unique) product ID to the owning package
// this is needed to find the package ID associated with a given product ID
var productIDPackages: [Product.ID?: Package] = [:]
for targetPackage in packageDeps {
for product in targetPackage.package.products {
productIDPackages[product.id] = targetPackage.package
}