Make SkShaper a module

Change-Id: I3709e49ba865f14260660cc07a762b9ac837cb3c
Reviewed-on: https://skia-review.googlesource.com/130602
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Herb Derby <herb@google.com>
diff --git a/BUILD.gn b/BUILD.gn
index d0c6755..d871e78 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -1474,7 +1474,7 @@
         "src/utils/SkLuaCanvas.cpp",
       ]
       deps = [
-        ":skshaper",
+        "modules/skshaper",
         "//third_party/lua",
       ]
     }
@@ -1535,11 +1535,11 @@
         ":experimental_svg_model",
         ":flags",
         ":gm",
-        ":skshaper",
         ":tool_utils",
         ":views",
         ":xml",
         "modules/sksg:samples",
+        "modules/skshaper",
       ]
 
       if (skia_use_lua) {
@@ -1629,33 +1629,13 @@
     }
   }
 
-  test_lib("skshaper") {
-    public_include_dirs = [ "tools/shape" ]
-    deps = [
-      ":skia",
-    ]
-
-    if (target_cpu == "wasm") {
-      sources = [
-        "tools/shape/SkShaper_primitive.cpp",
-      ]
-    } else {
-      sources = [
-        "tools/shape/SkShaper_harfbuzz.cpp",
-      ]
-      deps += [
-        "//third_party/harfbuzz",
-        "//third_party/icu",
-      ]
-    }
-  }
   test_app("sktexttopdf") {
     sources = [
-      "tools/shape/using_skia_and_harfbuzz.cpp",
+      "tools/using_skia_and_harfbuzz.cpp",
     ]
     deps = [
       ":skia",
-      ":skshaper",
+      "modules/skshaper",
     ]
   }
 
diff --git a/modules/skshaper/BUILD.gn b/modules/skshaper/BUILD.gn
new file mode 100644
index 0000000..eb67f90
--- /dev/null
+++ b/modules/skshaper/BUILD.gn
@@ -0,0 +1,40 @@
+# Copyright 2018 Google Inc.
+#
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+declare_args() {
+  skia_enable_skshaper = true
+}
+
+config("public_config") {
+  if (skia_enable_skshaper) {
+    include_dirs = [ "include" ]
+  }
+}
+
+source_set("skshaper") {
+  if (skia_enable_skshaper) {
+    public_configs = [ ":public_config" ]
+    public = [ "include/SkShaper.h" ]
+    deps = [
+      "../..:skia",
+    ]
+    if (target_cpu == "wasm") {
+      sources = [
+        "src/SkShaper_primitive.cpp",
+      ]
+    } else {
+      sources = [
+        "src/SkShaper_harfbuzz.cpp",
+      ]
+      deps += [
+        "//third_party/harfbuzz",
+        "//third_party/icu",
+      ]
+    }
+    configs += [ "../../:skia_private" ]
+
+  }
+}
+
diff --git a/tools/shape/SkShaper.h b/modules/skshaper/include/SkShaper.h
similarity index 100%
rename from tools/shape/SkShaper.h
rename to modules/skshaper/include/SkShaper.h
diff --git a/tools/shape/SkShaper_harfbuzz.cpp b/modules/skshaper/src/SkShaper_harfbuzz.cpp
similarity index 100%
rename from tools/shape/SkShaper_harfbuzz.cpp
rename to modules/skshaper/src/SkShaper_harfbuzz.cpp
diff --git a/tools/shape/SkShaper_primitive.cpp b/modules/skshaper/src/SkShaper_primitive.cpp
similarity index 100%
rename from tools/shape/SkShaper_primitive.cpp
rename to modules/skshaper/src/SkShaper_primitive.cpp
diff --git a/third_party/harfbuzz/BUILD.gn b/third_party/harfbuzz/BUILD.gn
index 9ac9835..851d3fb 100644
--- a/third_party/harfbuzz/BUILD.gn
+++ b/third_party/harfbuzz/BUILD.gn
@@ -61,5 +61,4 @@
     sources += [ "../externals/harfbuzz/src/hb-coretext.cc" ]
     defines += [ "HAVE_CORETEXT" ]
   }
-  testonly = true
 }
diff --git a/tools/shape/using_skia_and_harfbuzz.cpp b/tools/using_skia_and_harfbuzz.cpp
similarity index 100%
rename from tools/shape/using_skia_and_harfbuzz.cpp
rename to tools/using_skia_and_harfbuzz.cpp