1cc_library(
2    name = "gfxstream_backend_headers",
3    hdrs = glob(["include/**/*.h"]),
4    copts = ["-fno-exceptions"],
5    includes = ["include"],
6    visibility = ["//visibility:public"],
7)
8
9cc_library(
10    name = "gfxstream_host_headers",
11    hdrs = [
12        "compressedTextureFormats/AstcCpuDecompressor.h",
13    ] + glob([
14        "*.h",
15        "gl/*.h",
16    ]),
17    copts = ["-fno-exceptions"],
18    includes = ["."],
19    visibility = [":__subpackages__"],
20)
21
22cc_library(
23    name = "gfxstream-compressedTextures",
24    srcs = ["compressedTextureFormats/AstcCpuDecompressorNoOp.cpp"] + glob(["compressedTextureFormats/*.h"]),
25    hdrs = [
26        "compressedTextureFormats/AstcCpuDecompressor.h",
27    ],
28    copts = ["-fno-exceptions"],
29    includes = ["."],
30    visibility = ["//visibility:public"],
31    deps = [
32        "//hardware/google/gfxstream/common/etc:gfxstream_etc",
33    ],
34)
35
36cc_test(
37    name = "gfxstream-compressedTextures_unittests",
38    srcs = ["compressedTextureFormats/AstcCpuDecompressor_unittest.cpp"],
39    copts = ["-fno-exceptions"],
40    deps = [
41        ":gfxstream-compressedTextures",
42        "//hardware/google/aemu/base:aemu-base",
43        "//hardware/google/aemu/host-common:logging",
44        "@com_google_googletest//:gtest_main",
45    ],
46)
47
48objc_library(
49    name = "gfxstream_backend_static-darwin",
50    srcs = [
51        "GlesCompat.h",
52        "NativeSubWindow.h",
53        "NativeSubWindow_cocoa.mm",
54    ],
55    copts = [
56        "-fno-exceptions",
57        "-Wno-deprecated-declarations",
58    ],
59    defines = [
60        "EMUGL_BUILD",
61        "GFXSTREAM_ENABLE_HOST_GLES=1",
62    ],
63    sdk_frameworks = [
64        "AppKit",
65        "QuartzCore",
66        "IOSurface",
67    ],
68    deps = [
69        ":gfxstream_backend_headers",
70        "//external/angle:angle-headers",
71        "//hardware/google/gfxstream:gfxstream-gl-host-common-headers",
72    ],
73)
74
75cc_library(
76    name = "gfxstream_backend_static",
77    srcs = [
78        "Buffer.cpp",
79        "ChannelStream.cpp",
80        "ColorBuffer.cpp",
81        "DisplaySurface.cpp",
82        "DisplaySurfaceUser.cpp",
83        "ExternalObjectManager.cpp",
84        "FrameBuffer.cpp",
85        "GfxStreamAgents.cpp",
86        "Hwc2.cpp",
87        "PostWorker.cpp",
88        "PostWorkerGl.cpp",
89        "ReadBuffer.cpp",
90        "RenderChannelImpl.cpp",
91        "RenderControl.cpp",
92        "RenderLibImpl.cpp",
93        "RenderThread.cpp",
94        "RenderThreadInfo.cpp",
95        "RenderThreadInfoGl.cpp",
96        "RenderThreadInfoMagma.cpp",
97        "RenderWindow.cpp",
98        "RendererImpl.cpp",
99        "RingStream.cpp",
100        "SyncThread.cpp",
101        "VirtioGpuContext.cpp",
102        "VirtioGpuFrontend.cpp",
103        "VirtioGpuResource.cpp",
104        "VirtioGpuRingBlob.cpp",
105        "VirtioGpuTimelines.cpp",
106        "VsyncThread.cpp",
107    ] + select({
108        "@platforms//os:macos": [],
109        "@platforms//os:windows": ["NativeSubWindow_win32.cpp"],
110        "@platforms//os:linux": ["NativeSubWindow_x11.cpp"],
111        "//conditions:default": [],
112    }) + glob([
113        "*.h",
114    ]),
115    copts = [
116        "-Wno-return-type-c-linkage",
117        "-Wno-extern-c-compat",
118        "-fno-exceptions",
119    ],
120    defines = [
121        "EMUGL_BUILD",
122        "GFXSTREAM_ENABLE_HOST_GLES=1",
123    ] + select({
124        "@platforms//os:windows": [
125            "WIN32_LEAN_AND_MEAN",
126        ],
127        "//conditions:default": [],
128    }),
129    includes = [
130        ".",
131        "gl",
132    ],
133    linkstatic = True,
134    visibility = ["//visibility:public"],
135    deps = [
136        ":gfxstream_backend_headers",
137        "//hardware/google/aemu/base:aemu-base",
138        "//hardware/google/aemu/base:aemu-base-metrics",
139        "//hardware/google/aemu/host-common:aemu-host-common",
140        "//hardware/google/aemu/host-common:logging",
141        "//hardware/google/aemu/snapshot:aemu-snapshot",
142        "//hardware/google/gfxstream:gfxstream-gl-host-common-headers",
143        "//hardware/google/gfxstream/host/apigen-codec-common",
144        "//hardware/google/gfxstream/host/backend:gfxstream_backend",
145        "//hardware/google/gfxstream/host/features:gfxstream_features",
146        "//hardware/google/gfxstream/host/gl:EGL_translator_static",
147        "//hardware/google/gfxstream/host/gl:OpenGLESDispatch",
148        "//hardware/google/gfxstream/host/gl:gfxstream-gl-host-common",
149        "//hardware/google/gfxstream/host/gl:gfxstream-gl-server",
150        "//hardware/google/gfxstream/host/gl:gl-common-headers",
151        "//hardware/google/gfxstream/host/gl:gl_headers",
152        "//hardware/google/gfxstream/host/gl:gles1_dec",
153        "//hardware/google/gfxstream/host/gl:gles2_dec",
154        "//hardware/google/gfxstream/host/gl/glestranslator/GLES_CM:GLES_CM_translator_static",
155        "//hardware/google/gfxstream/host/magma:gfxstream-magma-server",
156        "//hardware/google/gfxstream/host/magma:magma-headers",
157        "//hardware/google/gfxstream/host/renderControl_dec",
158        "//hardware/google/gfxstream/host/tracing:gfxstream_host_tracing",
159        "//hardware/google/gfxstream/host/vulkan:gfxstream-vulkan-server",
160    ] + select({
161        "@platforms//os:macos": [
162            ":gfxstream_backend_static-darwin",
163        ],
164        "//conditions:default": [],
165    }),
166)
167
168cc_library(
169    name = "gfxstream_backend_shared",
170    srcs = [
171        "render_api.cpp",
172        "virtio-gpu-gfxstream-renderer.cpp",
173    ],
174    copts = [
175        "-fno-exceptions",
176        "-Wno-extern-c-compat",
177        "-Wno-return-type-c-linkage",
178    ],
179    defines = [
180        "EMUGL_BUILD",
181        "BUILDING_EMUGL_COMMON_SHARED",
182        "WIN32_LEAN_AND_MEAN",
183    ],
184    linkstatic = True,
185    visibility = ["//visibility:public"],
186    deps = [
187        ":gfxstream_backend_static",
188        "//hardware/google/aemu/base:aemu-base",
189        "//hardware/google/aemu/base:aemu-base-metrics",
190        "//hardware/google/aemu/host-common:aemu-host-common-product-feature-override",
191        "//hardware/google/gfxstream:gfxstream-gl-host-common-headers",
192        "//hardware/google/gfxstream/common/utils:gfxstream_common_utils",
193        "//hardware/google/gfxstream/host/gl:gfxstream-gl-host-common",
194    ],
195)
196
197cc_binary(
198    name = "gfxstream_backend",
199    srcs = [
200        "render_api.cpp",
201        "virtio-gpu-gfxstream-renderer.cpp",
202    ],
203    copts = ["-fno-exceptions"],
204    linkshared = True,
205    visibility = ["//visibility:public"],
206    deps = [
207        ":gfxstream_backend_static",
208        "//hardware/google/aemu/base:aemu-base",
209        "//hardware/google/aemu/base:aemu-base-metrics",
210        "//hardware/google/aemu/host-common:aemu-host-common-product-feature-override",
211        "//hardware/google/gfxstream:gfxstream-gl-host-common-headers",
212        "//hardware/google/gfxstream/common/utils:gfxstream_common_utils",
213        "//hardware/google/gfxstream/host/gl:gfxstream-gl-host-common",
214    ],
215)
216
217# Note: It looks like cc_shared_library refuses to include objc_library
218# b/331235218
219# cc_shared_library(
220#     name = "gfxstream_backend",
221#     visibility = ["//visibility:public"],
222#     deps = [":gfxstream_backend_shared"],
223# )
224