in Sources/XCRemoteCache/Commands/Swiftc/SwiftcOrchestrator.swift [99:146]
func run() throws {
switch mode {
case .consumer(.available):
let compileStepResult = try swiftc.mockCompilation()
do {
if case .forceFallback = compileStepResult {
// last-time fallback (probably a new swift file was added to the target)
// we are responsible to call all gathered compilation steps in compilation history
let historyCommandsToCall = try invocationStorage.retrieveAll()
try callExternalInvocations(invocations: historyCommandsToCall)
fallbackToDefault(command: swiftcCommand)
} else {
// save the current compilation invocation to the history file
try invocationStorage.store(args: invocationArgs)
}
} catch {
// The critical section is protected by a lock. Some other process already called compilation history
// We only need to call our current step then
fallbackToDefault(command: swiftcCommand)
}
case .consumer:
fallbackToDefault(command: swiftcCommand)
case .producerFast:
let compileStepResult = try swiftc.mockCompilation()
if case .forceFallback = compileStepResult {
// cannot reuse cached artifact. Build it locally and upload to the server just as for the producer
fallthrough
}
case .producer:
var swiftcArgs = ProcessInfo().arguments
swiftcArgs = try producerFallbackCommandProcessors.reduce(swiftcArgs) { args, processor in
try processor.applyArgsRewrite(args)
}
try fallbackToDefaultAndWait(command: swiftcCommand, args: swiftcArgs)
if let objcHeaderOutput = objcHeaderOutput {
// move generated .h to the location where artifact creator expects it
try artifactBuilder.includeObjCHeaderToTheArtifact(arch: arch, headerURL: objcHeaderOutput)
}
if let moduleOutput = moduleOutput {
// move generated .swiftmodule to the location where artifact creator expects it
try artifactBuilder.includeModuleDefinitionsToTheArtifact(arch: arch, moduleURL: moduleOutput)
}
try producerFallbackCommandProcessors.forEach {
try $0.postCommandProcessing()
}
}
}