[harfbuzz] Add shared_library target, plus FreeType integration

A shared library target enables the use of Rust crates that wrap harfbuzz.

Also, add hb-ft.{cc,h} to library (HarfBuzz-FreeType integrations), along with
the corresponding FreeType dependency.

TEXT-60 #comment

Change-Id: I35b4d5827a4c69b0756da4304caaff96a361f8ec
diff --git a/BUILD.gn b/BUILD.gn
index 2ce33cf..d103a36 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -17,7 +17,7 @@
   }
 }
 
-static_library("harfbuzz") {
+source_set("harfbuzz_sources") {
   sources = [
     "src/hb-aat-layout-ankr-table.hh",
     "src/hb-aat-layout-bsln-table.hh",
@@ -60,6 +60,8 @@
     "src/hb-font-private.hh",
     "src/hb-font.h",
     "src/hb-font.hh",
+    "src/hb-ft.h",
+    "src/hb-ft.cc",
     "src/hb-icu.cc",
     "src/hb-icu.h",
     "src/hb-iter.hh",
@@ -235,9 +237,33 @@
   }
 
   configs += [ ":harfbuzz_warnings" ]
+
+  # Without this modification, almost everything ends up hidden in the shared library, making it
+  # useless for linking.
+  if (current_toolchain == shlib_toolchain) {
+    # Avoid failure when subtracting if not already present.
+    configs += ["//build/config:symbol_visibility_hidden"]
+    configs -= ["//build/config:symbol_visibility_hidden"]
+  }
+
   public_configs = [ ":harfbuzz_config" ]
 
   deps = [
     "//third_party/icu:icuuc",
+    "//third_party/freetype2"
+  ]
+}
+
+static_library("harfbuzz") {
+  output_name = "harfbuzz"
+  public_deps = [
+    ":harfbuzz_sources"
+  ]
+}
+
+shared_library("harfbuzz_shared") {
+  output_name = "harfbuzz"
+  public_deps = [
+    ":harfbuzz_sources",
   ]
 }