GN: Expose Wayland surface extension on Linux

Set defines, add WaylandSurfaceKHR sources, and link against
libwayland-client.

Bug: chromium:1327041
Change-Id: I51858054e7ec29466f0fed380c73f34f64ceb567
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/65968
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
Kokoro-Result: kokoro <noreply+kokoro@google.com>
diff --git a/src/Vulkan/BUILD.gn b/src/Vulkan/BUILD.gn
index a8afc99..959aa45 100644
--- a/src/Vulkan/BUILD.gn
+++ b/src/Vulkan/BUILD.gn
@@ -21,6 +21,7 @@
   if (is_linux) {
     defines = [
       "VK_USE_PLATFORM_XCB_KHR",
+      "VK_USE_PLATFORM_WAYLAND_KHR",
       "VK_EXPORT=__attribute__((visibility(\"default\")))",
     ]
   } else if (is_chromeos) {
diff --git a/src/WSI/BUILD.gn b/src/WSI/BUILD.gn
index fef8517..03df427 100644
--- a/src/WSI/BUILD.gn
+++ b/src/WSI/BUILD.gn
@@ -13,6 +13,9 @@
 # limitations under the License.
 
 import("../swiftshader.gni")
+if (is_linux) {
+  import("//third_party/wayland/features.gni")
+}
 
 config("WSI_metal_weak_framework") {
   if (is_mac) {
@@ -35,8 +38,12 @@
 
   if (is_linux) {
     sources += [
+      "WaylandSurfaceKHR.cpp",
+      "WaylandSurfaceKHR.hpp",
       "XcbSurfaceKHR.cpp",
       "XcbSurfaceKHR.hpp",
+      "libWaylandClient.cpp",
+      "libWaylandClient.hpp",
       "libXCB.cpp",
       "libXCB.hpp",
     ]
@@ -74,5 +81,10 @@
     "../Vulkan:swiftshader_libvulkan_headers",
   ]
 
+  if (defined(use_system_libwayland) && !use_system_libwayland) {
+    # Use chromium third-party targets
+    deps += [ "//third_party/wayland:wayland_client" ]
+  }
+
   configs = [ "../Vulkan:swiftshader_libvulkan_private_config" ]
 }