tint/gn: Use Unix diagnostic printer on macOS

Renames PrinterLinux to PrinterUnix and enables it for macOS in the GN
build. This allows the Tint EXE to produce colorized/emboldened
diagnostic messages on macOS.

We already do this in the CMake build, so this makes GN match.

Change-Id: I35a0d53de44c793870a5a050fdd14148aaf3d763
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116300
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
This commit is contained in:
James Price 2023-01-04 17:48:00 +00:00 committed by Dawn LUCI CQ
parent cf1f4658ae
commit efdfc6bbca
3 changed files with 6 additions and 6 deletions

View File

@ -628,8 +628,8 @@ libtint_source_set("libtint_core_all_src") {
"writer/writer.h",
]
if (is_linux) {
sources += [ "diagnostic/printer_linux.cc" ]
if (is_linux || is_mac) {
sources += [ "diagnostic/printer_posix.cc" ]
} else if (is_win) {
sources += [ "diagnostic/printer_windows.cc" ]
} else {

View File

@ -572,7 +572,7 @@ tint_generated(sem/parameter_usage)
tint_generated(type/short_name BENCH TEST)
if(UNIX)
list(APPEND TINT_LIB_SRCS diagnostic/printer_linux.cc)
list(APPEND TINT_LIB_SRCS diagnostic/printer_posix.cc)
elseif(WIN32)
list(APPEND TINT_LIB_SRCS diagnostic/printer_windows.cc)
else()

View File

@ -42,9 +42,9 @@ bool supports_colors(FILE* f) {
return true;
}
class PrinterLinux : public Printer {
class PrinterPosix : public Printer {
public:
PrinterLinux(FILE* f, bool colors) : file(f), use_colors(colors && supports_colors(f)) {}
PrinterPosix(FILE* f, bool colors) : file(f), use_colors(colors && supports_colors(f)) {}
void write(const std::string& str, const Style& style) override {
write_color(style.color, style.bold);
@ -91,7 +91,7 @@ class PrinterLinux : public Printer {
} // namespace
std::unique_ptr<Printer> Printer::create(FILE* out, bool use_colors) {
return std::make_unique<PrinterLinux>(out, use_colors);
return std::make_unique<PrinterPosix>(out, use_colors);
}
} // namespace tint::diag