Use our own checked in Vulkan header to build skia source code.

Core Skia will always include our own SkiaVulkan.h which basically just
includes vulkan_core.h. All platform vulkan specific stuff must be
include by the client in their own vulkan.h file. Our public interface
is set up that we only use vulkan objects that will be present in all
versions of vulkan headers that the client could include.

Bug: skia:
Change-Id: I6673fd91498eabcc923d65d20f2b5e0a89b4ccf6
Reviewed-on: https://skia-review.googlesource.com/142985
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/BUILD.gn b/BUILD.gn
index ede8fc4..744146f 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -43,6 +43,7 @@
   skia_enable_spirv_validation = is_skia_dev_build && is_debug
   skia_enable_tools = is_skia_dev_build
   skia_enable_vulkan_debug_layers = is_skia_dev_build && is_debug
+  skia_vulkan_header = ""  # temporary as we remove the use from clients
   skia_qt_path = getenv("QT_PATH")
   skia_compile_processors = false
   skia_generate_workarounds = false
@@ -614,11 +615,7 @@
   }
 
   if (skia_use_vulkan) {
-    # TODO: We should make this deps be //third_party/vulkan and then update clients to have a
-    # //third_party/vulkan directory in their trees so they can set up the vulkan library however
-    # they want. For example this would allow us to remove the fuchsia specific vulkan code in our
-    # vulkan files.
-    public_deps += [ "third_party/vulkan" ]
+    public_defines += [ "SK_VULKAN" ]
     deps += [ "third_party/vulkanmemoryallocator" ]
     sources += skia_vk_sources
     if (skia_enable_vulkan_debug_layers) {
@@ -826,6 +823,7 @@
     ":fontmgr_empty",
     ":fontmgr_fontconfig",
     ":fontmgr_fuchsia",
+    ":gpu",
     ":heif",
     ":hsw",
     ":jpeg",
@@ -842,12 +840,6 @@
     ":xml",
   ]
 
-  # We need the public deps here for Vulkan. Our third_party/vulkan target sets some defines that
-  # need to get propagated up to the tools that depend on :skia and thus :gpu.
-  public_deps = [
-    ":gpu",
-  ]
-
   # This file (and all GN files in Skia) are designed to work with an
   # empty sources assignment filter; we handle all that explicitly.
   # We clear the filter here for clients who may have set up a global filter.
@@ -992,10 +984,6 @@
 
   config("skia.h_config") {
     include_dirs = [ "$target_gen_dir" ]
-    if (skia_use_vulkan) {
-      # So we can get the header which includes vulkan
-      include_dirs += [ "tools/gpu/vk" ]
-    }
   }
   action("skia.h") {
     public_configs = [ ":skia.h_config" ]
@@ -1230,12 +1218,42 @@
     }
   }
 
+  config("moltenvk_config") {
+    if (defined(skia_moltenvk_path) && skia_moltenvk_path != "") {
+      if (is_ios) {
+        moltenvk_framework_path = "$skia_moltenvk_path/MoltenVK/iOS"
+      } else {
+        moltenvk_framework_path = "$skia_moltenvk_path/MoltenVK/macOS"
+      }
+      cflags = [ "-F$moltenvk_framework_path" ]
+      ldflags = [ "-F$moltenvk_framework_path" ]
+      libs = [
+        "MoltenVK.framework",
+        "Metal.framework",
+        "IOSurface.framework",
+        "QuartzCore.framework",
+        "Foundation.framework",
+      ]
+      if (is_ios) {
+        libs += [ "UIKit.framework" ]
+      } else {
+        libs += [ "IOKit.framework" ]
+      }
+      defines = [ "SK_MOLTENVK" ]
+    }
+  }
+
+  source_set("moltenvk") {
+    public_configs = [ ":moltenvk_config" ]
+  }
+
   test_lib("gpu_tool_utils") {
     public_include_dirs = []
     public_defines = []
     public_include_dirs += [ "tools/gpu" ]
 
     deps = []
+    public_deps = []
     sources = [
       "tools/gpu/GrContextFactory.cpp",
       "tools/gpu/GrTest.cpp",
@@ -1279,8 +1297,12 @@
       sources += [ "tools/gpu/gl/angle/GLTestContext_angle.cpp" ]
     }
     if (skia_use_vulkan) {
+      public_include_dirs += [ "third_party/vulkan" ]
       sources += [ "tools/gpu/vk/VkTestContext.cpp" ]
       sources += [ "tools/gpu/vk/VkTestUtils.cpp" ]
+      if (defined(skia_moltenvk_path) && skia_moltenvk_path != "") {
+        public_deps += [ ":moltenvk" ]
+      }
     }
     if (skia_use_metal) {
       sources += [ "tools/gpu/mtl/MtlTestContext.mm" ]
@@ -1301,6 +1323,8 @@
     ]
     deps = [
       ":flags",
+    ]
+    public_deps = [
       ":gpu_tool_utils",
     ]
   }
@@ -1354,12 +1378,12 @@
       defines += [ "SK_TOOLS_REQUIRE_RESOURCES" ]
     }
     deps = [
-      ":common_flags",
       ":experimental_svg_model",
       ":flags",
       "//third_party/libpng",
     ]
     public_deps = [
+      ":common_flags",
       "//third_party/jsoncpp",
     ]
   }
@@ -1370,12 +1394,14 @@
     sources = gm_sources
     deps = [
       ":flags",
-      ":gpu_tool_utils",
       ":skia",
       ":tool_utils",
       "modules/skottie",
       "modules/sksg",
     ]
+    public_deps = [
+      ":gpu_tool_utils",
+    ]
   }
 
   import("gn/tests.gni")