Make SkShaper's GN setup more DLL friendly

Similar to the Skottie refactor that just landed, this avoids having an
empty component when shaper is disabled (which turns into a DLL with no
sources, and a missing DllMain). I think this pattern of having modules
expose the same components as empty groups is simpler (and also fixes
the fact that only two of N references in top-level BUILD.gn were
guarded). Also, no one is using the define?

Change-Id: I9d25c1cfbd42336874f4428bf61f3e34a4a18d3c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/207303
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
diff --git a/BUILD.gn b/BUILD.gn
index 254f6e2..9faf14d 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -1679,14 +1679,11 @@
       "modules/skottie",
       "modules/skottie:gm",
       "modules/sksg",
+      "modules/skshaper",
     ]
     public_deps = [
       ":gpu_tool_utils",
     ]
-    if (skia_enable_skshaper) {
-      deps += [ "modules/skshaper" ]
-      defines = [ "SK_USING_SKSHAPER" ]
-    }
   }
 
   import("gn/tests.gni")
@@ -1706,6 +1703,7 @@
       ":tool_utils",
       "modules/skottie:tests",
       "modules/sksg:tests",
+      "modules/skshaper",
       "//third_party/libpng",
       "//third_party/libwebp",
       "//third_party/zlib",
@@ -1713,10 +1711,6 @@
     public_deps = [
       ":gpu_tool_utils",  # Test.h #includes headers from this target.
     ]
-    if (skia_enable_skshaper) {
-      deps += [ "modules/skshaper" ]
-      defines = [ "SK_USING_SKSHAPER" ]
-    }
   }
 
   import("gn/bench.gni")
@@ -2341,9 +2335,9 @@
   if (!skia_use_vulkan && (is_mac || is_linux || is_win)) {
     test_app("fiddle_examples") {
       sources = [
+        "tools/fiddle/all_examples.cpp",
         "tools/fiddle/examples.cpp",
         "tools/fiddle/examples.h",
-        "tools/fiddle/all_examples.cpp",
       ]
       include_dirs = [ "tools" ]
       if (is_win) {
diff --git a/gn/skia.gni b/gn/skia.gni
index 8617d06..fa745ca 100644
--- a/gn/skia.gni
+++ b/gn/skia.gni
@@ -9,7 +9,6 @@
 
 declare_args() {
   skia_enable_gpu = true
-  skia_enable_skshaper = true
   skia_enable_tools = is_skia_dev_build
   skia_use_icu = !is_fuchsia && !is_ios
   skia_use_harfbuzz = true
diff --git a/modules/skshaper/BUILD.gn b/modules/skshaper/BUILD.gn
index d68ddf0..9e97ce6 100644
--- a/modules/skshaper/BUILD.gn
+++ b/modules/skshaper/BUILD.gn
@@ -5,29 +5,38 @@
 
 import("../../gn/skia.gni")
 
-config("public_config") {
-  include_dirs = [ "include" ]
-  defines = []
-  if (skia_use_icu) {
-    defines += [ "SK_SHAPER_HARFBUZZ_AVAILABLE" ]
-  }
+declare_args() {
+  skia_enable_skshaper = true
 }
 
-component("skshaper") {
-  check_includes = false
-  import("skshaper.gni")
-  public_configs = [ ":public_config" ]
-  public = skia_shaper_public
-  deps = [
-    "../..:skia",
-  ]
-  sources = skia_shaper_primitive_sources
-  if (skia_use_icu && skia_use_harfbuzz) {
-    sources += skia_shaper_harfbuzz_sources
-    deps += [
-      "//third_party/harfbuzz",
-      "//third_party/icu",
-    ]
+if (skia_enable_skshaper) {
+  config("public_config") {
+    include_dirs = [ "include" ]
+    defines = []
+    if (skia_use_icu) {
+      defines += [ "SK_SHAPER_HARFBUZZ_AVAILABLE" ]
+    }
   }
-  configs += [ "../../:skia_private" ]
+
+  component("skshaper") {
+    check_includes = false
+    import("skshaper.gni")
+    public_configs = [ ":public_config" ]
+    public = skia_shaper_public
+    deps = [
+      "../..:skia",
+    ]
+    sources = skia_shaper_primitive_sources
+    if (skia_use_icu && skia_use_harfbuzz) {
+      sources += skia_shaper_harfbuzz_sources
+      deps += [
+        "//third_party/harfbuzz",
+        "//third_party/icu",
+      ]
+    }
+    configs += [ "../../:skia_private" ]
+  }
+} else {
+  group("skshaper") {
+  }
 }