minigbm: add bindgen-generated Rust bindings
This provides the bindings necessary to use the Rust gbm crate within
Android source tree. Bindgen flags used in the rust_bindgen definition,
as well as the workaround described in wrapper.h were based on upstream
gbm-sys crate's build.rs [1].
Looking at other rust_bindgen modules, they are generally defined
alongside the native module they provide bindings to.
Details: go/drm-gbm-rust-crates-for-android
[1] 606c4260e0/gbm-sys/build.rs (L78)
Bug: b/328181805
Test: lunch aosp_cf_x86_64_only_phone-trunk_staging-userdebug && m
Test: m libgbm_sys
Change-Id: I3065f7fe35f4a86b72ac90c34476da6304155daf
This commit is contained in:
parent
66c52b3f63
commit
65742c01dd
2 changed files with 57 additions and 2 deletions
31
Android.bp
31
Android.bp
|
|
@ -163,7 +163,7 @@ cc_library {
|
|||
android: {
|
||||
shared_libs: [
|
||||
"libcutils",
|
||||
"liblog"
|
||||
"liblog",
|
||||
],
|
||||
static_libs: [
|
||||
"libdrm",
|
||||
|
|
@ -172,13 +172,40 @@ cc_library {
|
|||
},
|
||||
apex_available: [
|
||||
"//apex_available:platform",
|
||||
"com.android.virt",
|
||||
"//apex_available:anyapex",
|
||||
],
|
||||
vendor_available: true,
|
||||
product_available: true,
|
||||
|
||||
export_include_dirs: ["."],
|
||||
}
|
||||
|
||||
// Rust bindings to minigbm, generated in a way compatible with gbm crate.
|
||||
rust_bindgen {
|
||||
name: "libgbm_sys",
|
||||
crate_name: "gbm_sys",
|
||||
wrapper_src: "rust/gbm_wrapper.h",
|
||||
source_stem: "bindings",
|
||||
bindgen_flags: [
|
||||
"--blocklist-type=__BINDGEN_TMP_.*",
|
||||
"--allowlist-type=^gbm_.*$",
|
||||
"--allowlist-function=^gbm_.*$",
|
||||
"--allowlist-var=GBM_.*|gbm_.*$",
|
||||
"--constified-enum-module=^gbm_.*$",
|
||||
],
|
||||
shared_libs: ["libgbm"],
|
||||
host_supported: true,
|
||||
vendor_available: true,
|
||||
product_available: true,
|
||||
apex_available: [
|
||||
"//apex_available:anyapex",
|
||||
"//apex_available:platform",
|
||||
],
|
||||
visibility: [
|
||||
"//external/rust/crates/gbm",
|
||||
],
|
||||
}
|
||||
|
||||
// Generic
|
||||
cc_library_shared {
|
||||
name: "libminigbm_gralloc",
|
||||
|
|
|
|||
28
rust/gbm_wrapper.h
Normal file
28
rust/gbm_wrapper.h
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*/
|
||||
|
||||
#include <gbm.h>
|
||||
|
||||
// bindgen doesn't create constants for macros that expand to other macros
|
||||
// https://github.com/Smithay/gbm.rs/blob/606c4260e0147256fb5c2901bbe837c0dc7d9f2d/gbm-sys/build.rs#L16
|
||||
|
||||
const unsigned int __BINDGEN_TMP_GBM_BO_IMPORT_WL_BUFFER = GBM_BO_IMPORT_WL_BUFFER;
|
||||
#undef GBM_BO_IMPORT_WL_BUFFER
|
||||
const unsigned int GBM_BO_IMPORT_WL_BUFFER = __BINDGEN_TMP_GBM_BO_IMPORT_WL_BUFFER;
|
||||
#define GBM_BO_IMPORT_WL_BUFFER GBM_BO_IMPORT_WL_BUFFER
|
||||
|
||||
const unsigned int __BINDGEN_TMP_GBM_BO_IMPORT_EGL_IMAGE = GBM_BO_IMPORT_EGL_IMAGE;
|
||||
#undef GBM_BO_IMPORT_EGL_IMAGE
|
||||
const unsigned int GBM_BO_IMPORT_EGL_IMAGE = __BINDGEN_TMP_GBM_BO_IMPORT_EGL_IMAGE;
|
||||
#define GBM_BO_IMPORT_EGL_IMAGE GBM_BO_IMPORT_EGL_IMAGE
|
||||
|
||||
const unsigned int __BINDGEN_TMP_GBM_BO_IMPORT_FD = GBM_BO_IMPORT_FD;
|
||||
#undef GBM_BO_IMPORT_FD
|
||||
const unsigned int GBM_BO_IMPORT_FD = __BINDGEN_TMP_GBM_BO_IMPORT_FD;
|
||||
#define GBM_BO_IMPORT_FD GBM_BO_IMPORT_FD
|
||||
|
||||
const unsigned int __BINDGEN_TMP_GBM_BO_IMPORT_FD_MODIFIER = GBM_BO_IMPORT_FD_MODIFIER;
|
||||
#undef GBM_BO_IMPORT_FD_MODIFIER
|
||||
const unsigned int GBM_BO_IMPORT_FD_MODIFIER = __BINDGEN_TMP_GBM_BO_IMPORT_FD_MODIFIER;
|
||||
#define GBM_BO_IMPORT_FD_MODIFIER GBM_BO_IMPORT_FD_MODIFIER
|
||||
Loading…
Add table
Add a link
Reference in a new issue