Require the GPU backend to build our internal tools

This causes builders with skia_enable_gpu set to false to stop building
DM, nanobench, etc. Next step is to remove all of the GPU shimming used
throughout those tools, and conditional code and tests.

Bug: skia:
Change-Id: I59c1c64b7e4e300c3a72a2eed9b481ed1bdf732c
Reviewed-on: https://skia-review.googlesource.com/131146
Reviewed-by: Mike Klein <mtklein@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
diff --git a/BUILD.gn b/BUILD.gn
index 7270fa4..36ab16c 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -80,8 +80,8 @@
   import(skia_settings)
 }
 
-# Our tools require static linking (they use non-exported symbols).
-skia_enable_tools = skia_enable_tools && !is_component_build
+# Our tools require static linking (they use non-exported symbols), and the GPU backend.
+skia_enable_tools = skia_enable_tools && !is_component_build && skia_enable_gpu
 
 fontmgr_android_enabled = skia_use_expat && skia_use_freetype
 
@@ -1011,7 +1011,7 @@
     ]
   }
 
-  if (skia_enable_gpu && target_cpu == "x64") {
+  if (target_cpu == "x64") {
     executable("fiddle") {
       libs = []
       sources = [
@@ -1035,18 +1035,16 @@
     }
   }
 
-  if (skia_enable_gpu) {
-    source_set("public_headers_warnings_check") {
-      sources = [
-        "tools/public_headers_warnings_check.cpp",
-      ]
-      configs -= [ "//gn:warnings_except_public_headers" ]
-      deps = [
-        ":skia",
-        ":skia.h",
-        "modules/skottie",
-      ]
-    }
+  source_set("public_headers_warnings_check") {
+    sources = [
+      "tools/public_headers_warnings_check.cpp",
+    ]
+    configs -= [ "//gn:warnings_except_public_headers" ]
+    deps = [
+      ":skia",
+      ":skia.h",
+      "modules/skottie",
+    ]
   }
 
   template("test_lib") {
@@ -1228,62 +1226,60 @@
 
   test_lib("gpu_tool_utils") {
     public_include_dirs = []
-    if (skia_enable_gpu) {
-      public_defines = []
-      public_include_dirs += [ "tools/gpu" ]
+    public_defines = []
+    public_include_dirs += [ "tools/gpu" ]
 
-      deps = []
-      sources = [
-        "tools/gpu/GrContextFactory.cpp",
-        "tools/gpu/GrTest.cpp",
-        "tools/gpu/ProxyUtils.cpp",
-        "tools/gpu/TestContext.cpp",
-        "tools/gpu/atlastext/GLTestAtlasTextRenderer.cpp",
-        "tools/gpu/gl/GLTestContext.cpp",
-        "tools/gpu/gl/command_buffer/GLTestContext_command_buffer.cpp",
-        "tools/gpu/gl/debug/DebugGLTestContext.cpp",
-        "tools/gpu/gl/debug/GrBufferObj.cpp",
-        "tools/gpu/gl/debug/GrFrameBufferObj.cpp",
-        "tools/gpu/gl/debug/GrProgramObj.cpp",
-        "tools/gpu/gl/debug/GrShaderObj.cpp",
-        "tools/gpu/gl/debug/GrTextureObj.cpp",
-        "tools/gpu/gl/debug/GrTextureUnitObj.cpp",
-        "tools/gpu/gl/null/NullGLTestContext.cpp",
-        "tools/gpu/mock/MockTestContext.cpp",
+    deps = []
+    sources = [
+      "tools/gpu/GrContextFactory.cpp",
+      "tools/gpu/GrTest.cpp",
+      "tools/gpu/ProxyUtils.cpp",
+      "tools/gpu/TestContext.cpp",
+      "tools/gpu/atlastext/GLTestAtlasTextRenderer.cpp",
+      "tools/gpu/gl/GLTestContext.cpp",
+      "tools/gpu/gl/command_buffer/GLTestContext_command_buffer.cpp",
+      "tools/gpu/gl/debug/DebugGLTestContext.cpp",
+      "tools/gpu/gl/debug/GrBufferObj.cpp",
+      "tools/gpu/gl/debug/GrFrameBufferObj.cpp",
+      "tools/gpu/gl/debug/GrProgramObj.cpp",
+      "tools/gpu/gl/debug/GrShaderObj.cpp",
+      "tools/gpu/gl/debug/GrTextureObj.cpp",
+      "tools/gpu/gl/debug/GrTextureUnitObj.cpp",
+      "tools/gpu/gl/null/NullGLTestContext.cpp",
+      "tools/gpu/mock/MockTestContext.cpp",
+    ]
+    libs = []
+
+    if (is_android || skia_use_egl) {
+      sources += [ "tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp" ]
+    } else if (is_ios) {
+      sources += [ "tools/gpu/gl/iOS/CreatePlatformGLTestContext_iOS.mm" ]
+      libs += [ "OpenGLES.framework" ]
+    } else if (is_linux) {
+      sources += [ "tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp" ]
+      libs += [ "X11" ]
+    } else if (is_mac) {
+      sources += [ "tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp" ]
+    } else if (is_win) {
+      sources += [ "tools/gpu/gl/win/CreatePlatformGLTestContext_win.cpp" ]
+      libs += [
+        "Gdi32.lib",
+        "OpenGL32.lib",
       ]
-      libs = []
+    }
 
-      if (is_android || skia_use_egl) {
-        sources += [ "tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp" ]
-      } else if (is_ios) {
-        sources += [ "tools/gpu/gl/iOS/CreatePlatformGLTestContext_iOS.mm" ]
-        libs += [ "OpenGLES.framework" ]
-      } else if (is_linux) {
-        sources += [ "tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp" ]
-        libs += [ "X11" ]
-      } else if (is_mac) {
-        sources += [ "tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp" ]
-      } else if (is_win) {
-        sources += [ "tools/gpu/gl/win/CreatePlatformGLTestContext_win.cpp" ]
-        libs += [
-          "Gdi32.lib",
-          "OpenGL32.lib",
-        ]
-      }
+    cflags_objcc = [ "-fobjc-arc" ]
 
-      cflags_objcc = [ "-fobjc-arc" ]
-
-      if (skia_use_angle) {
-        deps += [ "//third_party/angle2" ]
-        sources += [ "tools/gpu/gl/angle/GLTestContext_angle.cpp" ]
-      }
-      if (skia_use_vulkan) {
-        sources += [ "tools/gpu/vk/VkTestContext.cpp" ]
-        sources += [ "tools/gpu/vk/VkTestUtils.cpp" ]
-      }
-      if (skia_use_metal) {
-        sources += [ "tools/gpu/mtl/MtlTestContext.mm" ]
-      }
+    if (skia_use_angle) {
+      deps += [ "//third_party/angle2" ]
+      sources += [ "tools/gpu/gl/angle/GLTestContext_angle.cpp" ]
+    }
+    if (skia_use_vulkan) {
+      sources += [ "tools/gpu/vk/VkTestContext.cpp" ]
+      sources += [ "tools/gpu/vk/VkTestUtils.cpp" ]
+    }
+    if (skia_use_metal) {
+      sources += [ "tools/gpu/mtl/MtlTestContext.mm" ]
     }
   }
 
@@ -1607,18 +1603,16 @@
     ]
   }
 
-  if (skia_enable_gpu) {
-    test_app("skpbench") {
-      sources = [
-        "tools/skpbench/skpbench.cpp",
-      ]
-      deps = [
-        ":flags",
-        ":gpu_tool_utils",
-        ":skia",
-        ":tool_utils",
-      ]
-    }
+  test_app("skpbench") {
+    sources = [
+      "tools/skpbench/skpbench.cpp",
+    ]
+    deps = [
+      ":flags",
+      ":gpu_tool_utils",
+      ":skia",
+      ":tool_utils",
+    ]
   }
 
   test_app("sktexttopdf") {
@@ -1797,7 +1791,7 @@
     ]
   }
 
-  if (!is_win && skia_enable_gpu) {
+  if (!is_win) {
     test_lib("skqp_lib") {
       public_include_dirs = [ "tools/skqp" ]
       defines =
@@ -1830,7 +1824,7 @@
       ]
     }
   }
-  if (is_android && skia_enable_gpu) {
+  if (is_android) {
     test_app("skqp_app") {
       is_shared_library = true
       sources = [
@@ -1865,138 +1859,134 @@
     ]
   }
 
-  if (skia_enable_gpu) {
-    test_lib("sk_app") {
-      public_include_dirs = [ "tools/sk_app" ]
-      sources = [
-        "tools/sk_app/CommandSet.cpp",
-        "tools/sk_app/GLWindowContext.cpp",
-        "tools/sk_app/Window.cpp",
+  test_lib("sk_app") {
+    public_include_dirs = [ "tools/sk_app" ]
+    sources = [
+      "tools/sk_app/CommandSet.cpp",
+      "tools/sk_app/GLWindowContext.cpp",
+      "tools/sk_app/Window.cpp",
+    ]
+    libs = []
+
+    if (is_android) {
+      sources += [
+        "tools/sk_app/android/GLWindowContext_android.cpp",
+        "tools/sk_app/android/RasterWindowContext_android.cpp",
+        "tools/sk_app/android/Window_android.cpp",
+        "tools/sk_app/android/main_android.cpp",
+        "tools/sk_app/android/surface_glue_android.cpp",
       ]
-      libs = []
-
-      if (is_android) {
-        sources += [
-          "tools/sk_app/android/GLWindowContext_android.cpp",
-          "tools/sk_app/android/RasterWindowContext_android.cpp",
-          "tools/sk_app/android/Window_android.cpp",
-          "tools/sk_app/android/main_android.cpp",
-          "tools/sk_app/android/surface_glue_android.cpp",
-        ]
-        libs += [ "android" ]
-      } else if (is_linux) {
-        sources += [
-          "tools/sk_app/unix/GLWindowContext_unix.cpp",
-          "tools/sk_app/unix/RasterWindowContext_unix.cpp",
-          "tools/sk_app/unix/Window_unix.cpp",
-          "tools/sk_app/unix/keysym2ucs.c",
-          "tools/sk_app/unix/main_unix.cpp",
-        ]
-        libs += [
-          "GL",
-          "X11",
-        ]
-      } else if (is_win) {
-        sources += [
-          "tools/sk_app/win/GLWindowContext_win.cpp",
-          "tools/sk_app/win/RasterWindowContext_win.cpp",
-          "tools/sk_app/win/Window_win.cpp",
-          "tools/sk_app/win/main_win.cpp",
-        ]
-        if (skia_use_angle) {
-          sources += [ "tools/sk_app/win/ANGLEWindowContext_win.cpp" ]
-        }
-      } else if (is_mac) {
-        sources += [
-          "tools/sk_app/mac/GLWindowContext_mac.cpp",
-          "tools/sk_app/mac/RasterWindowContext_mac.cpp",
-          "tools/sk_app/mac/Window_mac.cpp",
-          "tools/sk_app/mac/main_mac.cpp",
-        ]
-        libs += [
-          "QuartzCore.framework",
-          "Cocoa.framework",
-          "Foundation.framework",
-        ]
-      } else if (is_ios) {
-        sources += [
-          "tools/sk_app/ios/GLWindowContext_ios.cpp",
-          "tools/sk_app/ios/RasterWindowContext_ios.cpp",
-          "tools/sk_app/ios/Window_ios.cpp",
-          "tools/sk_app/ios/main_ios.cpp",
-        ]
-      }
-
-      if (skia_use_vulkan) {
-        sources += [ "tools/sk_app/VulkanWindowContext.cpp" ]
-        if (is_android) {
-          sources += [ "tools/sk_app/android/VulkanWindowContext_android.cpp" ]
-        } else if (is_linux) {
-          sources += [ "tools/sk_app/unix/VulkanWindowContext_unix.cpp" ]
-          libs += [ "X11-xcb" ]
-        } else if (is_win) {
-          sources += [ "tools/sk_app/win/VulkanWindowContext_win.cpp" ]
-        }
-      }
-
-      deps = [
-        ":gpu_tool_utils",
-        ":skia",
-        ":tool_utils",
-        ":views",
+      libs += [ "android" ]
+    } else if (is_linux) {
+      sources += [
+        "tools/sk_app/unix/GLWindowContext_unix.cpp",
+        "tools/sk_app/unix/RasterWindowContext_unix.cpp",
+        "tools/sk_app/unix/Window_unix.cpp",
+        "tools/sk_app/unix/keysym2ucs.c",
+        "tools/sk_app/unix/main_unix.cpp",
       ]
-      if (is_android) {
-        deps += [ "//third_party/native_app_glue" ]
-      } else if (is_mac || is_ios) {
-        deps += [ "//third_party/libsdl" ]
-      }
+      libs += [
+        "GL",
+        "X11",
+      ]
+    } else if (is_win) {
+      sources += [
+        "tools/sk_app/win/GLWindowContext_win.cpp",
+        "tools/sk_app/win/RasterWindowContext_win.cpp",
+        "tools/sk_app/win/Window_win.cpp",
+        "tools/sk_app/win/main_win.cpp",
+      ]
       if (skia_use_angle) {
-        deps += [ "//third_party/angle2" ]
+        sources += [ "tools/sk_app/win/ANGLEWindowContext_win.cpp" ]
       }
+    } else if (is_mac) {
+      sources += [
+        "tools/sk_app/mac/GLWindowContext_mac.cpp",
+        "tools/sk_app/mac/RasterWindowContext_mac.cpp",
+        "tools/sk_app/mac/Window_mac.cpp",
+        "tools/sk_app/mac/main_mac.cpp",
+      ]
+      libs += [
+        "QuartzCore.framework",
+        "Cocoa.framework",
+        "Foundation.framework",
+      ]
+    } else if (is_ios) {
+      sources += [
+        "tools/sk_app/ios/GLWindowContext_ios.cpp",
+        "tools/sk_app/ios/RasterWindowContext_ios.cpp",
+        "tools/sk_app/ios/Window_ios.cpp",
+        "tools/sk_app/ios/main_ios.cpp",
+      ]
+    }
+
+    if (skia_use_vulkan) {
+      sources += [ "tools/sk_app/VulkanWindowContext.cpp" ]
+      if (is_android) {
+        sources += [ "tools/sk_app/android/VulkanWindowContext_android.cpp" ]
+      } else if (is_linux) {
+        sources += [ "tools/sk_app/unix/VulkanWindowContext_unix.cpp" ]
+        libs += [ "X11-xcb" ]
+      } else if (is_win) {
+        sources += [ "tools/sk_app/win/VulkanWindowContext_win.cpp" ]
+      }
+    }
+
+    deps = [
+      ":gpu_tool_utils",
+      ":skia",
+      ":tool_utils",
+      ":views",
+    ]
+    if (is_android) {
+      deps += [ "//third_party/native_app_glue" ]
+    } else if (is_mac || is_ios) {
+      deps += [ "//third_party/libsdl" ]
+    }
+    if (skia_use_angle) {
+      deps += [ "//third_party/angle2" ]
     }
   }
 
-  if (skia_enable_gpu) {
-    test_app("viewer") {
-      is_shared_library = is_android
-      if (is_ios) {
-        bundle_ios_data = true
-      }
-      sources = [
-        "tools/viewer/BisectSlide.cpp",
-        "tools/viewer/GMSlide.cpp",
-        "tools/viewer/ImGuiLayer.cpp",
-        "tools/viewer/ImageSlide.cpp",
-        "tools/viewer/SKPSlide.cpp",
-        "tools/viewer/SampleSlide.cpp",
-        "tools/viewer/SkottieSlide.cpp",
-        "tools/viewer/SlideDir.cpp",
-        "tools/viewer/StatsLayer.cpp",
-        "tools/viewer/SvgSlide.cpp",
-        "tools/viewer/Viewer.cpp",
-      ]
-      libs = []
-
-      include_dirs = []
-      deps = [
-        ":experimental_svg_model",
-        ":flags",
-        ":gm",
-        ":gpu_tool_utils",
-        ":samples",
-        ":sk_app",
-        ":skia",
-        ":tool_utils",
-        ":views",
-        "modules/skottie",
-        "modules/sksg",
-        "//third_party/imgui",
-        "//third_party/jsoncpp",
-      ]
+  test_app("viewer") {
+    is_shared_library = is_android
+    if (is_ios) {
+      bundle_ios_data = true
     }
+    sources = [
+      "tools/viewer/BisectSlide.cpp",
+      "tools/viewer/GMSlide.cpp",
+      "tools/viewer/ImGuiLayer.cpp",
+      "tools/viewer/ImageSlide.cpp",
+      "tools/viewer/SKPSlide.cpp",
+      "tools/viewer/SampleSlide.cpp",
+      "tools/viewer/SkottieSlide.cpp",
+      "tools/viewer/SlideDir.cpp",
+      "tools/viewer/StatsLayer.cpp",
+      "tools/viewer/SvgSlide.cpp",
+      "tools/viewer/Viewer.cpp",
+    ]
+    libs = []
+
+    include_dirs = []
+    deps = [
+      ":experimental_svg_model",
+      ":flags",
+      ":gm",
+      ":gpu_tool_utils",
+      ":samples",
+      ":sk_app",
+      ":skia",
+      ":tool_utils",
+      ":views",
+      "modules/skottie",
+      "modules/sksg",
+      "//third_party/imgui",
+      "//third_party/jsoncpp",
+    ]
   }
 
-  if (skia_enable_gpu && !skia_use_angle && (is_linux || is_win || is_mac)) {
+  if (!skia_use_angle && (is_linux || is_win || is_mac)) {
     test_app("HelloWorld") {
       sources = [
         "example/HelloWorld.cpp",
@@ -2015,7 +2005,7 @@
     }
   }
 
-  if (skia_enable_gpu && (is_linux || is_mac || is_ios)) {
+  if (is_linux || is_mac || is_ios) {
     test_app("SkiaSDLExample") {
       sources = [
         "example/SkiaSDLExample.cpp",