Skip to content

Commit 4d9bde1

Browse files
committed
Allow SwiftCompilerMessages with no outputs
Swift frontend jobs are not required to have outputs. When they don’t, there is no “output” field in the driver’s JSON. SwiftPM previously assumed an “output” field must be present; this commit disabuses it of that notion.
1 parent 9f06667 commit 4d9bde1

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

Sources/Build/SwiftCompilerOutputParser.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ public struct SwiftCompilerMessage {
2828
public struct BeganInfo {
2929
public let pid: Int
3030
public let inputs: [String]
31-
public let outputs: [Output]
31+
public let outputs: [Output]?
3232
public let commandExecutable: String
3333
public let commandArguments: [String]
3434

3535
public init(
3636
pid: Int,
3737
inputs: [String],
38-
outputs: [Output],
38+
outputs: [Output]?,
3939
commandExecutable: String,
4040
commandArguments: [String]
4141
) {
@@ -49,7 +49,7 @@ public struct SwiftCompilerMessage {
4949

5050
public struct SkippedInfo {
5151
public let inputs: [String]
52-
public let outputs: [Output]
52+
public let outputs: [Output]?
5353

5454
public init(inputs: [String], outputs: [SwiftCompilerMessage.Kind.Output]) {
5555
self.inputs = inputs

Tests/BuildTests/SwiftCompilerOutputParserTests.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,17 @@ class SwiftCompilerOutputParserTests: XCTestCase {
5757
],
5858
"pid": 58776
5959
}
60+
250
61+
{
62+
"kind": "began",
63+
"name": "verify-module-interface",
64+
"inputs": [
65+
"main.swiftinterface"
66+
],
67+
"pid": 31337,
68+
"command_executable": "swift",
69+
"command_arguments" : ["-frontend", "-typecheck-module-from-interface", "main.swiftinterface"]
70+
}
6071
299
6172
{
6273
"kind": "began",
@@ -108,6 +119,14 @@ class SwiftCompilerOutputParserTests: XCTestCase {
108119
outputs: [.init(
109120
type: "object",
110121
path: "/var/folders/yc/rgflx8m11p5d71k1ydy0l_pr0000gn/T/test2-77d991.o")]))),
122+
SwiftCompilerMessage(
123+
name: "verify-module-interface",
124+
kind: .began(.init(
125+
pid: 31337,
126+
inputs: ["main.swiftinterface"],
127+
outputs: nil,
128+
commandExecutable: "swift",
129+
commandArguments: ["-frontend", "-typecheck-module-from-interface", "main.swiftinterface"]))),
111130
SwiftCompilerMessage(
112131
name: "link",
113132
kind: .began(.init(

0 commit comments

Comments
 (0)