Skia config for Windows without clang

Work around Windows build errors when Skia is enabled and clang is not
used.

This is required to be resolved before the choice of Skia vs. AGG
renderer can be selected at runtime.

Bug: pdfium:11
Change-Id: Ic3f240ba35e47c8ede1ce7732176ee901865e5ee
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/91910
Reviewed-by: Nigi <nigi@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Alan Screen <awscreen@chromium.org>
diff --git a/skia/config/SkUserConfig.h b/skia/config/SkUserConfig.h
index 679a19c..aa5f308 100644
--- a/skia/config/SkUserConfig.h
+++ b/skia/config/SkUserConfig.h
@@ -135,11 +135,17 @@
 #define GR_MAX_OFFSCREEN_AA_DIM 512
 
 // Log the file and line number for assertions.
+#if defined(SK_BUILD_FOR_WIN) && !defined(__clang__)
+// String formatting with this toolchain not supported.
+#define SkDebugf(...) SkDebugf_FileLineOnly(__FILE__, __LINE__)
+SK_API void SkDebugf_FileLineOnly(const char* file, int line);
+#else
 #define SkDebugf(...) SkDebugf_FileLine(__FILE__, __LINE__, __VA_ARGS__)
 SK_API void SkDebugf_FileLine(const char* file,
                               int line,
                               const char* format,
                               ...);
+#endif
 
 #if !defined(ANDROID)  // On Android, we use the skia default settings.
 #define SK_A32_SHIFT 24
@@ -249,6 +255,15 @@
 
 #define SK_DISABLE_TILE_IMAGE_FILTER_OPTIMIZATION
 
+#if defined(SK_BUILD_FOR_WIN) && !defined(__clang__)
+#define SK_ABORT(format, ...) \
+  SkAbort_FileLine(__FILE__, __LINE__, format, ##__VA_ARGS__)
+[[noreturn]] SK_API void SkAbort_FileLine(const char* file,
+                                          int line,
+                                          const char* format,
+                                          ...);
+#endif
+
 // ===== End Chrome-specific definitions =====
 
 #endif  // SKIA_CONFIG_SKUSERCONFIG_H_
diff --git a/skia/ext/google_logging.cc b/skia/ext/google_logging.cc
index 10d7674..87b9109 100644
--- a/skia/ext/google_logging.cc
+++ b/skia/ext/google_logging.cc
@@ -11,6 +11,10 @@
 
 #include "third_party/skia/include/core/SkTypes.h"
 
+#if defined(SK_BUILD_FOR_WIN) && !defined(__clang__)
+#include <stdlib.h>
+#endif
+
 void SkDebugf_FileLine(const char* file, int line, const char* format, ...) {
   va_list ap;
   va_start(ap, format);
@@ -19,3 +23,24 @@
   vfprintf(stderr, format, ap);
   va_end(ap);
 }
+
+#if defined(SK_BUILD_FOR_WIN) && !defined(__clang__)
+
+void SkDebugf_FileLineOnly(const char* file, int line) {
+  fprintf(stderr, "%s:%d\n", file, line);
+}
+
+void SkAbort_FileLine(const char* file, int line, const char* format, ...) {
+  va_list ap;
+  va_start(ap, format);
+
+  fprintf(stderr, "%s:%d ", file, line);
+  vfprintf(stderr, format, ap);
+  va_end(ap);
+
+  sk_abort_no_print();
+  // Extra safety abort().
+  abort();
+}
+
+#endif  // defined(SK_BUILD_FOR_WIN) && !defined(__clang__)