blob: d2cc3ae9e86a655dd006720bc6128e9f0af59dbf [file] [log] [blame]
package {
// See: http://go/android-license-faq
// A large-scale-change added 'default_applicable_licenses' to import
// all of the 'license_kinds' from "system_bt_license"
// to get the below license kinds:
// SPDX-license-identifier-Apache-2.0
default_applicable_licenses: ["system_bt_license"],
}
rust_defaults {
name: "libbluetooth_core_rs_defaults",
min_sdk_version: "Tiramisu",
dylib: {
enabled: false,
},
srcs: [
"src/lib.rs",
":bluetooth_core_rust_packets",
],
shared_libs: [
"libbase",
],
static_libs: [
"libbt_shim_bridge",
"libbt_shim_ffi",
"libchrome",
"libevent",
"libmodpb64",
],
proc_macros: [
"libasync_trait",
"libpaste",
],
rustlibs: [
"libanyhow",
"libbitflags",
"libbt_common_only_init_flags",
"libcxx",
"liblog_rust",
"libscopeguard",
// needed to work around duplicate symbols
// caused by bug in Soong
"libbt_shim",
],
whole_static_libs: [
"libbluetooth_core_rs_bridge",
],
features: [
// used to hide libbt_shim in Cargo builds, but
// expose it to Soong to work around linker bug
"via_android_bp",
],
target: {
android: {
shared_libs: [
"android.hardware.bluetooth@1.0",
"android.hardware.bluetooth@1.1",
"android.system.suspend-V1-ndk",
"android.system.suspend.control-V1-ndk",
"libbinder_ndk",
"libcutils",
"libhidlbase",
"libstatslog_bt",
"libutils",
],
},
},
apex_available: ["com.android.btservices"],
}
rust_library {
name: "libbluetooth_core_rs_for_facade",
crate_name: "bluetooth_core_rs_for_facade",
defaults: ["libbluetooth_core_rs_defaults"],
rustlibs: [
"libtokio",
],
host_supported: true,
}
rust_ffi_static {
name: "libbluetooth_core_rs",
crate_name: "bluetooth_core",
defaults: ["libbluetooth_core_rs_defaults"],
rustlibs: [
"libtokio",
],
target: {
android: {
rustlibs: [
"libandroid_logger",
],
},
},
host_supported: true,
}
rust_test_host {
name: "libbluetooth_core_rs_test",
defaults: ["libbluetooth_core_rs_defaults"],
rustlibs: [
"libtokio_for_test",
"libtokio_test",
],
}
cc_library_static {
name: "libbluetooth_core_rs_bridge",
defaults: ["bluetooth_cflags"],
srcs: [
"src/connection/ffi/connection_shim.cc",
"src/core/ffi/module.cc",
"src/gatt/ffi/gatt_shim.cc",
],
include_dirs: [
"packages/modules/Bluetooth/system",
"packages/modules/Bluetooth/system/gd",
"packages/modules/Bluetooth/system/include",
"packages/modules/Bluetooth/system/stack/include",
"packages/modules/Bluetooth/system/types",
],
export_include_dirs: ["."],
static_libs: [
"libbluetooth_hci_pdl",
"libbluetooth_log",
"libbt_shim_bridge",
"libbt_shim_ffi",
"libchrome",
"libflatbuffers-cpp",
],
generated_headers: [
"cxx-bridge-header",
"libbluetooth_core_rs_bridge_codegen_header",
"BluetoothGeneratedBundlerSchema_h_bfbs",
"BluetoothGeneratedDumpsysDataSchema_h",
],
export_generated_headers: [
"libbluetooth_core_rs_bridge_codegen_header",
],
host_supported: true,
generated_sources: ["libbluetooth_core_rs_bridge_codegen"],
apex_available: ["com.android.btservices"],
min_sdk_version: "Tiramisu",
// Bug: 286537287 this library gets linked with Rust objects but cross-language LTO
// isn't supported yet.
lto: {
never: true,
},
}
/// FFI codegen
///
/// The static library libbluetooth_core_rs_bridge is included by
/// libbluetooth_core_rs and depends on libbluetooth_core. libbluetooth
/// depends on libbluetooth_core_rs.
/// i.e.
/// libbluetooth -> {libbluetooth_core_rs, libbluetooth_core_rs_bridge} -> libbluetooth_core
///
/// Thus, FFI can be either:
/// * Rust to GD
/// * Legacy C++ to Rust
/// * Core to Rust only via injected callbacks (libbluetooth_core does not
/// depend on libbluetooth_core_rs)
/// * Legacy C++ to Rust can be made directly (as libbluetooth *does* depend
/// on libbluetooth_core_rs).
///
/// To add FFI for a new module, create an ffi.rs file, and add it to the filegroup below.
filegroup {
name: "libbluetooth_core_rs_ffi",
srcs: [
"src/connection/ffi.rs",
"src/core/ffi.rs",
"src/gatt/ffi.rs",
],
}
gensrcs {
name: "libbluetooth_core_rs_bridge_codegen_header",
tools: ["cxxbridge"],
cmd: "$(location cxxbridge) $(in) --header > $(out)",
srcs: [":libbluetooth_core_rs_ffi"],
output_extension: "rs.h",
export_include_dirs: ["."],
}
gensrcs {
name: "libbluetooth_core_rs_bridge_codegen",
tools: ["cxxbridge"],
cmd: "$(location cxxbridge) $(in) > $(out)",
srcs: [":libbluetooth_core_rs_ffi"],
output_extension: "cc",
}
genrule {
name: "bluetooth_core_rust_packets",
defaults: ["pdl_rust_noalloc_generator_defaults"],
srcs: ["src/packets.pdl"],
out: ["_packets.rs"],
}