Skip to content

Commit 43be545

Browse files
committed
[xcodegen] Allow output to be missing in compile_commands.json
This may not always be present for CI builds.
1 parent a9efa84 commit 43be545

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

utils/swift-xcodegen/Sources/SwiftXcodeGen/BuildArgs/ClangBuildArgsProvider.swift

+4-3
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,17 @@ struct ClangBuildArgsProvider {
3434
// Gather the candidates for each file to get build arguments for. We may
3535
// have multiple outputs, in which case, pick the first one that exists.
3636
var commandsToAdd: [RelativePath:
37-
(output: AbsolutePath, args: [Command.Argument])] = [:]
37+
(output: AbsolutePath?, args: [Command.Argument])] = [:]
3838
for command in parsed {
3939
guard command.command.executable.knownCommand == .clang,
4040
let relFilePath = command.file.removingPrefix(repoPath)
4141
else {
4242
continue
4343
}
44-
let output = command.directory.appending(command.output)
44+
let output = command.output.map { command.directory.appending($0) }
4545
if let existing = commandsToAdd[relFilePath],
46-
existing.output.exists || !output.exists {
46+
let existingOutput = existing.output,
47+
output == nil || existingOutput.exists || !output!.exists {
4748
continue
4849
}
4950
commandsToAdd[relFilePath] = (output, command.command.args)

utils/swift-xcodegen/Sources/SwiftXcodeGen/Command/CompileCommands.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ extension CompileCommands {
2727
struct Element: Decodable {
2828
var directory: AbsolutePath
2929
var file: AbsolutePath
30-
var output: RelativePath
30+
var output: RelativePath?
3131
var command: Command
3232
}
3333
}

validation-test/BuildSystem/swift-xcodegen.test

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
# REQUIRES: standalone_build
99
# REQUIRES: target-same-as-host
1010

11-
# REQUIRES: issue_77407
12-
1311
# First copy swift-xcodegen to the temporary location
1412
# so we don't touch the user's build, and make sure
1513
# we're doing a clean build.

0 commit comments

Comments
 (0)