adds init flag entry point, currently prints flags
disable the BT apex since it's not shipped yet (won't be for a while)
and there are a bajillion rust libraries we'd need to add apex
availibility to.
Bug:
171749953
Tag: #gd-refactor
Test: gd/cert/run --rhost SimpleHalTest
Change-Id: I54cffe93d5819ffdc8229aef7be23f260483ab66
apex {
name: "com.android.bluetooth.updatable",
+ enabled: false,
manifest: "apex_manifest.json",
"BluetoothGeneratedDumpsysDataSchema_h",
"BluetoothGeneratedDumpsysBundledSchema_h",
"BluetoothGeneratedPackets_h",
+ "libbt_common_bridge_header",
],
shared_libs: [
"libchrome",
],
static_libs: [
"libbluetooth-protos",
- ]
+ "libbluetooth_rust_interop",
+ "libbt_common_ffi",
+ "libcxxbridge05",
+ ],
+}
+
+cc_library_static {
+ name: "libbluetooth_rust_interop",
+ generated_headers: ["libbt_common_bridge_header"],
+ generated_sources: ["libbt_common_bridge_code"],
+ cflags: [
+ "-Wno-unused-const-variable",
+ ],
+ host_supported: true,
+ apex_available: [
+ "//apex_available:platform",
+ "com.android.bluetooth.updatable",
+ ],
+ static_libs: [
+ "libbt_common_ffi",
+ ],
}
cc_library {
#include "common/strings.h"
#include "os/log.h"
+#include "src/init_flags.rs.h"
namespace bluetooth {
namespace common {
}
void InitFlags::Load(const char** flags) {
+ rust::Vec<rust::String> rusted_flags = rust::Vec<rust::String>();
+ while (flags != nullptr && *flags != nullptr) {
+ rusted_flags.push_back(rust::String(*flags));
+ flags++;
+ }
+ init_flags_load(std::move(rusted_flags));
+
SetAll(false);
while (flags != nullptr && *flags != nullptr) {
std::string flag_element = *flags;
"libtokio",
"libnix",
"liblog_rust",
+ "libcxx",
+ ],
+ target: {
+ android: {
+ rustlibs: [
+ "libandroid_logger",
+ ],
+ },
+ host: {
+ rustlibs: [
+ "libenv_logger",
+ ],
+ },
+ },
+ host_supported: true,
+}
+
+rust_ffi_static {
+ name: "libbt_common_ffi",
+ stem: "libbt_common",
+ crate_name: "bt_common",
+ srcs: ["src/lib.rs"],
+ edition: "2018",
+ rustlibs: [
+ "libtokio",
+ "libnix",
+ "liblog_rust",
+ "libcxx",
],
target: {
android: {
"libnix",
"liblog_rust",
"libenv_logger",
+ "libcxx",
],
}
+
+genrule {
+ name: "libbt_common_bridge_header",
+ tools: ["cxxbridge"],
+ cmd: "$(location cxxbridge) $(in) --header > $(out)",
+ srcs: ["src/init_flags.rs"],
+ out: ["src/init_flags.rs.h"],
+}
+
+genrule {
+ name: "libbt_common_bridge_code",
+ tools: ["cxxbridge"],
+ cmd: "$(location cxxbridge) $(in) >> $(out)",
+ srcs: ["src/init_flags.rs"],
+ out: ["init_flags.cc"],
+}
+
+
--- /dev/null
+use log::error;
+
+#[cxx::bridge(namespace = bluetooth::common)]
+mod ffi {
+ extern "Rust" {
+ fn init_flags_load(flags: Vec<String>);
+ }
+}
+
+fn init_flags_load(flags: Vec<String>) {
+ crate::init_logging();
+
+ for flag in flags {
+ error!("hello from rust: {}", flag);
+ }
+}
#[macro_use]
mod asserts;
+mod init_flags;
+
/// Inits logging for Android
#[cfg(target_os = "android")]
pub fn init_logging() {
"libg722codec",
"libudrv-uipc",
"libbluetooth_gd", // Gabeldorsche
+ "libbluetooth_rust_interop",
+ "libbt_common_ffi",
+ "libcxxbridge05",
],
whole_static_libs: [
"libbt-bta",