• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Use of this source code is governed by a BSD-style license that can be
2// found in the LICENSE file.
3
4package {
5    default_applicable_licenses: ["external_minigbm_license"],
6}
7
8// Added automatically by a large-scale-change that took the approach of
9// 'apply every license found to every target'. While this makes sure we respect
10// every license restriction, it may not be entirely correct.
11//
12// e.g. GPL in an MIT project might only apply to the contrib/ directory.
13//
14// Please consider splitting the single license below into multiple licenses,
15// taking care not to lose any license_kind information, and overriding the
16// default license using the 'licenses: [...]' property on targets as needed.
17//
18// For unused files, consider creating a 'fileGroup' with "//visibility:private"
19// to attach the license to, and including a comment whether the files may be
20// used in the current project.
21// See: http://go/android-license-faq
22license {
23    name: "external_minigbm_license",
24    visibility: [":__subpackages__"],
25    license_kinds: [
26        "SPDX-license-identifier-Apache-2.0",
27        "SPDX-license-identifier-BSD",
28        "SPDX-license-identifier-MIT",
29    ],
30    license_text: [
31        "LICENSE",
32    ],
33}
34
35filegroup {
36    name: "minigbm_core_files",
37
38    srcs: [
39        "amdgpu.c",
40        "backend_mock.c",
41        "drv.c",
42        "drv_array_helpers.c",
43        "drv_helpers.c",
44        "dumb_driver.c",
45        "i915.c",
46        "mediatek.c",
47        "msm.c",
48        "rockchip.c",
49        "vc4.c",
50        "virtgpu.c",
51        "virtgpu_cross_domain.c",
52        "virtgpu_virgl.c",
53        "xe.c",
54    ],
55}
56
57filegroup {
58    name: "minigbm_gralloc_common_files",
59
60    srcs: [
61        "cros_gralloc/cros_gralloc_buffer.cc",
62        "cros_gralloc/cros_gralloc_driver.cc",
63        "cros_gralloc/cros_gralloc_helpers.cc",
64    ],
65}
66
67filegroup {
68    name: "minigbm_gralloc0_files",
69    srcs: ["cros_gralloc/gralloc0/gralloc0.cc"],
70}
71
72generic_cflags = ["-DHAS_DMABUF_SYSTEM_HEAP"]
73intel_cflags = [
74    "-DDRV_I915",
75    "-DDRV_XE",
76]
77meson_cflags = ["-DDRV_MESON"]
78msm_cflags = [
79    "-DDRV_MSM",
80    "-DHAS_DMABUF_SYSTEM_HEAP",
81    "-DQCOM_DISABLE_COMPRESSED_NV12",
82]
83arcvm_cflags = ["-DVIRTIO_GPU_NEXT"]
84
85cc_defaults {
86    name: "minigbm_defaults",
87
88    cflags: [
89        "-D_FILE_OFFSET_BITS=64",
90        "-D_GNU_SOURCE=1",
91        "-Wall",
92        "-Wcast-align",
93        "-Wcast-qual",
94        "-Wno-unused-parameter",
95        "-Wpointer-arith",
96        "-Wsign-compare",
97    ] + select(soong_config_variable("minigbm", "platform"), {
98        "generic": generic_cflags,
99        "intel": intel_cflags,
100        "meson": meson_cflags,
101        "msm": msm_cflags,
102        "arcvm": arcvm_cflags,
103        default: [],
104    }),
105
106    product_variables: {
107        platform_sdk_version: {
108            cflags: ["-DANDROID_API_LEVEL=%d"],
109        },
110    },
111}
112
113cc_library_headers {
114    name: "minigbm_headers",
115    host_supported: true,
116    vendor_available: true,
117    export_include_dirs: ["."],
118}
119
120cc_defaults {
121    name: "minigbm_cros_gralloc_defaults",
122
123    defaults: ["minigbm_defaults"],
124
125    header_libs: [
126        "libhardware_headers",
127        "libnativebase_headers",
128        "libsystem_headers",
129        "minigbm_headers",
130    ],
131
132    static_libs: ["libarect"],
133
134    vendor: true,
135
136    shared_libs: [
137        "libcutils",
138        "libdmabufheap",
139        "libdrm",
140        "libgralloctypes",
141        "liblog",
142        "libnativewindow",
143        "libsync",
144    ],
145}
146
147cc_defaults {
148    name: "minigbm_cros_gralloc_library_defaults",
149
150    defaults: ["minigbm_cros_gralloc_defaults"],
151    srcs: [
152        ":minigbm_core_files",
153        ":minigbm_gralloc_common_files",
154    ],
155}
156
157cc_defaults {
158    name: "minigbm_cros_gralloc0_defaults",
159
160    defaults: ["minigbm_cros_gralloc_defaults"],
161    relative_install_path: "hw",
162
163    srcs: [":minigbm_gralloc0_files"],
164}
165
166cc_library {
167    name: "libgbm",
168    defaults: ["minigbm_defaults"],
169    host_supported: true,
170    min_sdk_version: "34",
171
172    srcs: [
173        ":minigbm_core_files",
174        "gbm.c",
175        "gbm_helpers.c",
176        "minigbm_helpers.c",
177    ],
178
179    target: {
180        host: {
181            // Avoid linking to another host copy of libdrm; this library will cause
182            // binary GPU drivers to be loaded from the host, which might be linked
183            // to a system copy of libdrm, which conflicts with the AOSP one
184            allow_undefined_symbols: true,
185            header_libs: ["libdrm_headers"],
186        },
187        android: {
188            shared_libs: [
189                "libcutils",
190                "liblog",
191            ],
192            static_libs: [
193                "libdrm",
194            ],
195        },
196    },
197    apex_available: [
198        "//apex_available:anyapex",
199        "//apex_available:platform",
200    ],
201    vendor_available: true,
202    product_available: true,
203
204    export_include_dirs: ["."],
205}
206
207// Rust bindings to minigbm, generated in a way compatible with gbm crate.
208rust_bindgen {
209    name: "libgbm_sys",
210    crate_name: "gbm_sys",
211    wrapper_src: "rust/gbm_wrapper.h",
212    source_stem: "bindings",
213    bindgen_flags: [
214        "--allowlist-function=^gbm_.*$",
215        "--allowlist-type=^gbm_.*$",
216        "--allowlist-var=GBM_.*|gbm_.*$",
217        "--blocklist-type=__BINDGEN_TMP_.*",
218        "--constified-enum-module=^gbm_.*$",
219    ],
220    shared_libs: ["libgbm"],
221    host_supported: true,
222    vendor_available: true,
223    product_available: true,
224    apex_available: [
225        "//apex_available:anyapex",
226        "//apex_available:platform",
227    ],
228    visibility: [
229        "//external/rust/android-crates-io/crates/gbm",
230        "//system/cros-codecs",
231    ],
232}
233
234// Generic
235cc_library_shared {
236    name: "libminigbm_gralloc",
237    defaults: ["minigbm_cros_gralloc_library_defaults"],
238    cflags: generic_cflags,
239}
240
241cc_library_shared {
242    name: "gralloc.minigbm",
243    defaults: ["minigbm_cros_gralloc0_defaults"],
244    shared_libs: ["libminigbm_gralloc"],
245}
246
247cc_library_headers {
248    name: "libminigbm_gralloc_headers",
249    host_supported: true,
250    vendor_available: true,
251    export_include_dirs: ["cros_gralloc"],
252    visibility: [
253        "//device/generic/goldfish-opengl/system/hwc3:__subpackages__",
254    ],
255}
256
257// Intel
258cc_library_shared {
259    name: "libminigbm_gralloc_intel",
260    defaults: ["minigbm_cros_gralloc_library_defaults"],
261    cflags: intel_cflags,
262    enabled: false,
263    arch: {
264        x86: {
265            enabled: true,
266        },
267        x86_64: {
268            enabled: true,
269        },
270    },
271}
272
273cc_library_shared {
274    name: "gralloc.minigbm_intel",
275    defaults: ["minigbm_cros_gralloc0_defaults"],
276    shared_libs: ["libminigbm_gralloc_intel"],
277    enabled: false,
278    arch: {
279        x86: {
280            enabled: true,
281        },
282        x86_64: {
283            enabled: true,
284        },
285    },
286}
287
288// Meson
289cc_library_shared {
290    name: "libminigbm_gralloc_meson",
291    defaults: ["minigbm_cros_gralloc_library_defaults"],
292    cflags: meson_cflags,
293}
294
295cc_library_shared {
296    name: "gralloc.minigbm_meson",
297    defaults: ["minigbm_cros_gralloc0_defaults"],
298    shared_libs: ["libminigbm_gralloc_meson"],
299}
300
301// MSM
302cc_library_shared {
303    name: "libminigbm_gralloc_msm",
304    defaults: ["minigbm_cros_gralloc_library_defaults"],
305    cflags: msm_cflags,
306}
307
308cc_library_shared {
309    name: "gralloc.minigbm_msm",
310    defaults: ["minigbm_cros_gralloc0_defaults"],
311    shared_libs: ["libminigbm_gralloc_msm"],
312}
313
314// ARCVM
315cc_library_shared {
316    name: "libminigbm_gralloc_arcvm",
317    defaults: ["minigbm_cros_gralloc_library_defaults"],
318    cflags: arcvm_cflags,
319}
320
321cc_library_shared {
322    name: "gralloc.minigbm_arcvm",
323    defaults: ["minigbm_cros_gralloc0_defaults"],
324    shared_libs: ["libminigbm_gralloc_arcvm"],
325}
326