From 9dbb9a00084f02785f4790a69763324bede4f4ac Mon Sep 17 00:00:00 2001 From: tomer doron Date: Tue, 20 Jul 2021 17:56:28 -0700 Subject: [PATCH] Revert "adopt swift-collections (#3595)" This reverts commit 0b0ac517524ecfe423c66f13854fa069309b3437. --- CMakeLists.txt | 3 +-- CONTRIBUTING.md | 15 ++++----------- Package.swift | 11 +++-------- Sources/Basics/CMakeLists.txt | 2 -- Sources/Basics/Exports.swift | 14 -------------- Sources/Build/BuildPlan.swift | 2 +- Sources/PackageGraph/PackageGraph+Loading.swift | 4 ++-- .../PackageGraph/Pubgrub/Incompatibility.swift | 12 ++++++------ .../PackageGraph/Pubgrub/PartialSolution.swift | 2 +- .../Pubgrub/PubgrubDependencyResolver.swift | 6 +++--- Sources/PackageLoading/PackageBuilder.swift | 4 ++-- Tests/PackageGraphTests/PubgrubTests.swift | 16 +++++++++------- Utilities/bootstrap | 15 +++++---------- 13 files changed, 37 insertions(+), 69 deletions(-) delete mode 100644 Sources/Basics/Exports.swift diff --git a/CMakeLists.txt b/CMakeLists.txt index 38a41305ac7..db4c32af6a7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,7 +37,7 @@ string(COMPARE EQUAL ${CMAKE_SYSTEM_NAME} Windows CMAKE_INSTALL_DEFAULT) option(USE_CMAKE_INSTALL "Install build products using cmake's install() instead of the bootstrap script's install()" ${CMAKE_INSTALL_DEFAULT}) - + if(BUILD_SHARED_LIBS) set(CMAKE_POSITION_INDEPENDENT_CODE YES) endif() @@ -53,7 +53,6 @@ if(FIND_PM_DEPS) find_package(ArgumentParser CONFIG REQUIRED) find_package(SwiftCrypto CONFIG REQUIRED) find_package(SwiftDriver CONFIG REQUIRED) - find_package(SwiftCollections CONFIG REQUIRED) endif() find_package(dispatch QUIET) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0cd7701fae1..9bc7b4fdfe5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -132,7 +132,7 @@ Please refer to the [_Get Started_ guide](https://github.com/apple/swift/blob/ma Clone the following repositories beside the SwiftPM directory: 1. [swift-argument-parser] and check out tag with the [latest version](https://github.com/apple/swift-argument-parser/tags). - + For example, if the latest tag is 0.4.3: ```sh $> git clone https://github.com/apple/swift-argument-parser --branch 0.4.3 @@ -150,7 +150,7 @@ Clone the following repositories beside the SwiftPM directory: ``` 4. [Yams] and checkout tag with the [latest version](https://github.com/jpsim/Yams.git/tags) before 5.0.0. - + For example, if the latest tag is 4.0.6: ```sh $> git clone https://github.com/jpsim/yams --branch 4.0.6 @@ -162,21 +162,13 @@ Clone the following repositories beside the SwiftPM directory: ``` 6. [swift-crypto] and check out tag with the [latest version](https://github.com/apple/swift-crypto/tags). - + For example, if the latest tag is 1.1.6: ```sh $> git clone https://github.com/apple/swift-crypto --branch 1.1.6 ``` -7. [swift-collections] and check out tag with the [latest version](https://github.com/apple/swift-collections/tags). - - For example, if the latest tag is 0.0.4: - ```sh - $> git clone https://github.com/apple/swift-collections --branch 0.0.4 - ``` - [swift-argument-parser]: https://github.com/apple/swift-argument-parser -[swift-collections]: https://github.com/apple/swift-collections [swift-crypto]: https://github.com/apple/swift-crypto [swift-driver]: https://github.com/apple/swift-driver [swift-llbuild]: https://github.com/apple/swift-llbuild @@ -393,3 +385,4 @@ $> swift package update ``` Alternatively, if you are using Xcode, you can update to the latest version of all packages: **Xcode App** > *File* > *Swift Packages* > *Update to Latest Package Versions* + diff --git a/Package.swift b/Package.swift index fd1f34b40fb..5002c64ea30 100644 --- a/Package.swift +++ b/Package.swift @@ -15,7 +15,7 @@ import class Foundation.ProcessInfo /** SwiftPMDataModel is the subset of SwiftPM product that includes just its data model. -This allows some clients (such as IDEs) that use SwiftPM's data model but not its build system +This allowis some clients (such as IDEs) that use SwiftPM's data model but not its build system to not have to depend on SwiftDriver, SwiftLLBuild, etc. We should probably have better names here, though that could break some clients. */ @@ -33,7 +33,7 @@ let swiftPMDataModelProduct = ( ] ) -/** The `libSwiftPM` set of interfaces to programmatically work with Swift +/** The `libSwiftPM` set of interfaces to programatically work with Swift packages. `libSwiftPM` includes all of the SwiftPM code except the command line tools, while `libSwiftPMDataModel` includes only the data model. @@ -126,10 +126,7 @@ let package = Package( .target( name: "Basics", - dependencies: [ - .product(name: "OrderedCollections", package: "swift-collections"), - "SwiftToolsSupport-auto" - ]), + dependencies: ["SwiftToolsSupport-auto"]), .target( /** The llbuild manifest model */ @@ -359,7 +356,6 @@ if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil { .package(url: "https://github.com/apple/swift-argument-parser.git", .upToNextMinor(from: "0.4.3")), .package(url: "https://github.com/apple/swift-driver.git", .branch(relatedDependenciesBranch)), .package(url: "https://github.com/apple/swift-crypto.git", .upToNextMinor(from: "1.1.4")), - .package(url: "https://github.com/apple/swift-collections.git", .upToNextMinor(from: "0.0.4")), ] } else { package.dependencies += [ @@ -367,6 +363,5 @@ if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil { .package(path: "../swift-argument-parser"), .package(path: "../swift-driver"), .package(path: "../swift-crypto"), - .package(path: "../swift-collections"), ] } diff --git a/Sources/Basics/CMakeLists.txt b/Sources/Basics/CMakeLists.txt index 8aef8c3d133..85a70163ef4 100644 --- a/Sources/Basics/CMakeLists.txt +++ b/Sources/Basics/CMakeLists.txt @@ -12,7 +12,6 @@ add_library(Basics Dictionary+Extensions.swift DispatchTimeInterval+Extensions.swift Errors.swift - Exports.swift FileSystem+Extensions.swift HTPClient+URLSession.swift HTTPClient.swift @@ -22,7 +21,6 @@ add_library(Basics SQLiteBackedCache.swift Version+Extensions.swift) target_link_libraries(Basics PUBLIC - SwiftCollections::OrderedCollections TSCBasic TSCUtility) target_link_libraries(Basics PRIVATE diff --git a/Sources/Basics/Exports.swift b/Sources/Basics/Exports.swift deleted file mode 100644 index 500adafbd6b..00000000000 --- a/Sources/Basics/Exports.swift +++ /dev/null @@ -1,14 +0,0 @@ -/* - This source file is part of the Swift.org open source project - - Copyright (c) 2021 Apple Inc. and the Swift project authors - Licensed under Apache License v2.0 with Runtime Library Exception - - See http://swift.org/LICENSE.txt for license information - See http://swift.org/CONTRIBUTORS.txt for Swift project authors - */ - -import OrderedCollections - -public typealias OrderedDictionary = OrderedCollections.OrderedDictionary -public typealias OrderedSet = OrderedCollections.OrderedSet diff --git a/Sources/Build/BuildPlan.swift b/Sources/Build/BuildPlan.swift index ec6b836ec2e..78072f5b17d 100644 --- a/Sources/Build/BuildPlan.swift +++ b/Sources/Build/BuildPlan.swift @@ -1987,7 +1987,7 @@ public class BuildPlan { } // Build cache - var cflagsCache: Basics.OrderedSet = [] + var cflagsCache: OrderedSet = [] var libsCache: [String] = [] for tuple in ret { for cFlag in tuple.cFlags { diff --git a/Sources/PackageGraph/PackageGraph+Loading.swift b/Sources/PackageGraph/PackageGraph+Loading.swift index 2aa4445e4c4..bd26d21a720 100644 --- a/Sources/PackageGraph/PackageGraph+Loading.swift +++ b/Sources/PackageGraph/PackageGraph+Loading.swift @@ -611,7 +611,7 @@ fileprivate func findCycle( successors: (GraphLoadingNode) throws -> [GraphLoadingNode] ) rethrows -> (path: [Manifest], cycle: [Manifest])? { // Ordered set to hold the current traversed path. - var path = Basics.OrderedSet() + var path = OrderedSet() // Function to visit nodes recursively. // FIXME: Convert to stack. @@ -620,7 +620,7 @@ fileprivate func findCycle( _ successors: (GraphLoadingNode) throws -> [GraphLoadingNode] ) rethrows -> (path: [Manifest], cycle: [Manifest])? { // If this node is already in the current path then we have found a cycle. - if !path.append(node.manifest).inserted { + if !path.append(node.manifest) { let index = path.firstIndex(of: node.manifest)! // forced unwrap safe return (Array(path[path.startIndex.. + public let terms: OrderedSet public let cause: Cause - public init(terms: Basics.OrderedSet, cause: Cause) { + public init(terms: OrderedSet, cause: Cause) { self.terms = terms self.cause = cause } public init(_ terms: Term..., root: DependencyResolutionNode, cause: Cause = .root) throws { - let termSet = Basics.OrderedSet(terms) + let termSet = OrderedSet(terms) try self.init(termSet, root: root, cause: cause) } - public init(_ terms: Basics.OrderedSet, root: DependencyResolutionNode, cause: Cause) throws { + public init(_ terms: OrderedSet, root: DependencyResolutionNode, cause: Cause) throws { if terms.isEmpty { self.init(terms: terms, cause: cause) return @@ -43,7 +43,7 @@ public struct Incompatibility: Equatable, Hashable { terms = OrderedSet(terms.filter { !$0.isPositive || $0.node != root }) } - let normalizedTerms = try normalize(terms: terms.elements) + let normalizedTerms = try normalize(terms: terms.contents) assert(normalizedTerms.count > 0, "An incompatibility must contain at least one term after normalization.") self.init(terms: OrderedSet(normalizedTerms), cause: cause) @@ -134,7 +134,7 @@ extension Incompatibility { /// requirements to a^1.5.0. fileprivate func normalize(terms: [Term]) throws -> [Term] { - let dict = try terms.reduce(into: Basics.OrderedDictionary()) { + let dict = try terms.reduce(into: OrderedDictionary()) { res, term in // Don't try to intersect if this is the first time we're seeing this package. guard let previous = res[term.node] else { diff --git a/Sources/PackageGraph/Pubgrub/PartialSolution.swift b/Sources/PackageGraph/Pubgrub/PartialSolution.swift index 62647e96333..044a1694dfa 100644 --- a/Sources/PackageGraph/Pubgrub/PartialSolution.swift +++ b/Sources/PackageGraph/Pubgrub/PartialSolution.swift @@ -25,7 +25,7 @@ public struct PartialSolution { /// The intersection of all positive assignments for each package, minus any /// negative assignments that refer to that package. - public private(set) var _positive: Basics.OrderedDictionary = [:] + public private(set) var _positive: OrderedDictionary = [:] /// Union of all negative assignments for a package. /// diff --git a/Sources/PackageGraph/Pubgrub/PubgrubDependencyResolver.swift b/Sources/PackageGraph/Pubgrub/PubgrubDependencyResolver.swift index d88e62e0442..57478dd4e1b 100644 --- a/Sources/PackageGraph/Pubgrub/PubgrubDependencyResolver.swift +++ b/Sources/PackageGraph/Pubgrub/PubgrubDependencyResolver.swift @@ -445,7 +445,7 @@ public struct PubgrubDependencyResolver { /// If a conflict is found, the conflicting incompatibility is returned to /// resolve the conflict on. internal func propagate(state: State, node: DependencyResolutionNode) throws { - var changed: Basics.OrderedSet = [node] + var changed: OrderedSet = [node] while !changed.isEmpty { let package = changed.removeFirst() @@ -1209,7 +1209,7 @@ private final class PubGrubPackageContainer { throw InternalError("Unexpected unversioned requirement: \(constraint)") } return try constraint.nodes().map { dependencyNode in - var terms: Basics.OrderedSet = [] + var terms: OrderedSet = [] terms.append(Term(node, .exact(version))) terms.append(Term(not: dependencyNode, vs)) return try Incompatibility(terms, root: root, cause: .dependency(node: node)) @@ -1223,7 +1223,7 @@ private final class PubGrubPackageContainer { products: node.productFilter) return try constraints.map { constraint in - var terms: Basics.OrderedSet = [] + var terms: OrderedSet = [] let lowerBound = lowerBounds[constraint.package] ?? "0.0.0" let upperBound = upperBounds[constraint.package] ?? Version(version.major + 1, 0, 0) assert(lowerBound < upperBound) diff --git a/Sources/PackageLoading/PackageBuilder.swift b/Sources/PackageLoading/PackageBuilder.swift index bf8bf048173..05967dbf186 100644 --- a/Sources/PackageLoading/PackageBuilder.swift +++ b/Sources/PackageLoading/PackageBuilder.swift @@ -1190,11 +1190,11 @@ public final class PackageBuilder { /// Collects the products defined by a package. private func constructProducts(_ targets: [Target]) throws -> [Product] { - var products = Basics.OrderedSet>() + var products = OrderedSet>() /// Helper method to append to products array. func append(_ product: Product) { - let inserted = products.append(KeyedPair(product, key: product.name)).inserted + let inserted = products.append(KeyedPair(product, key: product.name)) if !inserted { diagnostics.emit( .duplicateProduct(product: product), diff --git a/Tests/PackageGraphTests/PubgrubTests.swift b/Tests/PackageGraphTests/PubgrubTests.swift index 91fdc33a0bd..29c7dec57e4 100644 --- a/Tests/PackageGraphTests/PubgrubTests.swift +++ b/Tests/PackageGraphTests/PubgrubTests.swift @@ -8,13 +8,15 @@ See http://swift.org/CONTRIBUTORS.txt for Swift project authors */ -import Basics -@testable import PackageGraph +import XCTest + +import TSCBasic import PackageLoading @testable import PackageModel +@testable import PackageGraph import SourceControl -import TSCBasic -import XCTest + + // There's some useful helper utilities defined below for easier testing: // @@ -2153,7 +2155,7 @@ class DependencyGraphBuilder { } func create( - dependencies: Basics.OrderedDictionary + dependencies: OrderedDictionary ) -> [PackageContainerConstraint] { return dependencies.map { PackageContainerConstraint(package: reference(for: $0), requirement: $1.0, products: $1.1) @@ -2164,7 +2166,7 @@ class DependencyGraphBuilder { _ package: String, at version: Version, toolsVersion: ToolsVersion? = nil, - with dependencies: KeyValuePairs> = [:] + with dependencies: KeyValuePairs> = [:] ) { serve(package, at: .version(version), toolsVersion: toolsVersion, with: dependencies) } @@ -2173,7 +2175,7 @@ class DependencyGraphBuilder { _ package: String, at version: BoundVersion, toolsVersion: ToolsVersion? = nil, - with dependencies: KeyValuePairs> = [:] + with dependencies: KeyValuePairs> = [:] ) { let packageReference = reference(for: package) let container = self.containers[package] ?? MockContainer(package: packageReference) diff --git a/Utilities/bootstrap b/Utilities/bootstrap index d3fce194aa0..38617192964 100755 --- a/Utilities/bootstrap +++ b/Utilities/bootstrap @@ -185,7 +185,6 @@ def parse_global_args(args): args.source_dirs["swift-argument-parser"] = os.path.join(args.project_root, "..", "swift-argument-parser") args.source_dirs["swift-driver"] = os.path.join(args.project_root, "..", "swift-driver") args.source_dirs["swift-crypto"] = os.path.join(args.project_root, "..", "swift-crypto") - args.source_dirs["swift-collections"] = os.path.join(args.project_root, "..", "swift-collections") args.source_root = os.path.join(args.project_root, "Sources") if platform.system() == 'Darwin': @@ -342,7 +341,6 @@ def build(args): ] build_dependency(args, "swift-driver", swift_driver_cmake_flags) build_dependency(args, "swift-crypto") - build_dependency(args, "swift-collections") build_swiftpm_with_cmake(args) build_swiftpm_with_swiftpm(args,integrated_swift_driver=False) @@ -555,12 +553,11 @@ def build_swiftpm_with_cmake(args): cmake_flags = [ get_llbuild_cmake_arg(args), - "-DTSC_DIR=" + os.path.join(args.build_dirs["tsc"], "cmake/modules"), - "-DYams_DIR=" + os.path.join(args.build_dirs["yams"], "cmake/modules"), - "-DArgumentParser_DIR=" + os.path.join(args.build_dirs["swift-argument-parser"], "cmake/modules"), - "-DSwiftDriver_DIR=" + os.path.join(args.build_dirs["swift-driver"], "cmake/modules"), - "-DSwiftCrypto_DIR=" + os.path.join(args.build_dirs["swift-crypto"], "cmake/modules"), - "-DSwiftCollections_DIR=" + os.path.join(args.build_dirs["swift-collections"], "cmake/modules"), + "-DTSC_DIR=" + os.path.join(args.build_dirs["tsc"], "cmake/modules"), + "-DYams_DIR=" + os.path.join(args.build_dirs["yams"], "cmake/modules"), + "-DArgumentParser_DIR=" + os.path.join(args.build_dirs["swift-argument-parser"], "cmake/modules"), + "-DSwiftDriver_DIR=" + os.path.join(args.build_dirs["swift-driver"], "cmake/modules"), + "-DSwiftCrypto_DIR=" + os.path.join(args.build_dirs["swift-crypto"], "cmake/modules"), ] if platform.system() == 'Darwin': @@ -577,7 +574,6 @@ def build_swiftpm_with_cmake(args): add_rpath_for_cmake_build(args, os.path.join(args.build_dirs["swift-argument-parser"], "lib")) add_rpath_for_cmake_build(args, os.path.join(args.build_dirs["swift-driver"], "lib")) add_rpath_for_cmake_build(args, os.path.join(args.build_dirs["swift-crypto"], "lib")) - add_rpath_for_cmake_build(args, os.path.join(args.build_dirs["swift-collections"], "lib")) def build_swiftpm_with_swiftpm(args, integrated_swift_driver): """Builds SwiftPM using the version of SwiftPM built with CMake.""" @@ -676,7 +672,6 @@ def get_swiftpm_env_cmd(args): os.path.join(args.build_dirs["swift-argument-parser"], "lib"), os.path.join(args.build_dirs["swift-driver"], "lib"), os.path.join(args.build_dirs["swift-crypto"], "lib"), - os.path.join(args.build_dirs["swift-collections"], "lib"), ] + args.target_info["paths"]["runtimeLibraryPaths"]) if platform.system() == 'Darwin':