Skip to content

Commit

Permalink
Sync with SwiftPM trunk
Browse files Browse the repository at this point in the history
  • Loading branch information
aciidgh committed Nov 6, 2019
1 parent 54a0b60 commit e8910f4
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Sources/TSCBasic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
17 changes: 16 additions & 1 deletion Sources/TSCBasic/Path.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -621,13 +631,17 @@ 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
/// that `string` does not start with a path separator.
///
/// 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
Expand Down Expand Up @@ -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
}
2 changes: 2 additions & 0 deletions Sources/TSCLibc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
5 changes: 5 additions & 0 deletions Sources/TSCTestSupport/XCTAssertHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<T:Equatable, U:Equatable> (_ lhs:(T,U), _ rhs:(T,U), file: StaticString = #file, line: UInt = #line) {
XCTAssertEqual(lhs.0, rhs.0)
XCTAssertEqual(lhs.1, rhs.1)
}
2 changes: 1 addition & 1 deletion Sources/TSCUtility/Versioning.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand Down

0 comments on commit e8910f4

Please sign in to comment.