From e8910f4046cfb6fbade329bee990c94e3a63b694 Mon Sep 17 00:00:00 2001 From: Ankit Aggarwal Date: Wed, 6 Nov 2019 11:15:56 -0800 Subject: [PATCH] Sync with SwiftPM trunk --- Sources/TSCBasic/CMakeLists.txt | 2 ++ Sources/TSCBasic/Path.swift | 17 ++++++++++++++++- Sources/TSCLibc/CMakeLists.txt | 2 ++ Sources/TSCTestSupport/XCTAssertHelpers.swift | 5 +++++ Sources/TSCUtility/Versioning.swift | 2 +- 5 files changed, 26 insertions(+), 2 deletions(-) diff --git a/Sources/TSCBasic/CMakeLists.txt b/Sources/TSCBasic/CMakeLists.txt index 29eafc98..ae7f5f7b 100644 --- a/Sources/TSCBasic/CMakeLists.txt +++ b/Sources/TSCBasic/CMakeLists.txt @@ -57,7 +57,9 @@ set_target_properties(TSCBasic PROPERTIES set_property(GLOBAL APPEND PROPERTY TSC_EXPORTS TSCBasic) +if(CMAKE_SYSTEM_NAME STREQUAL Windows) install(TARGETS TSCBasic ARCHIVE DESTINATION lib LIBRARY DESTINATION lib RUNTIME DESTINATION bin) +endif() diff --git a/Sources/TSCBasic/Path.swift b/Sources/TSCBasic/Path.swift index 06f50abc..dc60961e 100644 --- a/Sources/TSCBasic/Path.swift +++ b/Sources/TSCBasic/Path.swift @@ -7,6 +7,9 @@ See http://swift.org/LICENSE.txt for license information See http://swift.org/CONTRIBUTORS.txt for Swift project authors */ +#if os(Windows) +import Foundation +#endif /// Represents an absolute file system path, independently of what (or whether /// anything at all) exists at that path in the file system at any given time. @@ -370,6 +373,10 @@ private struct PathImpl: Hashable { /// string consisting of just `.` if there is no directory part (which is /// the case if and only if there is no path separator). fileprivate var dirname: String { +#if os(Windows) + let dir = string.deletingLastPathComponent + return dir == "" ? "." : dir +#else // FIXME: This method seems too complicated; it should be simplified, // if possible, and certainly optimized (using UTF8View). // Find the last path separator. @@ -385,6 +392,7 @@ private struct PathImpl: Hashable { // Otherwise, it's the string up to (but not including) the last path // separator. return String(string.prefix(upTo: idx)) +#endif } fileprivate var basename: String { @@ -561,11 +569,13 @@ private func mayNeedNormalization(absolute string: String) -> Bool { /// /// The normalization rules are as described for the AbsolutePath struct. private func normalize(absolute string: String) -> String { + #if os(Windows) + return string.standardizingPath + #else precondition(string.first == "/", "Failure normalizing \(string), absolute paths should start with '/'") // At this point we expect to have a path separator as first character. assert(string.first == "/") - // Fast path. if !mayNeedNormalization(absolute: string) { return string @@ -621,6 +631,7 @@ private func normalize(absolute string: String) -> String { // Use the result as our stored string. return result + #endif } /// Private function that normalizes and returns a relative string. Asserts @@ -628,6 +639,9 @@ private func normalize(absolute string: String) -> String { /// /// The normalization rules are as described for the AbsolutePath struct. private func normalize(relative string: String) -> String { + #if os(Windows) + return string.standardizingPath + #else precondition(string.first != "/") // FIXME: Here we should also keep track of whether anything actually has @@ -688,4 +702,5 @@ private func normalize(relative string: String) -> String { // If the result is empty, return `.`, otherwise we return it as a string. return result.isEmpty ? "." : result + #endif } diff --git a/Sources/TSCLibc/CMakeLists.txt b/Sources/TSCLibc/CMakeLists.txt index 3a3accb7..c1306a81 100644 --- a/Sources/TSCLibc/CMakeLists.txt +++ b/Sources/TSCLibc/CMakeLists.txt @@ -21,7 +21,9 @@ set_target_properties(TSCLibc PROPERTIES set_property(GLOBAL APPEND PROPERTY TSC_EXPORTS TSCLibc) +if(CMAKE_SYSTEM_NAME STREQUAL Windows) install(TARGETS TSCLibc ARCHIVE DESTINATION lib LIBRARY DESTINATION lib RUNTIME DESTINATION bin) +endif() diff --git a/Sources/TSCTestSupport/XCTAssertHelpers.swift b/Sources/TSCTestSupport/XCTAssertHelpers.swift index e62c50b9..cfb2921d 100644 --- a/Sources/TSCTestSupport/XCTAssertHelpers.swift +++ b/Sources/TSCTestSupport/XCTAssertHelpers.swift @@ -89,3 +89,8 @@ public func XCTAssertNoDiagnostics(_ engine: DiagnosticsEngine, file: StaticStri let diags = engine.diagnostics.map({ "- " + $0.description }).joined(separator: "\n") XCTFail("Found unexpected diagnostics: \n\(diags)", file: file, line: line) } + +public func XCTAssertEqual (_ lhs:(T,U), _ rhs:(T,U), file: StaticString = #file, line: UInt = #line) { + XCTAssertEqual(lhs.0, rhs.0) + XCTAssertEqual(lhs.1, rhs.1) +} diff --git a/Sources/TSCUtility/Versioning.swift b/Sources/TSCUtility/Versioning.swift index 6f5b848a..797d2f19 100644 --- a/Sources/TSCUtility/Versioning.swift +++ b/Sources/TSCUtility/Versioning.swift @@ -74,7 +74,7 @@ public struct Versioning { /// The current version of the package manager. public static let currentVersion = SwiftVersion( - version: (5, 1, 0), + version: (5, 2, 0), isDevelopment: false, buildIdentifier: getBuildIdentifier())