Skip to content

Commit a404893

Browse files
committed
[xcodegen] Ignore -fdiagnostics-color
Avoid introducing ANSI escape sequences in the Xcode build log.
1 parent abc099c commit a404893

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,16 @@ struct ClangBuildArgsProvider {
5050
commandsToAdd[relFilePath] = (output, command.command.args)
5151
}
5252
for (path, (output, commandArgs)) in commandsToAdd {
53-
// Only include arguments that have known flags.
54-
args.insert(commandArgs.filter({ $0.flag != nil }), for: path)
53+
let commandArgs = commandArgs.filter { arg in
54+
// Only include arguments that have known flags.
55+
// Ignore `-fdiagnostics-color`, we don't want ANSI escape sequences
56+
// in Xcode build logs.
57+
guard let flag = arg.flag, flag != .fDiagnosticsColor else {
58+
return false
59+
}
60+
return true
61+
}
62+
args.insert(commandArgs, for: path)
5563
outputs[path] = output
5664
}
5765
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ extension Command.Flag {
128128
static let isystem = dash("isystem")
129129
static let isysroot = dash("isysroot")
130130
static let f = dash("f")
131+
static let fDiagnosticsColor = dash("fdiagnostics-color")
131132
static let U = dash("U")
132133
static let W = dash("W")
133134
static let std = dash("std")
@@ -211,6 +212,8 @@ extension KnownCommand {
211212
// FIXME: We ought to see if we can get away with preserving unknown flags.
212213
.init(.f, option: .unspaced),
213214

215+
.init(.fDiagnosticsColor),
216+
214217
// FIXME: Really we ought to map to Xcode's SDK
215218
.init(.isystem, option: .unspaced, .spaced),
216219
.init(.isysroot, option: .unspaced, .spaced),

0 commit comments

Comments
 (0)