Skip to content

Commit

Permalink
Merge pull request #297 from davidungar/incremental-10-9b
Browse files Browse the repository at this point in the history
Add a `primaryInputs` field to `Job` which will be needed for incremental compilation.
  • Loading branch information
David Ungar committed Oct 10, 2020
2 parents 095937c + 9c66cc8 commit 5ae9bd8
Show file tree
Hide file tree
Showing 21 changed files with 43 additions and 13 deletions.
Expand Up @@ -187,6 +187,7 @@ public typealias ExternalBuildArtifacts = (ExternalTargetModulePathMap, ModuleIn
tool: .absolute(try toolchain.getToolPath(.swiftCompiler)),
commandLine: commandLine,
inputs: inputs,
primaryInputs: [],
outputs: outputs
)
}
Expand Down Expand Up @@ -232,6 +233,7 @@ public typealias ExternalBuildArtifacts = (ExternalTargetModulePathMap, ModuleIn
tool: .absolute(try toolchain.getToolPath(.swiftCompiler)),
commandLine: commandLine,
inputs: inputs,
primaryInputs: [],
outputs: outputs
)
}
Expand Down
Expand Up @@ -48,6 +48,7 @@ extension Driver {
commandLine: commandLine,
displayInputs: inputs,
inputs: inputs,
primaryInputs: [],
outputs: [TypedVirtualPath(file: .standardOutput, type: .jsonDependencies)],
supportsResponseFiles: true)
}
Expand Down Expand Up @@ -156,6 +157,7 @@ extension Driver {
commandLine: commandLine,
displayInputs: inputs,
inputs: inputs,
primaryInputs: [],
outputs: outputs,
supportsResponseFiles: true)
}
Expand Down
1 change: 1 addition & 0 deletions Sources/SwiftDriver/Jobs/AutolinkExtractJob.swift
Expand Up @@ -34,6 +34,7 @@ extension Driver {
tool: .absolute(try toolchain.getToolPath(.swiftAutolinkExtract)),
commandLine: commandLine,
inputs: inputs,
primaryInputs: [],
outputs: [.init(file: output, type: .autolink)],
supportsResponseFiles: true
)
Expand Down
1 change: 1 addition & 0 deletions Sources/SwiftDriver/Jobs/BackendJob.swift
Expand Up @@ -72,6 +72,7 @@ extension Driver {
commandLine: commandLine,
displayInputs: inputs,
inputs: inputs,
primaryInputs: [],
outputs: outputs,
supportsResponseFiles: true
)
Expand Down
1 change: 1 addition & 0 deletions Sources/SwiftDriver/Jobs/CompileJob.swift
Expand Up @@ -267,6 +267,7 @@ extension Driver {
commandLine: commandLine,
displayInputs: primaryInputs,
inputs: inputs,
primaryInputs: primaryInputs,
outputs: outputs,
supportsResponseFiles: true
)
Expand Down
1 change: 1 addition & 0 deletions Sources/SwiftDriver/Jobs/EmitModuleJob.swift
Expand Up @@ -75,6 +75,7 @@ extension Driver {
tool: .absolute(try toolchain.getToolPath(.swiftCompiler)),
commandLine: commandLine,
inputs: inputs,
primaryInputs: [],
outputs: outputs
)
}
Expand Down
1 change: 1 addition & 0 deletions Sources/SwiftDriver/Jobs/GenerateDSYMJob.swift
Expand Up @@ -29,6 +29,7 @@ extension Driver {
commandLine: commandLine,
displayInputs: [],
inputs: inputs,
primaryInputs: [],
outputs: [.init(file: outputPath, type: .dSYM)]
)
}
Expand Down
1 change: 1 addition & 0 deletions Sources/SwiftDriver/Jobs/GeneratePCHJob.swift
Expand Up @@ -68,6 +68,7 @@ extension Driver {
commandLine: commandLine,
displayInputs: [],
inputs: inputs,
primaryInputs: [],
outputs: outputs,
supportsResponseFiles: true
)
Expand Down
1 change: 1 addition & 0 deletions Sources/SwiftDriver/Jobs/GeneratePCMJob.swift
Expand Up @@ -59,6 +59,7 @@ extension Driver {
commandLine: commandLine,
displayInputs: [],
inputs: inputs,
primaryInputs: [],
outputs: outputs
)
}
Expand Down
1 change: 1 addition & 0 deletions Sources/SwiftDriver/Jobs/InterpretJob.swift
Expand Up @@ -46,6 +46,7 @@ extension Driver {
tool: .absolute(try toolchain.getToolPath(.swiftCompiler)),
commandLine: commandLine,
inputs: inputs,
primaryInputs: [],
outputs: [],
extraEnvironment: extraEnvironment,
requiresInPlaceExecution: true,
Expand Down
5 changes: 5 additions & 0 deletions Sources/SwiftDriver/Jobs/Job.swift
Expand Up @@ -70,6 +70,9 @@ public struct Job: Codable, Equatable, Hashable {
/// The list of inputs for this job.
public var inputs: [TypedVirtualPath]

/// The primary inputs for compile jobs
public var primaryInputs: [TypedVirtualPath]

/// The outputs produced by the job.
public var outputs: [TypedVirtualPath]

Expand All @@ -89,6 +92,7 @@ public struct Job: Codable, Equatable, Hashable {
commandLine: [ArgTemplate],
displayInputs: [TypedVirtualPath]? = nil,
inputs: [TypedVirtualPath],
primaryInputs: [TypedVirtualPath],
outputs: [TypedVirtualPath],
extraEnvironment: [String: String] = [:],
requiresInPlaceExecution: Bool = false,
Expand All @@ -100,6 +104,7 @@ public struct Job: Codable, Equatable, Hashable {
self.commandLine = commandLine
self.displayInputs = displayInputs ?? []
self.inputs = inputs
self.primaryInputs = primaryInputs
self.outputs = outputs
self.extraEnvironment = extraEnvironment
self.requiresInPlaceExecution = requiresInPlaceExecution
Expand Down
1 change: 1 addition & 0 deletions Sources/SwiftDriver/Jobs/LinkJob.swift
Expand Up @@ -58,6 +58,7 @@ extension Driver {
tool: .absolute(toolPath),
commandLine: commandLine,
inputs: inputs,
primaryInputs: [],
outputs: [.init(file: outputFile, type: .image)]
)
}
Expand Down
1 change: 1 addition & 0 deletions Sources/SwiftDriver/Jobs/MergeModuleJob.swift
Expand Up @@ -67,6 +67,7 @@ extension Driver {
tool: .absolute(try toolchain.getToolPath(.swiftCompiler)),
commandLine: commandLine,
inputs: inputs,
primaryInputs: [],
outputs: outputs,
supportsResponseFiles: true
)
Expand Down
1 change: 1 addition & 0 deletions Sources/SwiftDriver/Jobs/ModuleWrapJob.swift
Expand Up @@ -32,6 +32,7 @@ extension Driver {
tool: .absolute(try toolchain.getToolPath(.swiftCompiler)),
commandLine: commandLine,
inputs: [moduleInput],
primaryInputs: [],
outputs: [.init(file: outputPath, type: .object)],
supportsResponseFiles: true
)
Expand Down
2 changes: 2 additions & 0 deletions Sources/SwiftDriver/Jobs/Planning.swift
Expand Up @@ -472,6 +472,7 @@ extension Driver {
tool: .absolute(try toolchain.getToolPath(.swiftCompiler)),
commandLine: [.flag("--version")],
inputs: [],
primaryInputs: [],
outputs: [],
requiresInPlaceExecution: true)
}
Expand All @@ -487,6 +488,7 @@ extension Driver {
tool: .absolute(try toolchain.getToolPath(.swiftHelp)),
commandLine: commandLine,
inputs: [],
primaryInputs: [],
outputs: [],
requiresInPlaceExecution: true)
}
Expand Down
1 change: 1 addition & 0 deletions Sources/SwiftDriver/Jobs/PrintTargetInfoJob.swift
Expand Up @@ -165,6 +165,7 @@ extension Toolchain {
commandLine: commandLine,
displayInputs: [],
inputs: [],
primaryInputs: [],
outputs: [.init(file: .standardOutput, type: .jsonTargetInfo)],
requiresInPlaceExecution: requiresInPlaceExecution,
supportsResponseFiles: false
Expand Down
1 change: 1 addition & 0 deletions Sources/SwiftDriver/Jobs/ReplJob.swift
Expand Up @@ -29,6 +29,7 @@ extension Driver {
tool: .absolute(try toolchain.getToolPath(.lldb)),
commandLine: [Job.ArgTemplate.flag(lldbArg)],
inputs: inputs,
primaryInputs: [],
outputs: [],
requiresInPlaceExecution: true
)
Expand Down
1 change: 1 addition & 0 deletions Sources/SwiftDriver/Jobs/VerifyDebugInfoJob.swift
Expand Up @@ -27,6 +27,7 @@ extension Driver {
commandLine: commandLine,
displayInputs: [],
inputs: inputs,
primaryInputs: [],
outputs: []
)
}
Expand Down
1 change: 1 addition & 0 deletions Sources/SwiftDriver/Jobs/VerifyModuleInterfaceJob.swift
Expand Up @@ -34,6 +34,7 @@ extension Driver {
commandLine: commandLine,
displayInputs: [],
inputs: [interfaceInput],
primaryInputs: [],
outputs: [outputFile]
)
}
Expand Down
25 changes: 14 additions & 11 deletions Tests/SwiftDriverTests/JobExecutorTests.swift
Expand Up @@ -113,6 +113,11 @@ final class JobExecutorTests: XCTestCase {
.relative(RelativePath("main")): exec.pathString,
]

let inputs: [String: TypedVirtualPath] = [
"foo" : .init(file: .relative(RelativePath( "foo.swift")), type: .swift),
"main": .init(file: .relative(RelativePath("main.swift")), type: .swift)
]

let compileFoo = Job(
moduleName: "main",
kind: .compile,
Expand All @@ -121,19 +126,17 @@ final class JobExecutorTests: XCTestCase {
"-frontend",
"-c",
"-primary-file",
.path(.relative(RelativePath("foo.swift"))),
.path(.relative(RelativePath("main.swift"))),
.path(inputs[ "foo"]!.file),
.path(inputs["main"]!.file),
"-target", "x86_64-apple-darwin18.7.0",
"-enable-objc-interop",
"-sdk",
.path(.absolute(try toolchain.sdk.get())),
"-module-name", "main",
"-o", .path(.temporary(RelativePath("foo.o"))),
],
inputs: [
.init(file: .relative(RelativePath("foo.swift")), type: .swift),
.init(file: .relative(RelativePath("main.swift")), type: .swift),
],
inputs: Array(inputs.values),
primaryInputs: [inputs["foo"]!],
outputs: [.init(file: .temporary(RelativePath("foo.o")), type: .object)]
)

Expand All @@ -146,18 +149,16 @@ final class JobExecutorTests: XCTestCase {
"-c",
.path(.relative(RelativePath("foo.swift"))),
"-primary-file",
.path(.relative(RelativePath("main.swift"))),
.path(inputs["main"]!.file),
"-target", "x86_64-apple-darwin18.7.0",
"-enable-objc-interop",
"-sdk",
.path(.absolute(try toolchain.sdk.get())),
"-module-name", "main",
"-o", .path(.temporary(RelativePath("main.o"))),
],
inputs: [
.init(file: .relative(RelativePath("foo.swift")), type: .swift),
.init(file: .relative(RelativePath("main.swift")), type: .swift),
],
inputs: Array(inputs.values),
primaryInputs: [inputs["main"]!],
outputs: [.init(file: .temporary(RelativePath("main.o")), type: .object)]
)

Expand All @@ -182,6 +183,7 @@ final class JobExecutorTests: XCTestCase {
.init(file: .temporary(RelativePath("foo.o")), type: .object),
.init(file: .temporary(RelativePath("main.o")), type: .object),
],
primaryInputs: [],
outputs: [.init(file: .relative(RelativePath("main")), type: .image)]
)

Expand Down Expand Up @@ -213,6 +215,7 @@ final class JobExecutorTests: XCTestCase {
tool: .absolute(AbsolutePath("/usr/bin/swift")),
commandLine: [.flag("something")],
inputs: [],
primaryInputs: [],
outputs: [.init(file: .temporary(RelativePath("main")), type: .object)]
)

Expand Down
5 changes: 3 additions & 2 deletions Tests/SwiftDriverTests/ModuleDependencyGraphTests.swift
Expand Up @@ -1311,8 +1311,9 @@ extension Job {
kind: .compile,
tool: VirtualPath(path: ""),
commandLine: [],
inputs: [TypedVirtualPath(file: VirtualPath(path: dummyBaseName + ".swift" ), type: .swift )],
outputs: [TypedVirtualPath(file: VirtualPath(path: dummyBaseName + ".swiftdeps"), type: .swiftDeps)])
inputs: [TypedVirtualPath(file: VirtualPath(path: dummyBaseName + ".swift" ), type: .swift )],
primaryInputs: [TypedVirtualPath(file: VirtualPath(path: dummyBaseName + ".swift" ), type: .swift )],
outputs: [TypedVirtualPath(file: VirtualPath(path: dummyBaseName + ".swiftdeps"), type: .swiftDeps)])
}

}
Expand Down

0 comments on commit 5ae9bd8

Please sign in to comment.