[xcodegen] Ignore -fdiagnostics-color

Avoid introducing ANSI escape sequences in the Xcode build log.
This commit is contained in:
Hamish Knight
2025-05-07 13:48:45 +01:00
parent abc099cfa9
commit a404893f26
2 changed files with 13 additions and 2 deletions

View File

@@ -50,8 +50,16 @@ struct ClangBuildArgsProvider {
commandsToAdd[relFilePath] = (output, command.command.args)
}
for (path, (output, commandArgs)) in commandsToAdd {
// Only include arguments that have known flags.
args.insert(commandArgs.filter({ $0.flag != nil }), for: path)
let commandArgs = commandArgs.filter { arg in
// Only include arguments that have known flags.
// Ignore `-fdiagnostics-color`, we don't want ANSI escape sequences
// in Xcode build logs.
guard let flag = arg.flag, flag != .fDiagnosticsColor else {
return false
}
return true
}
args.insert(commandArgs, for: path)
outputs[path] = output
}
}

View File

@@ -128,6 +128,7 @@ extension Command.Flag {
static let isystem = dash("isystem")
static let isysroot = dash("isysroot")
static let f = dash("f")
static let fDiagnosticsColor = dash("fdiagnostics-color")
static let U = dash("U")
static let W = dash("W")
static let std = dash("std")
@@ -211,6 +212,8 @@ extension KnownCommand {
// FIXME: We ought to see if we can get away with preserving unknown flags.
.init(.f, option: .unspaced),
.init(.fDiagnosticsColor),
// FIXME: Really we ought to map to Xcode's SDK
.init(.isystem, option: .unspaced, .spaced),
.init(.isysroot, option: .unspaced, .spaced),