Skip to content

Commit 68f732b

Browse files
committed
Further cleanup of the parameter names as the changes started by the improvements to toolchain loading error messages propagate through the APIs.
1 parent 8cc68f0 commit 68f732b

File tree

5 files changed

+13
-16
lines changed

5 files changed

+13
-16
lines changed

Sources/Build/Command.compile(ClangModule).swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ struct ClangModuleBuildMetadata {
114114
}
115115

116116
extension Command {
117-
static func compile(clangModule module: ClangModule, externalModules: Set<Module>, configuration conf: Configuration, prefix: AbsolutePath, CC: String, otherArgs: [String]) throws -> [Command] {
117+
static func compile(clangModule module: ClangModule, externalModules: Set<Module>, configuration conf: Configuration, prefix: AbsolutePath, otherArgs: [String], compilerExec: AbsolutePath) throws -> [Command] {
118118

119119
let buildMeta = ClangModuleBuildMetadata(module: module, prefix: prefix, otherArgs: otherArgs)
120120

@@ -138,7 +138,7 @@ extension Command {
138138
let clang = ClangTool(desc: "Compile \(module.name) \(path.filename.asString)",
139139
inputs: buildMeta.inputs + [path.source.asString],
140140
outputs: [path.object.asString],
141-
args: [CC] + args,
141+
args: [compilerExec.asString] + args,
142142
deps: path.deps.asString)
143143

144144
let command = Command(node: path.object.asString, tool: clang)

Sources/Build/Command.compile(SwiftModule).swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import PackageLoading
1414
import Utility
1515

1616
extension Command {
17-
static func compile(swiftModule module: SwiftModule, configuration conf: Configuration, prefix: AbsolutePath, otherArgs: [String], SWIFT_EXEC: String) throws -> Command {
17+
static func compile(swiftModule module: SwiftModule, configuration conf: Configuration, prefix: AbsolutePath, otherArgs: [String], compilerExec: AbsolutePath) throws -> Command {
1818
let otherArgs = otherArgs + module.XccFlags(prefix) + (try module.pkgConfigSwiftcArgs()) + module.moduleCacheArgs(prefix: prefix)
1919
var args = ["-j\(SwiftcTool.numThreads)", "-D", "SWIFT_PACKAGE"]
2020

@@ -29,7 +29,7 @@ extension Command {
2929
args += ["-F", try platformFrameworksPath().asString]
3030
#endif
3131

32-
let tool = SwiftcTool(module: module, prefix: prefix, otherArgs: args + otherArgs, executable: SWIFT_EXEC, conf: conf)
32+
let tool = SwiftcTool(module: module, prefix: prefix, otherArgs: args + otherArgs, executable: compilerExec.asString, conf: conf)
3333
return Command(node: module.targetName, tool: tool)
3434
}
3535
}

Sources/Build/Command.link(ClangModule).swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import PackageLoading
1414
import Utility
1515

1616
extension Command {
17-
static func linkClangModule(_ product: Product, configuration conf: Configuration, prefix: AbsolutePath, otherArgs: [String], CC: String) throws -> Command {
17+
static func linkClangModule(_ product: Product, configuration conf: Configuration, prefix: AbsolutePath, otherArgs: [String], linkerExec: AbsolutePath) throws -> Command {
1818
precondition(product.containsOnlyClangModules)
1919

2020
let clangModules = product.modules.flatMap { $0 as? ClangModule }
@@ -54,7 +54,7 @@ extension Command {
5454
let shell = ShellTool(description: "Linking \(product.name)",
5555
inputs: objects.map{ $0.asString } + inputs,
5656
outputs: [productPath.asString, product.targetName],
57-
args: [CC] + args)
57+
args: [linkerExec.asString] + args)
5858

5959
return Command(node: product.targetName, tool: shell)
6060
}

Sources/Build/Command.link(SwiftModule).swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,21 @@ import Utility
1616
//FIXME messy :/
1717

1818
extension Command {
19-
static func linkSwiftModule(_ product: Product, configuration conf: Configuration, prefix: AbsolutePath, otherArgs: [String], SWIFT_EXEC: String) throws -> Command {
19+
static func linkSwiftModule(_ product: Product, configuration conf: Configuration, prefix: AbsolutePath, otherArgs: [String], linkerExec: AbsolutePath) throws -> Command {
2020

2121
// Get the unique set of all input modules.
2222
//
2323
// FIXME: This needs to handle C language targets.
2424
let buildables = OrderedSet(product.modules.flatMap{ [$0] + $0.recursiveDependencies }.flatMap{ $0 as? SwiftModule }).contents
2525

26-
var objects = buildables.flatMap { SwiftcTool(module: $0, prefix: prefix, otherArgs: [], executable: SWIFT_EXEC, conf: conf).objects }
26+
var objects = buildables.flatMap { SwiftcTool(module: $0, prefix: prefix, otherArgs: [], executable: linkerExec.asString, conf: conf).objects }
2727

2828
let outpath = prefix.appending(product.outname)
2929

3030
var args: [String]
3131
switch product.type {
3232
case .Library(.Dynamic), .Executable, .Test:
33-
args = [SWIFT_EXEC] + otherArgs
33+
args = [linkerExec.asString] + otherArgs
3434

3535
if conf == .debug {
3636
args += ["-g"]

Sources/Build/describe().swift

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,13 @@ public func describe(_ prefix: AbsolutePath, _ conf: Configuration, _ graph: Pac
3232
try makeDirectories(prefix)
3333
let swiftcArgs = flags.cCompilerFlags.flatMap{ ["-Xcc", $0] } + flags.swiftCompilerFlags + verbosity.ccArgs
3434

35-
let SWIFT_EXEC = toolchain.swiftCompiler
36-
let CC = getenv("CC") ?? "clang"
37-
3835
var commands = [Command]()
3936
var targets = Targets()
4037

4138
for module in graph.modules {
4239
switch module {
4340
case let module as SwiftModule:
44-
let compile = try Command.compile(swiftModule: module, configuration: conf, prefix: prefix, otherArgs: swiftcArgs + toolchain.swiftPlatformArgs, SWIFT_EXEC: SWIFT_EXEC.asString)
41+
let compile = try Command.compile(swiftModule: module, configuration: conf, prefix: prefix, otherArgs: swiftcArgs + toolchain.swiftPlatformArgs, compilerExec: toolchain.swiftCompiler)
4542
commands.append(compile)
4643
targets.append([compile], for: module)
4744

@@ -51,7 +48,7 @@ public func describe(_ prefix: AbsolutePath, _ conf: Configuration, _ graph: Pac
5148
if module.isTest { continue }
5249
#endif
5350
// FIXME: Find a way to eliminate `externalModules` from here.
54-
let compile = try Command.compile(clangModule: module, externalModules: graph.externalModules, configuration: conf, prefix: prefix, CC: CC, otherArgs: flags.cCompilerFlags + toolchain.clangPlatformArgs)
51+
let compile = try Command.compile(clangModule: module, externalModules: graph.externalModules, configuration: conf, prefix: prefix, otherArgs: flags.cCompilerFlags + toolchain.clangPlatformArgs, compilerExec: toolchain.clangCompiler)
5552
commands += compile
5653
targets.append(compile, for: module)
5754

@@ -74,9 +71,9 @@ public func describe(_ prefix: AbsolutePath, _ conf: Configuration, _ graph: Pac
7471
#endif
7572
let command: Command
7673
if product.containsOnlyClangModules {
77-
command = try Command.linkClangModule(product, configuration: conf, prefix: prefix, otherArgs: Xld, CC: CC)
74+
command = try Command.linkClangModule(product, configuration: conf, prefix: prefix, otherArgs: Xld, linkerExec: toolchain.clangCompiler)
7875
} else {
79-
command = try Command.linkSwiftModule(product, configuration: conf, prefix: prefix, otherArgs: Xld + swiftcArgs + toolchain.swiftPlatformArgs + rpathArgs, SWIFT_EXEC: SWIFT_EXEC.asString)
76+
command = try Command.linkSwiftModule(product, configuration: conf, prefix: prefix, otherArgs: Xld + swiftcArgs + toolchain.swiftPlatformArgs + rpathArgs, linkerExec: toolchain.swiftCompiler)
8077
}
8178

8279
commands.append(command)

0 commit comments

Comments
 (0)