Skip to content

Commit d2f386b

Browse files
committed
* Do not invoke link.exe with invalid args, execution
with no arguments, will output the version string. * Use proper path seperator based on running host for environment variable seperator. * Check host arch to determine which subpath to check for visual studio installed binaries
1 parent f8e55fc commit d2f386b

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

Sources/SWBCore/Core.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ public final class Core: Sendable {
419419
}
420420
}
421421
if let additionalPlatformSearchPaths = getEnvironmentVariable("XCODE_EXTRA_PLATFORM_FOLDERS") {
422-
for searchPath in additionalPlatformSearchPaths.split(separator: ":") {
422+
for searchPath in additionalPlatformSearchPaths.split(separator: Path.pathEnvironmentSeparator) {
423423
searchPaths.append(Path(searchPath))
424424
}
425425
}

Sources/SWBCore/Specs/Tools/LinkerTools.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1553,7 +1553,7 @@ public final class LibtoolLinkerSpec : GenericLinkerSpec, SpecIdentifierType, @u
15531553
public func discoveredLinkerToolsInfo(_ producer: any CommandProducer, _ delegate: any CoreClientTargetDiagnosticProducingDelegate, at toolPath: Path) async -> (any DiscoveredCommandLineToolSpecInfo)? {
15541554
do {
15551555
do {
1556-
let commandLine = [toolPath.str, producer.hostOperatingSystem == .windows ? "/VERSION" : "-version_details"]
1556+
let commandLine = [toolPath.str] + (producer.hostOperatingSystem == .windows ? [] : ["-version_details"])
15571557
return try await producer.discoveredCommandLineToolSpecInfo(delegate, nil, commandLine, { executionResult in
15581558
let gnuLD = [
15591559
#/GNU ld version (?<version>[\d.]+)-.*/#,
@@ -1569,7 +1569,7 @@ public func discoveredLinkerToolsInfo(_ producer: any CommandProducer, _ delegat
15691569
if let match = try goLD.compactMap({ try $0.firstMatch(in: String(decoding: executionResult.stdout, as: UTF8.self)) }).first {
15701570
return DiscoveredLdLinkerToolSpecInfo(linker: .gold, toolPath: toolPath, toolVersion: try Version(String(match.output.version)), architectures: Set())
15711571
}
1572-
// link.exe has no option to simply dump the version, but if you pass an invalid argument, the program will dump a header that contains the version.
1572+
// link.exe has no option to simply dump the version, running, the program will no arguments will dump a header that contains the version.
15731573
let linkExe = [
15741574
#/Microsoft \(R\) Incremental Linker Version (?<version>[\d.]+)/#
15751575
]

Sources/SWBTestSupport/TaskPlanningTestSupport.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ open class MockTestTaskPlanningClientDelegate: TaskPlanningClientDelegate, @unch
210210
return .deferred
211211
case "ld" where args == ["-version_details"]:
212212
return .deferred
213-
case "link" where args == ["/VERSION"]:
213+
case "link":
214214
return .deferred
215215
case "libtool" where args == ["-V"] || args == ["--version"]:
216216
return .deferred

Sources/SWBWindowsPlatform/Plugin.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,11 @@ struct WindowsPlatformExtension: PlatformInfoExtension {
5959
guard let dir = try? await findLatestInstallDirectory(fs: fs) else {
6060
return []
6161
}
62-
return [dir.join("bin/Hostarm64/arm64"), dir.join("bin/Hostx64/x64") ]
62+
if Architecture.hostStringValue == "aarch64" {
63+
return [dir.join("bin/Hostarm64/arm64")]
64+
} else {
65+
return [dir.join("bin/Hostx64/x64")]
66+
}
6367
}
6468
}
6569

0 commit comments

Comments
 (0)