84 lines
3.6 KiB
Diff
84 lines
3.6 KiB
Diff
diff --git a/swift-tools-support-core/Sources/TSCUtility/Triple.swift b/swift-tools-support-core/Sources/TSCUtility/Triple.swift
|
|
index 449a21f..87e70b5 100644
|
|
--- a/swift-tools-support-core/Sources/TSCUtility/Triple.swift
|
|
+++ b/swift-tools-support-core/Sources/TSCUtility/Triple.swift
|
|
@@ -27,6 +27,8 @@ public struct Triple: Encodable, Equatable {
|
|
public let vendor: Vendor
|
|
public let os: OS
|
|
public let abi: ABI
|
|
+ public let osVersion: String?
|
|
+ public let abiVersion: String?
|
|
|
|
public enum Error: Swift.Error {
|
|
case badFormat
|
|
@@ -83,13 +85,18 @@ public struct Triple: Encodable, Equatable {
|
|
throw Error.unknownOS
|
|
}
|
|
|
|
+ let osVersion = Triple.parseVersion(components[2])
|
|
+
|
|
let abi = components.count > 3 ? Triple.parseABI(components[3]) : nil
|
|
+ let abiVersion = components.count > 3 ? Triple.parseVersion(components[3]) : nil
|
|
|
|
self.tripleString = string
|
|
self.arch = arch
|
|
self.vendor = vendor
|
|
self.os = os
|
|
+ self.osVersion = osVersion
|
|
self.abi = abi ?? .unknown
|
|
+ self.abiVersion = abiVersion
|
|
}
|
|
|
|
fileprivate static func parseOS(_ string: String) -> OS? {
|
|
@@ -100,6 +107,15 @@ public struct Triple: Encodable, Equatable {
|
|
return nil
|
|
}
|
|
|
|
+ fileprivate static func parseVersion(_ string: String) -> String? {
|
|
+ let candidate = String(string.drop(while: { $0.isLetter }))
|
|
+ if candidate != string && !candidate.isEmpty {
|
|
+ return candidate
|
|
+ }
|
|
+
|
|
+ return nil
|
|
+ }
|
|
+
|
|
fileprivate static func parseABI(_ string: String) -> ABI? {
|
|
if string.hasPrefix(ABI.android.rawValue) {
|
|
return ABI.android
|
|
@@ -132,18 +148,18 @@ public struct Triple: Encodable, Equatable {
|
|
/// This is currently meant for Apple platforms only.
|
|
public func tripleString(forPlatformVersion version: String) -> String {
|
|
precondition(isDarwin())
|
|
- return self.tripleString + version
|
|
+ return String(self.tripleString.dropLast(self.osVersion?.count ?? 0)) + version
|
|
}
|
|
|
|
public static let macOS = try! Triple("x86_64-apple-macosx")
|
|
|
|
- /// Determine the host triple using the Swift compiler.
|
|
+ /// Determine the versioned host triple using the Swift compiler.
|
|
public static func getHostTriple(usingSwiftCompiler swiftCompiler: AbsolutePath) -> Triple {
|
|
do {
|
|
let result = try Process.popen(args: swiftCompiler.pathString, "-print-target-info")
|
|
let output = try result.utf8Output().spm_chomp()
|
|
let targetInfo = try JSON(string: output)
|
|
- let tripleString: String = try targetInfo.get("target").get("unversionedTriple")
|
|
+ let tripleString: String = try targetInfo.get("target").get("triple")
|
|
return try Triple(tripleString)
|
|
} catch {
|
|
// FIXME: Remove the macOS special-casing once the latest version of Xcode comes with
|
|
diff --git a/swiftpm/Utilities/bootstrap b/swiftpm/Utilities/bootstrap
|
|
index 6ae084e9..2f3f99e0 100755
|
|
--- a/swiftpm/Utilities/bootstrap
|
|
+++ b/swiftpm/Utilities/bootstrap
|
|
@@ -289,7 +289,7 @@ def get_build_target(args, cross_compile=False):
|
|
target_info_json = subprocess.check_output(command,
|
|
stderr=subprocess.PIPE, universal_newlines=True).strip()
|
|
args.target_info = json.loads(target_info_json)
|
|
- return args.target_info["target"]["unversionedTriple"]
|
|
+ return args.target_info["target"]["triple"]
|
|
except Exception as e:
|
|
# Temporary fallback for Darwin.
|
|
if platform.system() == 'Darwin':
|