Skip to content

Commit 0cff858

Browse files
authored
Rename getToolchain() to getDestinationToolchain() (#5850)
Simple rename for clarity since we `getHostToolchain()`.
1 parent c1bfac6 commit 0cff858

File tree

6 files changed

+18
-18
lines changed

6 files changed

+18
-18
lines changed

Sources/Commands/SwiftPackageTool.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ extension SwiftPackageTool {
398398
var regenerateBaseline: Bool = false
399399

400400
func run(_ swiftTool: SwiftTool) throws {
401-
let apiDigesterPath = try swiftTool.getToolchain().getSwiftAPIDigester()
401+
let apiDigesterPath = try swiftTool.getDestinationToolchain().getSwiftAPIDigester()
402402
let apiDigesterTool = SwiftAPIDigester(fileSystem: swiftTool.fileSystem, tool: apiDigesterPath)
403403

404404
let packageRoot = try globalOptions.locations.packageDirectory ?? swiftTool.getPackageRoot()
@@ -600,7 +600,7 @@ extension SwiftPackageTool {
600600
// Configure the symbol graph extractor.
601601
let symbolGraphExtractor = try SymbolGraphExtract(
602602
fileSystem: swiftTool.fileSystem,
603-
tool: swiftTool.getToolchain().getSymbolGraphExtract(),
603+
tool: swiftTool.getDestinationToolchain().getSymbolGraphExtract(),
604604
skipSynthesizedMembers: skipSynthesizedMembers,
605605
minimumAccessLevel: minimumAccessLevel,
606606
skipInheritedDocs: skipInheritedDocs,
@@ -1077,7 +1077,7 @@ extension SwiftPackageTool {
10771077
let readOnlyDirectories = writableDirectories.contains{ package.path.isDescendantOfOrEqual(to: $0) } ? [] : [package.path]
10781078

10791079
// Use the directory containing the compiler as an additional search directory, and add the $PATH.
1080-
let toolSearchDirs = [try swiftTool.getToolchain().swiftCompilerPath.parentDirectory]
1080+
let toolSearchDirs = [try swiftTool.getDestinationToolchain().swiftCompilerPath.parentDirectory]
10811081
+ getEnvSearchPaths(pathString: ProcessEnv.path, currentWorkingDirectory: .none)
10821082

10831083
// Build or bring up-to-date any executable host-side tools on which this plugin depends. Add them and any binary dependencies to the tool-names-to-path map.
@@ -1272,7 +1272,7 @@ final class PluginDelegate: PluginInvocationDelegate {
12721272

12731273
func performTestsForPlugin(subset: PluginInvocationTestSubset, parameters: PluginInvocationTestParameters) throws -> PluginInvocationTestResult {
12741274
// Build the tests. Ideally we should only build those that match the subset, but we don't have a way to know which ones they are until we've built them and can examine the binaries.
1275-
let toolchain = try swiftTool.getToolchain()
1275+
let toolchain = try swiftTool.getDestinationToolchain()
12761276
var buildParameters = try swiftTool.buildParameters()
12771277
buildParameters.enableTestability = true
12781278
buildParameters.enableCodeCoverage = parameters.enableCodeCoverage
@@ -1418,7 +1418,7 @@ final class PluginDelegate: PluginInvocationDelegate {
14181418
// Configure the symbol graph extractor.
14191419
var symbolGraphExtractor = try SymbolGraphExtract(
14201420
fileSystem: swiftTool.fileSystem,
1421-
tool: swiftTool.getToolchain().getSymbolGraphExtract()
1421+
tool: swiftTool.getDestinationToolchain().getSymbolGraphExtract()
14221422
)
14231423
symbolGraphExtractor.skipSynthesizedMembers = !options.includeSynthesized
14241424
switch options.minimumAccessLevel {

Sources/Commands/SwiftRunTool.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public struct SwiftRunTool: SwiftCommand {
140140
print("Launching Swift REPL with arguments: \(arguments.joined(separator: " "))")
141141
try self.run(
142142
fileSystem: swiftTool.fileSystem,
143-
executablePath: swiftTool.getToolchain().swiftInterpreterPath,
143+
executablePath: swiftTool.getDestinationToolchain().swiftInterpreterPath,
144144
originalWorkingDirectory: swiftTool.originalWorkingDirectory,
145145
arguments: arguments
146146
)
@@ -164,7 +164,7 @@ public struct SwiftRunTool: SwiftCommand {
164164
}
165165

166166
let pathRelativeToWorkingDirectory = executablePath.relative(to: swiftTool.originalWorkingDirectory)
167-
let lldbPath = try swiftTool.getToolchain().getLLDB()
167+
let lldbPath = try swiftTool.getDestinationToolchain().getLLDB()
168168
try exec(path: lldbPath.pathString, args: ["--", pathRelativeToWorkingDirectory.pathString] + options.arguments)
169169
} catch let error as RunError {
170170
swiftTool.observabilityScope.emit(error)
@@ -176,7 +176,7 @@ public struct SwiftRunTool: SwiftCommand {
176176
if let executable = options.executable, isValidSwiftFilePath(fileSystem: swiftTool.fileSystem, path: executable) {
177177
swiftTool.observabilityScope.emit(.runFileDeprecation)
178178
// Redirect execution to the toolchain's swift executable.
179-
let swiftInterpreterPath = try swiftTool.getToolchain().swiftInterpreterPath
179+
let swiftInterpreterPath = try swiftTool.getDestinationToolchain().swiftInterpreterPath
180180
// Prepend the script to interpret to the arguments.
181181
let arguments = [executable] + options.arguments
182182
try self.run(

Sources/Commands/SwiftTestTool.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public struct SwiftTestTool: SwiftCommand {
165165
try self.validateArguments(observabilityScope: swiftTool.observabilityScope)
166166

167167
// validate XCTest available on darwin based systems
168-
let toolchain = try swiftTool.getToolchain()
168+
let toolchain = try swiftTool.getDestinationToolchain()
169169
if toolchain.triple.isDarwin() && toolchain.xctestPath == nil {
170170
throw TestError.xctestNotAvailable
171171
}
@@ -183,7 +183,7 @@ public struct SwiftTestTool: SwiftCommand {
183183
let command = try GenerateLinuxMain.parse()
184184
try command.run(swiftTool)
185185
} else if !self.options.shouldRunInParallel {
186-
let toolchain = try swiftTool.getToolchain()
186+
let toolchain = try swiftTool.getDestinationToolchain()
187187
let testProducts = try buildTestsIfNeeded(swiftTool: swiftTool)
188188
let buildParameters = try swiftTool.buildParametersForTest(options: self.options)
189189

@@ -259,7 +259,7 @@ public struct SwiftTestTool: SwiftCommand {
259259
}
260260

261261
} else {
262-
let toolchain = try swiftTool.getToolchain()
262+
let toolchain = try swiftTool.getDestinationToolchain()
263263
let testProducts = try buildTestsIfNeeded(swiftTool: swiftTool)
264264
let testSuites = try TestingSupport.getTestSuites(
265265
in: testProducts,
@@ -351,7 +351,7 @@ public struct SwiftTestTool: SwiftCommand {
351351
/// Merges all profraw profiles in codecoverage directory into default.profdata file.
352352
private func mergeCodeCovRawDataFiles(swiftTool: SwiftTool) throws {
353353
// Get the llvm-prof tool.
354-
let llvmProf = try swiftTool.getToolchain().getLLVMProf()
354+
let llvmProf = try swiftTool.getDestinationToolchain().getLLVMProf()
355355

356356
// Get the profraw files.
357357
let buildParameters = try swiftTool.buildParametersForTest(options: self.options)
@@ -373,7 +373,7 @@ public struct SwiftTestTool: SwiftCommand {
373373
/// Exports profdata as a JSON file.
374374
private func exportCodeCovAsJSON(to path: AbsolutePath, testBinary: AbsolutePath, swiftTool: SwiftTool) throws {
375375
// Export using the llvm-cov tool.
376-
let llvmCov = try swiftTool.getToolchain().getLLVMCov()
376+
let llvmCov = try swiftTool.getDestinationToolchain().getLLVMCov()
377377
let buildParameters = try swiftTool.buildParametersForTest(options: self.options)
378378
let args = [
379379
llvmCov.pathString,

Sources/Commands/SwiftTool.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ public class SwiftTool {
666666
}
667667

668668
/// Returns the user toolchain to compile the actual product.
669-
func getToolchain() throws -> UserToolchain {
669+
func getDestinationToolchain() throws -> UserToolchain {
670670
return try _destinationToolchain.get()
671671
}
672672

@@ -787,7 +787,7 @@ public class SwiftTool {
787787

788788
private lazy var _buildParameters: Result<BuildParameters, Swift.Error> = {
789789
return Result(catching: {
790-
let toolchain = try self.getToolchain()
790+
let toolchain = try self.getDestinationToolchain()
791791
let triple = toolchain.triple
792792

793793
// Use "apple" as the subdirectory because in theory Xcode build system

Sources/Commands/Utilities/TestingSupport.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ enum TestingSupport {
7575
let data: String = try withTemporaryFile { tempFile in
7676
let args = [try Self.xctestHelperPath(swiftTool: swiftTool).pathString, path.pathString, tempFile.path.pathString]
7777
var env = try Self.constructTestEnvironment(
78-
toolchain: try swiftTool.getToolchain(),
78+
toolchain: try swiftTool.getDestinationToolchain(),
7979
buildParameters: swiftTool.buildParametersForTest(
8080
enableCodeCoverage: enableCodeCoverage
8181
),
@@ -94,7 +94,7 @@ enum TestingSupport {
9494
}
9595
#else
9696
let env = try Self.constructTestEnvironment(
97-
toolchain: try swiftTool.getToolchain(),
97+
toolchain: try swiftTool.getDestinationToolchain(),
9898
buildParameters: swiftTool.buildParametersForTest(
9999
enableCodeCoverage: enableCodeCoverage
100100
),

Tests/CommandsTests/PackageToolTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ final class PackageToolTests: CommandsTestCase {
480480
// Returns symbol graph with or without pretty printing.
481481
private func symbolGraph(atPath path: AbsolutePath, withPrettyPrinting: Bool, file: StaticString = #file, line: UInt = #line) throws -> Data? {
482482
let tool = try SwiftTool(options: GlobalOptions.parse(["--package-path", path.pathString]))
483-
let symbolGraphExtractorPath = try tool.getToolchain().getSymbolGraphExtract()
483+
let symbolGraphExtractorPath = try tool.getDestinationToolchain().getSymbolGraphExtract()
484484

485485
let arguments = withPrettyPrinting ? ["dump-symbol-graph", "--pretty-print"] : ["dump-symbol-graph"]
486486

0 commit comments

Comments
 (0)