diff options
Diffstat (limited to 'libs/binder/rust/Android.bp')
-rw-r--r-- | libs/binder/rust/Android.bp | 119 |
1 files changed, 119 insertions, 0 deletions
diff --git a/libs/binder/rust/Android.bp b/libs/binder/rust/Android.bp new file mode 100644 index 0000000000..49d3401a4f --- /dev/null +++ b/libs/binder/rust/Android.bp @@ -0,0 +1,119 @@ +package { + // See: http://go/android-license-faq + // A large-scale-change added 'default_applicable_licenses' to import + // all of the 'license_kinds' from "frameworks_native_license" + // to get the below license kinds: + // SPDX-license-identifier-Apache-2.0 + default_applicable_licenses: ["frameworks_native_license"], +} + +rust_library { + name: "libbinder_rs", + crate_name: "binder", + srcs: ["src/lib.rs"], + shared_libs: [ + "libutils", + ], + rustlibs: [ + "liblibc", + "libbinder_ndk_sys", + ], + host_supported: true, + target: { + darwin: { + enabled: false, + } + }, + apex_available: [ + "//apex_available:platform", + "com.android.virt", + ], +} + +rust_library { + name: "libbinder_ndk_sys", + crate_name: "binder_ndk_sys", + srcs: [ + "sys/lib.rs", + ":libbinder_ndk_bindgen", + ], + shared_libs: [ + "libbinder_ndk", + ], + host_supported: true, + target: { + darwin: { + enabled: false, + } + }, + apex_available: [ + "//apex_available:platform", + "com.android.virt", + ], + lints: "none", + clippy_lints: "none", +} + +rust_bindgen { + name: "libbinder_ndk_bindgen", + crate_name: "binder_ndk_bindgen", + wrapper_src: "sys/BinderBindings.hpp", + source_stem: "bindings", + bindgen_flags: [ + // Unfortunately the only way to specify the rust_non_exhaustive enum + // style for a type is to make it the default + "--default-enum-style", "rust_non_exhaustive", + // and then specify constified enums for the enums we don't want + // rustified + "--constified-enum", "android::c_interface::consts::.*", + + "--allowlist-type", "android::c_interface::.*", + "--allowlist-type", "AStatus", + "--allowlist-type", "AIBinder_Class", + "--allowlist-type", "AIBinder", + "--allowlist-type", "AIBinder_Weak", + "--allowlist-type", "AIBinder_DeathRecipient", + "--allowlist-type", "AParcel", + "--allowlist-type", "binder_status_t", + "--allowlist-function", ".*", + ], + shared_libs: [ + "libbinder_ndk", + ], + host_supported: true, + + // Currently necessary for host builds + // TODO(b/31559095): bionic on host should define this + target: { + host: { + cflags: [ + "-D__INTRODUCED_IN(n)=", + "-D__assert(a,b,c)=", + // We want all the APIs to be available on the host. + "-D__ANDROID_API__=10000", + ], + }, + darwin: { + enabled: false, + }, + }, + apex_available: [ + "//apex_available:platform", + "com.android.virt", + ], +} + +rust_test { + name: "libbinder_rs-internal_test", + crate_name: "binder", + srcs: ["src/lib.rs"], + test_suites: ["general-tests"], + auto_gen_config: true, + shared_libs: [ + "libbinder_ndk", + ], + rustlibs: [ + "liblibc", + "libbinder_ndk_sys", + ], +} |