Switch GN defs on Mac and iOS to use frameworks instead of libs.

GN will be removing support for frameworks in the libs variable, so
might as well get ahead of it.

Change-Id: I67b118457721975ac2408308438d71172be66592
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/300181
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
diff --git a/BUILD.gn b/BUILD.gn
index a82555e..486d75c 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -454,7 +454,7 @@
   ]
 
   if (is_mac) {
-    libs = [
+    frameworks = [
       # AppKit symbols NSFontWeightXXX may be dlsym'ed.
       "AppKit.framework",
       "ApplicationServices.framework",
@@ -462,7 +462,7 @@
   }
 
   if (is_ios) {
-    libs = [
+    frameworks = [
       "CoreFoundation.framework",
       "CoreGraphics.framework",
       "CoreText.framework",
@@ -637,6 +637,7 @@
   }
 
   libs = []
+  frameworks = []
 
   if (skia_use_gl) {
     public_defines += [ "SK_GL" ]
@@ -709,7 +710,7 @@
         "d3dcompiler.lib",
       ]
     } else if (dawn_enable_metal) {
-      libs += [ "Metal.framework" ]
+      frameworks += [ "Metal.framework" ]
     }
   }
 
@@ -731,9 +732,9 @@
   if (skia_use_metal) {
     public_defines += [ "SK_METAL" ]
     sources += skia_metal_sources
-    libs += [ "Metal.framework" ]
-    libs += [ "MetalKit.framework" ]
-    libs += [ "Foundation.framework" ]
+    frameworks += [ "Metal.framework" ]
+    frameworks += [ "MetalKit.framework" ]
+    frameworks += [ "Foundation.framework" ]
     cflags_objcc += [ "-fobjc-arc" ]
   }
 
@@ -1081,6 +1082,7 @@
 
   defines = []
   libs = []
+  frameworks = []
 
   if (is_win) {
     sources += [
@@ -1131,7 +1133,7 @@
       "src/ports/SkImageEncoder_CG.cpp",
       "src/ports/SkImageGeneratorCG.cpp",
     ]
-    libs += [
+    frameworks += [
       "ApplicationServices.framework",
       "OpenGL.framework",
     ]
@@ -1143,7 +1145,7 @@
       "src/ports/SkImageEncoder_CG.cpp",
       "src/ports/SkImageGeneratorCG.cpp",
     ]
-    libs += [
+    frameworks += [
       "CoreFoundation.framework",
       "ImageIO.framework",
       "MobileCoreServices.framework",
@@ -1471,13 +1473,14 @@
     ]
 
     libs = []
+    frameworks = []
 
     if (skia_use_gl) {
       sources +=
           [ "tools/gpu/gl/command_buffer/GLTestContext_command_buffer.cpp" ]
       if (is_ios) {
         sources += [ "tools/gpu/gl/iOS/CreatePlatformGLTestContext_iOS.mm" ]
-        libs += [ "OpenGLES.framework" ]
+        frameworks += [ "OpenGLES.framework" ]
       } else if (is_mac) {
         sources += [ "tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp" ]
       }
@@ -1612,17 +1615,18 @@
       sources += [ "tools/CrashHandler.cpp" ]
     }
     libs = []
+    frameworks = []
     if (is_ios) {
       sources += [ "tools/ios_utils.m" ]
       sources += [ "tools/ios_utils.h" ]
       if (skia_use_metal) {
         sources += [ "tools/AutoreleasePool.mm" ]
       }
-      libs += [ "Foundation.framework" ]
+      frameworks += [ "Foundation.framework" ]
     } else if (is_mac) {
       if (skia_use_metal) {
         sources += [ "tools/AutoreleasePool.mm" ]
-        libs += [ "Foundation.framework" ]
+        frameworks += [ "Foundation.framework" ]
       }
     } else if (is_win) {
       libs += [ "DbgHelp.lib" ]
@@ -2249,6 +2253,7 @@
       "tools/sk_app/WindowContext.h",
     ]
     libs = []
+    frameworks = []
 
     if (is_android) {
       sources += [
@@ -2291,7 +2296,7 @@
         "tools/sk_app/mac/Window_mac.mm",
         "tools/sk_app/mac/main_mac.mm",
       ]
-      libs += [
+      frameworks += [
         "QuartzCore.framework",
         "Cocoa.framework",
         "Foundation.framework",
@@ -2304,7 +2309,7 @@
         "tools/sk_app/ios/Window_ios.mm",
         "tools/sk_app/ios/main_ios.mm",
       ]
-      libs += [ "QuartzCore.framework" ]
+      frameworks += [ "QuartzCore.framework" ]
     }
 
     if (skia_use_gl) {
diff --git a/gn/toolchain/BUILD.gn b/gn/toolchain/BUILD.gn
index 4517710..0465686 100644
--- a/gn/toolchain/BUILD.gn
+++ b/gn/toolchain/BUILD.gn
@@ -234,7 +234,7 @@
 
     tool("objc") {
       depfile = "{{output}}.d"
-      command = "$cc_wrapper $cc -MD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_objc}} -c {{source}} -o {{output}}"
+      command = "$cc_wrapper $cc -MD -MF $depfile {{defines}} {{include_dirs}} {{framework_dirs}} {{cflags}} {{cflags_objc}} -c {{source}} -o {{output}}"
       depsformat = "gcc"
       outputs =
           [ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o" ]
@@ -243,7 +243,7 @@
 
     tool("objcxx") {
       depfile = "{{output}}.d"
-      command = "$cc_wrapper $cxx -MD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} {{cflags_objcc}} -c {{source}} -o {{output}}"
+      command = "$cc_wrapper $cxx -MD -MF $depfile {{defines}} {{include_dirs}} {{framework_dirs}} {{cflags}} {{cflags_cc}} {{cflags_objcc}} -c {{source}} -o {{output}}"
       depsformat = "gcc"
       outputs =
           [ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o" ]
@@ -304,7 +304,7 @@
         _end_group = ""
       }
 
-      command = "$cxx -shared {{ldflags}} $_start_group @$rspfile {{solibs}} $_end_group {{libs}} $rpath -o {{output}}"
+      command = "$cxx -shared {{ldflags}} $_start_group @$rspfile {{solibs}} $_end_group {{frameworks}} {{libs}} $rpath -o {{output}}"
       outputs = [ "{{root_out_dir}}/$soname" ]
       output_prefix = "lib"
       default_output_extension = ".so"
@@ -328,7 +328,7 @@
         _start_group = ""
         _end_group = ""
       }
-      command = "$cxx {{ldflags}} $_start_group @$rspfile {{solibs}} $_end_group {{libs}} -o $exe_name"
+      command = "$cxx {{ldflags}} $_start_group @$rspfile {{solibs}} $_end_group {{frameworks}} {{libs}} -o $exe_name"
 
       outputs = [ "$exe_name" ]
       description = "link {{output}}"