From efdfc6bbcac307cab149759504ef4b37a22913a0 Mon Sep 17 00:00:00 2001 From: James Price Date: Wed, 4 Jan 2023 17:48:00 +0000 Subject: [PATCH] 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 Reviewed-by: Dan Sinclair Kokoro: Kokoro Commit-Queue: James Price --- src/tint/BUILD.gn | 4 ++-- src/tint/CMakeLists.txt | 2 +- src/tint/diagnostic/{printer_linux.cc => printer_posix.cc} | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) rename src/tint/diagnostic/{printer_linux.cc => printer_posix.cc} (94%) diff --git a/src/tint/BUILD.gn b/src/tint/BUILD.gn index d942b8688e..2167eaf8d3 100644 --- a/src/tint/BUILD.gn +++ b/src/tint/BUILD.gn @@ -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 { diff --git a/src/tint/CMakeLists.txt b/src/tint/CMakeLists.txt index 7988364f5c..b30227a7e1 100644 --- a/src/tint/CMakeLists.txt +++ b/src/tint/CMakeLists.txt @@ -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() diff --git a/src/tint/diagnostic/printer_linux.cc b/src/tint/diagnostic/printer_posix.cc similarity index 94% rename from src/tint/diagnostic/printer_linux.cc rename to src/tint/diagnostic/printer_posix.cc index 56d77b9853..b854640513 100644 --- a/src/tint/diagnostic/printer_linux.cc +++ b/src/tint/diagnostic/printer_posix.cc @@ -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::create(FILE* out, bool use_colors) { - return std::make_unique(out, use_colors); + return std::make_unique(out, use_colors); } } // namespace tint::diag