in Sources/SwiftDriver/Jobs/PrintTargetInfoJob.swift [122:175]
func printTargetInfoJob(target: Triple?,
targetVariant: Triple?,
sdkPath: VirtualPath? = nil,
resourceDirPath: VirtualPath? = nil,
runtimeCompatibilityVersion: String? = nil,
requiresInPlaceExecution: Bool = false,
useStaticResourceDir: Bool = false,
swiftCompilerPrefixArgs: [String]) throws -> Job {
var commandLine: [Job.ArgTemplate] = swiftCompilerPrefixArgs.map { Job.ArgTemplate.flag($0) }
commandLine.append(contentsOf: [.flag("-frontend"),
.flag("-print-target-info")])
// If we were given a target, include it. Otherwise, let the frontend
// tell us the host target.
if let target = target {
commandLine += [.flag("-target"), .flag(target.triple)]
}
// If there is a target variant, include that too.
if let targetVariant = targetVariant {
commandLine += [.flag("-target-variant"), .flag(targetVariant.triple)]
}
if let sdkPath = sdkPath {
commandLine += [.flag("-sdk"), .path(sdkPath)]
}
if let resourceDirPath = resourceDirPath {
commandLine += [.flag("-resource-dir"), .path(resourceDirPath)]
}
if let runtimeCompatibilityVersion = runtimeCompatibilityVersion {
commandLine += [
.flag("-runtime-compatibility-version"),
.flag(runtimeCompatibilityVersion)
]
}
if useStaticResourceDir {
commandLine += [.flag("-use-static-resource-dir")]
}
return Job(
moduleName: "",
kind: .printTargetInfo,
tool: .absolute(try getToolPath(.swiftCompiler)),
commandLine: commandLine,
displayInputs: [],
inputs: [],
primaryInputs: [],
outputs: [.init(file: .standardOutput, type: .jsonTargetInfo)],
requiresInPlaceExecution: requiresInPlaceExecution,
supportsResponseFiles: false
)
}