Bazel: Do not use cc_shared_library

It looks that the cc_shared_libary function will not link in the
objc_library dependencies. This in turn will result in missing symbols
when attempting to load the dylib inside of qemu.

We now use the "old" version of using cc_binary to create the dylib.
This requires us to slightly rewrite the rules to make sure all symbols
are present.

The bug contains additional google internal background information.

Test: Can launch qemu with gfxstream on mac os
Bug: 331235218
Change-Id: Ia634f9d6e1f9495d288a7c751ab176d33eb9247f
diff --git a/host/BUILD.bazel b/host/BUILD.bazel
index a26de91..9942825 100644
--- a/host/BUILD.bazel
+++ b/host/BUILD.bazel
@@ -52,6 +52,11 @@
         "EMUGL_BUILD",
         "GFXSTREAM_ENABLE_HOST_GLES=1",
     ],
+    sdk_frameworks = [
+        "AppKit",
+        "QuartzCore",
+        "IOSurface",
+    ],
     deps = [
         ":gfxstream_backend_headers",
         "//external/angle:angle-headers",
@@ -112,12 +117,14 @@
         ".",
         "gl",
     ],
+    linkstatic = True,
     visibility = ["//visibility:public"],
     deps = [
         ":gfxstream_backend_headers",
         "//hardware/google/aemu/base:aemu-base",
         "//hardware/google/aemu/base:aemu-base-metrics",
         "//hardware/google/aemu/host-common:aemu-host-common",
+        "//hardware/google/aemu/host-common:logging",
         "//hardware/google/aemu/snapshot:aemu-snapshot",
         "//hardware/google/gfxstream:gfxstream-gl-host-common-headers",
         "//hardware/google/gfxstream/host/apigen-codec-common",
@@ -135,7 +142,12 @@
         "//hardware/google/gfxstream/host/magma:magma-headers",
         "//hardware/google/gfxstream/host/renderControl_dec",
         "//hardware/google/gfxstream/host/vulkan:gfxstream-vulkan-server",
-    ],
+    ] + select({
+        "@platforms//os:macos": [
+            ":gfxstream_backend_static-darwin",
+        ],
+        "//conditions:default": [],
+    }),
 )
 
 cc_library(
@@ -153,16 +165,40 @@
         "BUILDING_EMUGL_COMMON_SHARED",
         "WIN32_LEAN_AND_MEAN",
     ],
+    linkstatic = True,
     deps = [
         ":gfxstream_backend_static",
+        "//hardware/google/aemu/base:aemu-base",
+        "//hardware/google/aemu/base:aemu-base-metrics",
         "//hardware/google/aemu/host-common:aemu-host-common-product-feature-override",
         "//hardware/google/gfxstream:gfxstream-gl-host-common-headers",
         "//hardware/google/gfxstream/common/utils:gfxstream_common_utils",
+        "//hardware/google/gfxstream/host/gl:gfxstream-gl-host-common",
     ],
 )
 
-cc_shared_library(
+cc_binary(
     name = "gfxstream_backend",
-    visibility = ["//visibility:public"],
-    deps = [":gfxstream_backend_shared"],
+    srcs = [
+        "render_api.cpp",
+        "virtio-gpu-gfxstream-renderer.cpp",
+    ],
+    linkshared = True,
+    deps = [
+        ":gfxstream_backend_static",
+        "//hardware/google/aemu/base:aemu-base",
+        "//hardware/google/aemu/base:aemu-base-metrics",
+        "//hardware/google/aemu/host-common:aemu-host-common-product-feature-override",
+        "//hardware/google/gfxstream:gfxstream-gl-host-common-headers",
+        "//hardware/google/gfxstream/common/utils:gfxstream_common_utils",
+        "//hardware/google/gfxstream/host/gl:gfxstream-gl-host-common",
+    ],
 )
+
+# Note: It looks like cc_shared_library refuses to include objc_library
+# b/331235218
+# cc_shared_library(
+#     name = "gfxstream_backend",
+#     visibility = ["//visibility:public"],
+#     deps = [":gfxstream_backend_shared"],
+# )