Switch to shared libraries.

When mesa is built out-of-tree it depends on the system
libwayland-client.so, so apps built in tree that use the
Vulkan Wayland swapchain should use the same client library
implementation.

Change-Id: I08187c45dc0be3ef400c8a69a7b757058b452784
Reviewed-on: https://fuchsia-review.googlesource.com/c/third_party/wayland/+/571756
Reviewed-by: David Reveman <reveman@google.com>
diff --git a/BUILD.gn b/BUILD.gn
index 7bd4750..627c5fc 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -36,11 +36,11 @@
 }
 
 group("client") {
-  public_deps = [ ":client_static" ]
+  public_deps = [ ":wayland-client" ]
 }
 
 group("server") {
-  public_deps = [ ":server_static" ]
+  public_deps = [ ":wayland-server" ]
 }
 
 group("client_headers") {
@@ -137,7 +137,7 @@
   configs += [ ":private_config" ]
 }
 
-source_set("client_static") {
+shared_library("wayland-client") {
   visibility = [ ":*" ]
   sources = [ "src/wayland-client.c" ]
   deps = [ ":common_static" ]
@@ -145,7 +145,7 @@
   configs += [ ":private_config" ]
 }
 
-source_set("server_static") {
+shared_library("wayland-server") {
   visibility = [ ":*" ]
   sources = [ "src/wayland-server.c" ]
   deps = [ ":common_static" ]
@@ -176,6 +176,7 @@
   visibility = [ ":*" ]
   protocol = "protocol/wayland.xml"
   output = "${target_gen_dir}/wayland-protocol.c"
+  for_export = true
 }
 
 wayland_protocol_header("protocol_client") {
diff --git a/wayland.gni b/wayland.gni
index 85dab7a..a5fe107 100644
--- a/wayland.gni
+++ b/wayland.gni
@@ -82,8 +82,7 @@
 }
 
 # Given a wayland protocol xml file, the wayland_protocol_code template generates protocol
-# marshalling code file using the 'private-code' argument as recommended in the wayland-scanner
-# documentation.
+# marshalling code file.
 template("wayland_protocol_code") {
   assert(defined(invoker.protocol),
          "${target_name} must have a 'protocol' property, e.g. 'wayland.xml'")
@@ -95,8 +94,13 @@
                            [
                              "protocol",
                              "output",
+                             "for_export",
                            ])
-    scanner_args = [ "private-code" ]
+    if (defined(for_export) && for_export) {
+      scanner_args = [ "public-code" ]
+    } else {
+      scanner_args = [ "private-code" ]
+    }
   }
   source_set("_${target_name}_source_set") {
     forward_variables_from(invoker, "*")