diff --git a/Sources/ScipioKit/DescriptionPackage.swift b/Sources/ScipioKit/DescriptionPackage.swift index 8b4a3281..687d8d2a 100644 --- a/Sources/ScipioKit/DescriptionPackage.swift +++ b/Sources/ScipioKit/DescriptionPackage.swift @@ -149,7 +149,7 @@ struct DescriptionPackage { } extension DescriptionPackage { - func resolveBuildProducts() throws -> [BuildProduct] { + func resolveBuildProducts() throws -> OrderedSet { let resolver = BuildProductsResolver(descriptionPackage: self) return try resolver.resolveBuildProducts() } @@ -167,6 +167,11 @@ struct BuildProduct: Hashable, Sendable { target.underlying as? ScipioBinaryModule } + static func == (lhs: Self, rhs: Self) -> Bool { + lhs.target.name == rhs.target.name && + lhs.package.identity == rhs.package.identity + } + func hash(into hasher: inout Hasher) { // Important: Relevant for swift-6.0+ toolchain versions. For the versions below // this change has no effect as SwiftPM provides its own proper `Hashable` @@ -185,8 +190,6 @@ struct BuildProduct: Hashable, Sendable { hasher.combine(package.identity) } } - - private final class BuildProductsResolver { private var buildProductsCache: [BuildProduct: Set] = [:] let descriptionPackage: DescriptionPackage @@ -195,7 +198,7 @@ private final class BuildProductsResolver { self.descriptionPackage = descriptionPackage } - func resolveBuildProducts() throws -> [BuildProduct] { + func resolveBuildProducts() throws -> OrderedSet { let targetsToBuild = try targetsToBuild() var products = try targetsToBuild.flatMap(resolveBuildProduct(from:)) @@ -232,7 +235,7 @@ private final class BuildProductsResolver { } } - return products.reversed() + return OrderedSet(products.reversed()) } private func targetsToBuild() throws -> [ScipioResolvedModule] {