Skip to content

Commit

Permalink
Revert "adopt swift-collections (#3595)" (#3628)
Browse files Browse the repository at this point in the history
This reverts commit 0b0ac51.
  • Loading branch information
tomerd authored Jul 22, 2021
1 parent fbcf039 commit c61078f
Show file tree
Hide file tree
Showing 13 changed files with 37 additions and 69 deletions.
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
Expand Down
15 changes: 4 additions & 11 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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*

11 changes: 3 additions & 8 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand All @@ -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.

Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -359,14 +356,12 @@ 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 += [
.package(path: "../swift-tools-support-core"),
.package(path: "../swift-argument-parser"),
.package(path: "../swift-driver"),
.package(path: "../swift-crypto"),
.package(path: "../swift-collections"),
]
}
2 changes: 0 additions & 2 deletions Sources/Basics/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
14 changes: 0 additions & 14 deletions Sources/Basics/Exports.swift

This file was deleted.

2 changes: 1 addition & 1 deletion Sources/Build/BuildPlan.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1987,7 +1987,7 @@ public class BuildPlan {
}

// Build cache
var cflagsCache: Basics.OrderedSet<String> = []
var cflagsCache: OrderedSet<String> = []
var libsCache: [String] = []
for tuple in ret {
for cFlag in tuple.cFlags {
Expand Down
4 changes: 2 additions & 2 deletions Sources/PackageGraph/PackageGraph+Loading.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<Manifest>()
var path = OrderedSet<Manifest>()

// Function to visit nodes recursively.
// FIXME: Convert to stack.
Expand All @@ -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..<index]), Array(path[index..<path.endIndex]))
}
Expand Down
12 changes: 6 additions & 6 deletions Sources/PackageGraph/Pubgrub/Incompatibility.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ import PackageModel
/// all be true at the same time. In dependency resolution, these are derived
/// from version requirements and when running into unresolvable situations.
public struct Incompatibility: Equatable, Hashable {
public let terms: Basics.OrderedSet<Term>
public let terms: OrderedSet<Term>
public let cause: Cause

public init(terms: Basics.OrderedSet<Term>, cause: Cause) {
public init(terms: OrderedSet<Term>, 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<Term>, root: DependencyResolutionNode, cause: Cause) throws {
public init(_ terms: OrderedSet<Term>, root: DependencyResolutionNode, cause: Cause) throws {
if terms.isEmpty {
self.init(terms: terms, cause: cause)
return
Expand All @@ -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)
Expand Down Expand Up @@ -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<DependencyResolutionNode, (req: VersionSetSpecifier, polarity: Bool)>()) {
let dict = try terms.reduce(into: OrderedDictionary<DependencyResolutionNode, (req: VersionSetSpecifier, polarity: Bool)>()) {
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 {
Expand Down
2 changes: 1 addition & 1 deletion Sources/PackageGraph/Pubgrub/PartialSolution.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<DependencyResolutionNode, Term> = [:]
public private(set) var _positive: OrderedDictionary<DependencyResolutionNode, Term> = [:]

/// Union of all negative assignments for a package.
///
Expand Down
6 changes: 3 additions & 3 deletions Sources/PackageGraph/Pubgrub/PubgrubDependencyResolver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<DependencyResolutionNode> = [node]
var changed: OrderedSet<DependencyResolutionNode> = [node]

while !changed.isEmpty {
let package = changed.removeFirst()
Expand Down Expand Up @@ -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<Term> = []
var terms: OrderedSet<Term> = []
terms.append(Term(node, .exact(version)))
terms.append(Term(not: dependencyNode, vs))
return try Incompatibility(terms, root: root, cause: .dependency(node: node))
Expand All @@ -1223,7 +1223,7 @@ private final class PubGrubPackageContainer {
products: node.productFilter)

return try constraints.map { constraint in
var terms: Basics.OrderedSet<Term> = []
var terms: OrderedSet<Term> = []
let lowerBound = lowerBounds[constraint.package] ?? "0.0.0"
let upperBound = upperBounds[constraint.package] ?? Version(version.major + 1, 0, 0)
assert(lowerBound < upperBound)
Expand Down
4 changes: 2 additions & 2 deletions Sources/PackageLoading/PackageBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<KeyedPair<Product, String>>()
var products = OrderedSet<KeyedPair<Product, String>>()

/// 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),
Expand Down
16 changes: 9 additions & 7 deletions Tests/PackageGraphTests/PubgrubTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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:
//
Expand Down Expand Up @@ -2153,7 +2155,7 @@ class DependencyGraphBuilder {
}

func create(
dependencies: Basics.OrderedDictionary<String, (PackageRequirement, ProductFilter)>
dependencies: OrderedDictionary<String, (PackageRequirement, ProductFilter)>
) -> [PackageContainerConstraint] {
return dependencies.map {
PackageContainerConstraint(package: reference(for: $0), requirement: $1.0, products: $1.1)
Expand All @@ -2164,7 +2166,7 @@ class DependencyGraphBuilder {
_ package: String,
at version: Version,
toolsVersion: ToolsVersion? = nil,
with dependencies: KeyValuePairs<String, Basics.OrderedDictionary<String, (PackageRequirement, ProductFilter)>> = [:]
with dependencies: KeyValuePairs<String, OrderedDictionary<String, (PackageRequirement, ProductFilter)>> = [:]
) {
serve(package, at: .version(version), toolsVersion: toolsVersion, with: dependencies)
}
Expand All @@ -2173,7 +2175,7 @@ class DependencyGraphBuilder {
_ package: String,
at version: BoundVersion,
toolsVersion: ToolsVersion? = nil,
with dependencies: KeyValuePairs<String, Basics.OrderedDictionary<String, (PackageRequirement, ProductFilter)>> = [:]
with dependencies: KeyValuePairs<String, OrderedDictionary<String, (PackageRequirement, ProductFilter)>> = [:]
) {
let packageReference = reference(for: package)
let container = self.containers[package] ?? MockContainer(package: packageReference)
Expand Down
15 changes: 5 additions & 10 deletions Utilities/bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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':
Expand All @@ -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."""
Expand Down Expand Up @@ -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':
Expand Down

0 comments on commit c61078f

Please sign in to comment.