Skip to content

Commit 3fb2393

Browse files
Dependencies: handle empty clang trace
1 parent c9383cc commit 3fb2393

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Sources/SWBTaskExecution/TaskActions/ClangCompileTaskAction.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,16 @@ public final class ClangCompileTaskAction: TaskAction, BuildValueValidatingTaskA
484484
) throws {
485485
let payload: DependencyValidationInfo.Payload
486486
if let traceFilePath {
487-
let traceData = try JSONDecoder().decode(Array<TraceData>.self, from: Data(fileSystem.read(traceFilePath)))
487+
let traceFileContent = try fileSystem.read(traceFilePath)
488+
489+
let traceData: Array<TraceData>
490+
// clang will emit an empty file instead of an empty array when there's nothing to trace
491+
if traceFileContent.isEmpty {
492+
traceData = []
493+
} else {
494+
traceData = try JSONDecoder().decode(Array<TraceData>.self, from: Data(traceFileContent))
495+
}
496+
488497
var allFiles = Set<Path>()
489498
traceData.forEach { allFiles.formUnion(Set($0.includes)) }
490499

0 commit comments

Comments
 (0)