[lavapipe] Remove Wayland dependency from runtime

- Split runtime target so lavapipe depends on its
  own runtime target that in turn does not depend
  on wsi.

- whitespace-only change to vk_semaphore.c.

Change-Id: I559ea26a0ed7827a94731837879b759f5b87c33c
Reviewed-on: https://fuchsia-review.googlesource.com/c/third_party/mesa/+/983596
Reviewed-by: John Bauman <jbauman@google.com>
Reviewed-by: Craig Stout <cstout@google.com>
Reviewed-on: https://fuchsia-review.googlesource.com/c/third_party/mesa/+/1005913
Reviewed-by: Josh Gargus <jjosh@google.com>
Commit-Queue: Josh Gargus <jjosh@google.com>
diff --git a/src/gallium/frontends/lavapipe/BUILD.gn b/src/gallium/frontends/lavapipe/BUILD.gn
index 9d109e0..7c2f4b3 100644
--- a/src/gallium/frontends/lavapipe/BUILD.gn
+++ b/src/gallium/frontends/lavapipe/BUILD.gn
@@ -95,7 +95,6 @@
 mesa_source_set("lavapipe") {
   public_deps = [
     "$mesa_build_root/src/compiler",
-    "$mesa_build_root/src/vulkan/wsi",
   ]
 
   public_configs = [ ":lavapipe_config" ]
@@ -107,10 +106,18 @@
     "$mesa_build_root/src/gallium/auxiliary",
     "$mesa_build_root/src/gallium/auxiliary/pipe-loader:pipe-loader-llvmpipe",
     "$mesa_build_root/src/util",
-    "$mesa_build_root/src/vulkan/runtime",
     "$mesa_build_root/src/vulkan/util",
   ]
 
+  if(target_os == "fuchsia") {
+    public_deps += [ "$mesa_build_root/src/vulkan/wsi:stub" ]
+    deps += [ "$mesa_build_root/src/vulkan/runtime:zircon" ]
+  } else {
+    public_deps += [ "$mesa_build_root/src/vulkan/wsi" ]
+    deps += [ "$mesa_build_root/src/vulkan/runtime" ]
+  }
+
+
   sources = [
     # target.c is not used by our sibling meson.build, but rather by
     # //mesa/src/gallium/targets/lavapipe/meson.build.  We include it here because it's not worth
diff --git a/src/intel/vulkan/BUILD.gn b/src/intel/vulkan/BUILD.gn
index a1f5f85..60b40b7 100644
--- a/src/intel/vulkan/BUILD.gn
+++ b/src/intel/vulkan/BUILD.gn
@@ -110,7 +110,7 @@
 
   public_configs = [
     ":vulkan_internal_config",
-    "$mesa_build_root/src/vulkan/runtime:config",
+    "$mesa_build_root/src/vulkan/runtime:magma_config",
   ]
 
   deps = [
@@ -197,7 +197,7 @@
 
     configs = [
       ":vulkan_internal_config",
-      "$mesa_build_root/src/vulkan/runtime:config",
+      "$mesa_build_root/src/vulkan/runtime:magma_config",
     ]
 
     sources = [
diff --git a/src/vulkan/runtime/BUILD.gn b/src/vulkan/runtime/BUILD.gn
index 14c5eb8..96baaab 100644
--- a/src/vulkan/runtime/BUILD.gn
+++ b/src/vulkan/runtime/BUILD.gn
@@ -22,25 +22,103 @@
 import("//third_party/mako/py_srcs.gni")
 import("../../../mesa.gni")
 
-config("config") {
+config("common") {
   include_dirs = [
     "$target_gen_dir",
+    # Needed because generated vk_dispatch_trampolines.h includes 'vulkan/util/vk_dispatch_table.h'
+    "$target_gen_dir/../..",
     ".",
+    "$mesa_build_root/src/vulkan",
+    "$mesa_build_root/src/vulkan/util",
+    "$mesa_build_root/include",
   ]
+}
 
+config("magma_config") {
+  configs = [ ":common" ]
   defines = [ "USE_MAGMA=1" ]
 }
 
-mesa_source_set("runtime") {
-  public_configs = [ ":config" ]
+runtime_headers = [
+  "vk_buffer.h",
+  "vk_command_buffer.h",
+  "vk_command_pool.h",
+  "vk_debug_report.h",
+  "vk_debug_utils.h",
+  "vk_deferred_operation.h",
+  "vk_descriptor_set_layout.h",
+  "vk_descriptor_update_template.h",
+  "vk_descriptors.h",
+  "vk_device.h",
+  "vk_fence.h",
+  "vk_framebuffer.h",
+  "vk_graphics_state.h",
+  "vk_image.h",
+  "vk_instance.h",
+  "vk_log.h",
+  "vk_nir.h",
+  "vk_object.h",
+  "vk_physical_device.h",
+  "vk_pipeline.h",
+  "vk_pipeline_cache.h",
+  "vk_pipeline_layout.h",
+  "vk_queue.h",
+  "vk_sampler.h",
+  "vk_semaphore.h",
+  "vk_shader_module.h",
+  "vk_standard_sample_locations.h",
+  "vk_sync.h",
+  "vk_sync_binary.h",
+  "vk_sync_dummy.h",
+  "vk_sync_timeline.h",
+]
 
+runtime_sources = [
+    "vk_buffer.c",
+    "vk_cmd_copy.c",
+    "vk_cmd_enqueue.c",
+    "vk_command_buffer.c",
+    "vk_command_pool.c",
+    "vk_debug_report.c",
+    "vk_debug_utils.c",
+    "vk_deferred_operation.c",
+    "vk_descriptor_set_layout.c",
+    "vk_descriptor_update_template.c",
+    "vk_descriptors.c",
+    "vk_device.c",
+    "vk_fence.c",
+    "vk_framebuffer.c",
+    "vk_graphics_state.c",
+    "vk_image.c",
+    "vk_instance.c",
+    "vk_log.c",
+    "vk_nir.c",
+    "vk_object.c",
+    "vk_object.h",
+    "vk_physical_device.c",
+    "vk_pipeline.c",
+    "vk_pipeline_cache.c",
+    "vk_pipeline_layout.c",
+    "vk_queue.c",
+    "vk_render_pass.c",
+    "vk_sampler.c",
+    "vk_semaphore.c",
+    "vk_shader_module.c",
+    "vk_standard_sample_locations.c",
+    "vk_sync.c",
+    "vk_sync_binary.c",
+    "vk_sync_dummy.c",
+    "vk_sync_timeline.c",
+    "vk_synchronization2.c",
+]
+
+runtime_public_deps = [
+  "$mesa_build_root/include:c_compat",
+  "$mesa_build_root/include:vulkan",
+]
+
+mesa_source_set("generated") {
   public_deps = [
-    "$mesa_build_root/include:c_compat",
-    "$mesa_build_root/include:vulkan",
-    "//sdk/lib/magma_client:magma_headers",
-  ]
-
-  deps = [
     ":vk_cmd_enqueue_entrypoints",
     ":vk_cmd_queue",
     ":vk_common_entrypoints",
@@ -49,93 +127,41 @@
     "$mesa_build_root/src/compiler/nir",
     "$mesa_build_root/src/util",
     "$mesa_build_root/src/vulkan/util",
-    "//sdk/lib/magma_client:magma_headers",
   ]
+}
 
-  include_dirs = [
-    # Needed because generated vk_dispatch_trampolines.h includes 'vulkan/util/vk_dispatch_table.h'
-    "$target_gen_dir/../..",
-  ]
+mesa_source_set("runtime") {
+  public_configs = [ ":magma_config" ]
+
+  deps = [ ":generated" ]
+  public_deps = runtime_public_deps + [ "//sdk/lib/magma_client:magma_headers" ]
 
   sources = [
     "$target_gen_dir/vk_cmd_enqueue_entrypoints.c",
-    "$target_gen_dir/vk_cmd_enqueue_entrypoints.h",
     "$target_gen_dir/vk_cmd_queue.c",
-    "$target_gen_dir/vk_cmd_queue.h",
     "$target_gen_dir/vk_common_entrypoints.c",
-    "$target_gen_dir/vk_common_entrypoints.h",
     "$target_gen_dir/vk_dispatch_trampolines.c",
-    "$target_gen_dir/vk_dispatch_trampolines.h",
     "$target_gen_dir/vk_physical_device_features.c",
-    "vk_buffer.c",
-    "vk_buffer.h",
-    "vk_cmd_copy.c",
-    "vk_cmd_enqueue.c",
-    "vk_command_buffer.c",
-    "vk_command_buffer.h",
-    "vk_command_pool.c",
-    "vk_command_pool.h",
-    "vk_debug_report.c",
-    "vk_debug_report.h",
-    "vk_debug_utils.c",
-    "vk_debug_utils.h",
-    "vk_deferred_operation.c",
-    "vk_deferred_operation.h",
-    "vk_descriptor_set_layout.c",
-    "vk_descriptor_set_layout.h",
-    "vk_descriptor_update_template.c",
-    "vk_descriptor_update_template.h",
-    "vk_descriptors.c",
-    "vk_descriptors.h",
-    "vk_device.c",
-    "vk_device.h",
-    "vk_fence.c",
-    "vk_fence.h",
-    "vk_framebuffer.c",
-    "vk_framebuffer.h",
-    "vk_graphics_state.c",
-    "vk_graphics_state.h",
-    "vk_image.c",
-    "vk_image.h",
-    "vk_instance.c",
-    "vk_instance.h",
-    "vk_log.c",
-    "vk_log.h",
     "vk_magma_syncobj.c",
-    "vk_magma_syncobj.h",
-    "vk_nir.c",
-    "vk_nir.h",
-    "vk_object.c",
-    "vk_object.h",
-    "vk_physical_device.c",
-    "vk_physical_device.h",
-    "vk_pipeline.c",
-    "vk_pipeline.h",
-    "vk_pipeline_cache.c",
-    "vk_pipeline_cache.h",
-    "vk_pipeline_layout.c",
-    "vk_pipeline_layout.h",
-    "vk_queue.c",
-    "vk_queue.h",
-    "vk_render_pass.c",
-    "vk_sampler.c",
-    "vk_sampler.h",
-    "vk_semaphore.c",
-    "vk_semaphore.h",
-    "vk_shader_module.c",
-    "vk_shader_module.h",
-    "vk_standard_sample_locations.c",
-    "vk_standard_sample_locations.h",
-    "vk_sync.c",
-    "vk_sync.h",
-    "vk_sync_binary.c",
-    "vk_sync_binary.h",
-    "vk_sync_dummy.c",
-    "vk_sync_dummy.h",
-    "vk_sync_timeline.c",
-    "vk_sync_timeline.h",
-    "vk_synchronization2.c",
-  ]
+    "vk_magma_syncobj.h"
+  ] + runtime_sources + runtime_headers
+
+  configs = [ "//build/config:Wno-strict-prototypes" ]
+}
+
+mesa_source_set("zircon") {
+  public_configs = [ ":common" ]
+
+  deps = [ ":generated" ]
+  public_deps = runtime_public_deps
+
+  sources = [
+    "$target_gen_dir/vk_cmd_enqueue_entrypoints.c",
+    "$target_gen_dir/vk_cmd_queue.c",
+    "$target_gen_dir/vk_common_entrypoints.c",
+    "$target_gen_dir/vk_dispatch_trampolines.c",
+    "$target_gen_dir/vk_physical_device_features.c",
+  ] + runtime_sources + runtime_headers
 
   configs = [ "//build/config:Wno-strict-prototypes" ]
 }
diff --git a/src/vulkan/runtime/vk_semaphore.c b/src/vulkan/runtime/vk_semaphore.c
index a83852f..5e9ab93 100644
--- a/src/vulkan/runtime/vk_semaphore.c
+++ b/src/vulkan/runtime/vk_semaphore.c
@@ -647,6 +647,6 @@
    return VK_SUCCESS;
 }
 
-#else /* Zircon */
+#else  /* Zircon */
 #endif  /* defined(USE_MAGMA) */
-#endif /* defined(__Fuchsia__) */
+#endif  /* defined(__Fuchsia__) */