Regularize SkFontMgr for CoreText build.

Move SkFontHost_mac.cpp into an 'optional' like the other fontmgr build
rules. This allows building with other fontmgrs on Mac and makes the lib
dependencies explicit. In the future this helps with splitting the out
the default factory.

Change-Id: Iecef9e428acb69f89b54afa00b4e779f5858c61a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/294076
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
diff --git a/BUILD.gn b/BUILD.gn
index 7a6994c..b5a9098 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -361,6 +361,31 @@
   ]
 }
 
+optional("fontmgr_mac") {
+  enabled = skia_use_fonthost_mac
+
+  sources = [ "src/ports/SkFontHost_mac.cpp" ]
+
+  if (is_mac) {
+    libs = [
+      # AppKit symbols NSFontWeightXXX may be dlsym'ed.
+      "AppKit.framework",
+      "ApplicationServices.framework",
+    ]
+  }
+
+  if (is_ios) {
+    libs = [
+      "CoreFoundation.framework",
+      "CoreGraphics.framework",
+      "CoreText.framework",
+
+      # UIKit symbols UIFontWeightXXX may be dlsym'ed.
+      "UIKit.framework",
+    ]
+  }
+}
+
 optional("fontmgr_wasm") {
   enabled = target_cpu == "wasm"
   deps = []
@@ -879,6 +904,7 @@
     ":fontmgr_empty",
     ":fontmgr_fontconfig",
     ":fontmgr_fuchsia",
+    ":fontmgr_mac",
     ":fontmgr_wasm",
     ":fontmgr_win",
     ":fontmgr_win_gdi",
@@ -997,10 +1023,6 @@
     }
   }
 
-  if (skia_use_fonthost_mac) {
-    sources += [ "src/ports/SkFontHost_mac.cpp" ]
-  }
-
   if (is_mac) {
     sources += [
       "src/ports/SkDebug_stdio.cpp",
@@ -1008,8 +1030,6 @@
       "src/ports/SkImageGeneratorCG.cpp",
     ]
     libs += [
-      # AppKit symbols NSFontWeightXXX may be dlsym'ed.
-      "AppKit.framework",
       "ApplicationServices.framework",
       "OpenGL.framework",
     ]
@@ -1018,19 +1038,13 @@
   if (is_ios) {
     sources += [
       "src/ports/SkDebug_stdio.cpp",
-      "src/ports/SkFontHost_mac.cpp",
       "src/ports/SkImageEncoder_CG.cpp",
       "src/ports/SkImageGeneratorCG.cpp",
     ]
     libs += [
       "CoreFoundation.framework",
-      "CoreGraphics.framework",
-      "CoreText.framework",
       "ImageIO.framework",
       "MobileCoreServices.framework",
-
-      # UIKit symbols UIFontWeightXXX may be dlsym'ed.
-      "UIKit.framework",
     ]
   }