Skip to content

Commit 693aba4

Browse files
authored
Merge pull request #8 from apple/update
Sync with SwiftPM trunk
2 parents 54a0b60 + e8910f4 commit 693aba4

File tree

5 files changed

+26
-2
lines changed

5 files changed

+26
-2
lines changed

Diff for: Sources/TSCBasic/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ set_target_properties(TSCBasic PROPERTIES
5757

5858
set_property(GLOBAL APPEND PROPERTY TSC_EXPORTS TSCBasic)
5959

60+
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
6061
install(TARGETS TSCBasic
6162
ARCHIVE DESTINATION lib
6263
LIBRARY DESTINATION lib
6364
RUNTIME DESTINATION bin)
65+
endif()

Diff for: Sources/TSCBasic/Path.swift

+16-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
See http://swift.org/LICENSE.txt for license information
88
See http://swift.org/CONTRIBUTORS.txt for Swift project authors
99
*/
10+
#if os(Windows)
11+
import Foundation
12+
#endif
1013

1114
/// Represents an absolute file system path, independently of what (or whether
1215
/// anything at all) exists at that path in the file system at any given time.
@@ -370,6 +373,10 @@ private struct PathImpl: Hashable {
370373
/// string consisting of just `.` if there is no directory part (which is
371374
/// the case if and only if there is no path separator).
372375
fileprivate var dirname: String {
376+
#if os(Windows)
377+
let dir = string.deletingLastPathComponent
378+
return dir == "" ? "." : dir
379+
#else
373380
// FIXME: This method seems too complicated; it should be simplified,
374381
// if possible, and certainly optimized (using UTF8View).
375382
// Find the last path separator.
@@ -385,6 +392,7 @@ private struct PathImpl: Hashable {
385392
// Otherwise, it's the string up to (but not including) the last path
386393
// separator.
387394
return String(string.prefix(upTo: idx))
395+
#endif
388396
}
389397

390398
fileprivate var basename: String {
@@ -561,11 +569,13 @@ private func mayNeedNormalization(absolute string: String) -> Bool {
561569
///
562570
/// The normalization rules are as described for the AbsolutePath struct.
563571
private func normalize(absolute string: String) -> String {
572+
#if os(Windows)
573+
return string.standardizingPath
574+
#else
564575
precondition(string.first == "/", "Failure normalizing \(string), absolute paths should start with '/'")
565576

566577
// At this point we expect to have a path separator as first character.
567578
assert(string.first == "/")
568-
569579
// Fast path.
570580
if !mayNeedNormalization(absolute: string) {
571581
return string
@@ -621,13 +631,17 @@ private func normalize(absolute string: String) -> String {
621631

622632
// Use the result as our stored string.
623633
return result
634+
#endif
624635
}
625636

626637
/// Private function that normalizes and returns a relative string. Asserts
627638
/// that `string` does not start with a path separator.
628639
///
629640
/// The normalization rules are as described for the AbsolutePath struct.
630641
private func normalize(relative string: String) -> String {
642+
#if os(Windows)
643+
return string.standardizingPath
644+
#else
631645
precondition(string.first != "/")
632646

633647
// FIXME: Here we should also keep track of whether anything actually has
@@ -688,4 +702,5 @@ private func normalize(relative string: String) -> String {
688702

689703
// If the result is empty, return `.`, otherwise we return it as a string.
690704
return result.isEmpty ? "." : result
705+
#endif
691706
}

Diff for: Sources/TSCLibc/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ set_target_properties(TSCLibc PROPERTIES
2121

2222
set_property(GLOBAL APPEND PROPERTY TSC_EXPORTS TSCLibc)
2323

24+
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
2425
install(TARGETS TSCLibc
2526
ARCHIVE DESTINATION lib
2627
LIBRARY DESTINATION lib
2728
RUNTIME DESTINATION bin)
29+
endif()

Diff for: Sources/TSCTestSupport/XCTAssertHelpers.swift

+5
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,8 @@ public func XCTAssertNoDiagnostics(_ engine: DiagnosticsEngine, file: StaticStri
8989
let diags = engine.diagnostics.map({ "- " + $0.description }).joined(separator: "\n")
9090
XCTFail("Found unexpected diagnostics: \n\(diags)", file: file, line: line)
9191
}
92+
93+
public func XCTAssertEqual<T:Equatable, U:Equatable> (_ lhs:(T,U), _ rhs:(T,U), file: StaticString = #file, line: UInt = #line) {
94+
XCTAssertEqual(lhs.0, rhs.0)
95+
XCTAssertEqual(lhs.1, rhs.1)
96+
}

Diff for: Sources/TSCUtility/Versioning.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public struct Versioning {
7474

7575
/// The current version of the package manager.
7676
public static let currentVersion = SwiftVersion(
77-
version: (5, 1, 0),
77+
version: (5, 2, 0),
7878
isDevelopment: false,
7979
buildIdentifier: getBuildIdentifier())
8080

0 commit comments

Comments
 (0)