GN: Wayland build overrides

Introduce //build_overrides/wayland.gni to simplify the management of
the wayland dependencies. Also, include Wayland sources only when
relative ozone platform is enabled.

Bug: chromium:1327041
Bug: angleproject:7409
Change-Id: Iccac3a66359cbda7919b2d7aa9a401f397180cd9
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/66408
Presubmit-Ready: Yuly Novikov <ynovikov@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Yuly Novikov <ynovikov@google.com>
Kokoro-Result: kokoro <noreply+kokoro@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
Commit-Queue: Yuly Novikov <ynovikov@google.com>
diff --git a/build_overrides/wayland.gni b/build_overrides/wayland.gni
new file mode 100644
index 0000000..21e575c
--- /dev/null
+++ b/build_overrides/wayland.gni
@@ -0,0 +1,18 @@
+# Copyright 2022 The SwiftShader Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+ozone_platform_wayland = true
+use_system_libwayland = true
+# SwiftShader has no wayland third-party dir
+wayland_gn_dir = ""
diff --git a/src/WSI/BUILD.gn b/src/WSI/BUILD.gn
index 243729b..3910345 100644
--- a/src/WSI/BUILD.gn
+++ b/src/WSI/BUILD.gn
@@ -13,13 +13,7 @@
 # limitations under the License.
 
 import("../swiftshader.gni")
-
-if (is_linux) {
-  import("//build/config/ozone.gni")
-  if (ozone_platform_wayland) {
-    import("//third_party/wayland/features.gni")
-  }
-}
+import("//build_overrides/wayland.gni")
 
 config("WSI_metal_weak_framework") {
   if (is_mac) {
@@ -42,15 +36,20 @@
 
   if (is_linux) {
     sources += [
-      "WaylandSurfaceKHR.cpp",
-      "WaylandSurfaceKHR.hpp",
       "XcbSurfaceKHR.cpp",
       "XcbSurfaceKHR.hpp",
-      "libWaylandClient.cpp",
-      "libWaylandClient.hpp",
       "libXCB.cpp",
       "libXCB.hpp",
     ]
+
+    if (ozone_platform_wayland) {
+      sources += [
+        "WaylandSurfaceKHR.cpp",
+        "WaylandSurfaceKHR.hpp",
+        "libWaylandClient.cpp",
+        "libWaylandClient.hpp",
+      ]
+    }
   }
 
   if (is_win) {
@@ -85,9 +84,9 @@
     "../Vulkan:swiftshader_libvulkan_headers",
   ]
 
-  if (defined(use_system_libwayland) && !use_system_libwayland) {
-    # Use chromium third-party targets
-    deps += [ "//third_party/wayland:wayland_client" ]
+  if (is_linux && !use_system_libwayland) {
+    # Use third-party targets
+    deps += [ "$wayland_gn_dir:wayland_client" ]
   }
 
   configs = [ "../Vulkan:swiftshader_libvulkan_private_config" ]