in Sources/SwiftDriver/Jobs/Planning.swift [704:751]
/*private*/ mutating func planPossiblyIncrementalBuild() throws
-> ([Job], IncrementalCompilationState?) {
if let job = try immediateForwardingJob() {
return ([job], nil)
}
// The REPL doesn't require input files, but all other modes do.
guard !inputFiles.isEmpty || compilerMode == .repl || compilerMode == .intro else {
if parsedOptions.hasArgument(.v) {
// `swiftc -v` is allowed and prints version information.
return ([], nil)
}
throw Error.noInputFiles
}
// Plan the build.
switch compilerMode {
case .repl:
if !inputFiles.isEmpty {
throw PlanningError.replReceivedInput
}
return ([try replJob()], nil)
case .immediate:
var jobs: [Job] = []
try addPrecompileModuleDependenciesJobs(addJob: { jobs.append($0) })
jobs.append(try interpretJob(inputs: inputFiles))
return (jobs, nil)
case .standardCompile, .batchCompile, .singleCompile:
return try planStandardCompile()
case .compilePCM:
if inputFiles.count != 1 {
throw PlanningError.emitPCMWrongInputFiles
}
return ([try generateEmitPCMJob(input: inputFiles.first!)], nil)
case .dumpPCM:
if inputFiles.count != 1 {
throw PlanningError.dumpPCMWrongInputFiles
}
return ([try generateDumpPCMJob(input: inputFiles.first!)], nil)
case .intro:
return (try helpIntroJobs(), nil)
}
}