Loading system/gd/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -352,6 +352,7 @@ cc_test { "libbluetooth_rust_interop", "libbt_shim_ffi", "libcxxbridge05", "libchrome", ], } Loading system/gd/rust/shim/Android.bp +56 −3 Original line number Diff line number Diff line Loading @@ -8,14 +8,33 @@ rust_ffi_static { "libbt_common", "libcxx", ], static_libs: [ "libbt_callbacks_cxx", ], host_supported: true, } cc_library_static { name: "libbluetooth_rust_interop", generated_headers: ["libbt_init_flags_bridge_header", "libbt_shim_bridge_header"], generated_sources: ["libbt_init_flags_bridge_code", "libbt_shim_bridge_code"], export_generated_headers: ["libbt_init_flags_bridge_header", "libbt_shim_bridge_header"], generated_headers: [ "libbt_init_flags_bridge_header", "libbt_shim_bridge_header", "libbt_hci_bridge_header", "cxx-bridge-header", ], generated_sources: [ "libbt_init_flags_bridge_code", "libbt_shim_bridge_code", "libbt_hci_bridge_code", ], export_generated_headers: [ "libbt_init_flags_bridge_header", "libbt_shim_bridge_header", "libbt_hci_bridge_header", "cxx-bridge-header", ], header_libs: ["libbt_callbacks_cxx_headers"], export_header_lib_headers: ["libbt_callbacks_cxx_headers"], cflags: [ "-Wno-unused-const-variable", ], Loading @@ -24,11 +43,31 @@ cc_library_static { "//apex_available:platform", "com.android.bluetooth.updatable", ], shared_libs: [ "libchrome", ], static_libs: [ "libbt_shim_ffi", ], } cc_library_static { name: "libbt_callbacks_cxx", header_libs: ["libbt_callbacks_cxx_headers"], srcs: ["callbacks/callbacks.cc"], generated_headers: ["libbt_hci_bridge_header", "cxx-bridge-header"], shared_libs: [ "libchrome", ], host_supported: true, } cc_library_headers { name: "libbt_callbacks_cxx_headers", local_include_dirs: ["callbacks"], host_supported: true, } genrule { name: "libbt_shim_bridge_header", tools: ["cxxbridge"], Loading Loading @@ -61,4 +100,18 @@ genrule { out: ["init_flags.cc"], } genrule { name: "libbt_hci_bridge_header", tools: ["cxxbridge"], cmd: "$(location cxxbridge) $(in) --header > $(out)", srcs: ["src/hci.rs"], out: ["src/hci.rs.h"], } genrule { name: "libbt_hci_bridge_code", tools: ["cxxbridge"], cmd: "$(location cxxbridge) $(in) >> $(out)", srcs: ["src/hci.rs"], out: ["hci.cc"], } system/gd/rust/shim/callbacks/callbacks.cc 0 → 100644 +1 −0 Original line number Diff line number Diff line #include "callbacks/callbacks.h" system/gd/rust/shim/callbacks/callbacks.h 0 → 100644 +26 −0 Original line number Diff line number Diff line #pragma once #include "base/callback.h" #include "rust/cxx.h" namespace bluetooth { namespace shim { namespace rust { class u8SliceCallback { public: u8SliceCallback(base::Callback<void(::rust::Slice<uint8_t>)> callback) : callback_(callback) {} void Run(::rust::Slice<uint8_t> value) const { callback_.Run(value); } private: base::Callback<void(::rust::Slice<uint8_t>)> callback_; }; } // namespace rust } // namespace shim } // namespace bluetooth #include "src/hci.rs.h" system/gd/rust/shim/src/hci.rs 0 → 100644 +35 −0 Original line number Diff line number Diff line //! Hci shim #[cxx::bridge(namespace = bluetooth::shim::rust)] mod ffi { extern "C" { include!("callbacks/callbacks.h"); type u8SliceCallback; fn Run(&self, data: &[u8]); } extern "Rust" { fn hci_set_acl_callback(callback: UniquePtr<u8SliceCallback>); fn hci_send_command(data: &[u8]); fn hci_send_acl(data: &[u8]); fn hci_register_event(event: u8, callback: UniquePtr<u8SliceCallback>); fn hci_register_le_event(subevent: u8, callback: UniquePtr<u8SliceCallback>); } } fn hci_send_command(_data: &[u8]) { } fn hci_send_acl(_data: &[u8]) { } fn hci_register_event(_event: u8, _callback: cxx::UniquePtr<ffi::u8SliceCallback>) { } fn hci_register_le_event(_subevent: u8, _callback: cxx::UniquePtr<ffi::u8SliceCallback>) { } fn hci_set_acl_callback(_callback: cxx::UniquePtr<ffi::u8SliceCallback>) { } Loading
system/gd/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -352,6 +352,7 @@ cc_test { "libbluetooth_rust_interop", "libbt_shim_ffi", "libcxxbridge05", "libchrome", ], } Loading
system/gd/rust/shim/Android.bp +56 −3 Original line number Diff line number Diff line Loading @@ -8,14 +8,33 @@ rust_ffi_static { "libbt_common", "libcxx", ], static_libs: [ "libbt_callbacks_cxx", ], host_supported: true, } cc_library_static { name: "libbluetooth_rust_interop", generated_headers: ["libbt_init_flags_bridge_header", "libbt_shim_bridge_header"], generated_sources: ["libbt_init_flags_bridge_code", "libbt_shim_bridge_code"], export_generated_headers: ["libbt_init_flags_bridge_header", "libbt_shim_bridge_header"], generated_headers: [ "libbt_init_flags_bridge_header", "libbt_shim_bridge_header", "libbt_hci_bridge_header", "cxx-bridge-header", ], generated_sources: [ "libbt_init_flags_bridge_code", "libbt_shim_bridge_code", "libbt_hci_bridge_code", ], export_generated_headers: [ "libbt_init_flags_bridge_header", "libbt_shim_bridge_header", "libbt_hci_bridge_header", "cxx-bridge-header", ], header_libs: ["libbt_callbacks_cxx_headers"], export_header_lib_headers: ["libbt_callbacks_cxx_headers"], cflags: [ "-Wno-unused-const-variable", ], Loading @@ -24,11 +43,31 @@ cc_library_static { "//apex_available:platform", "com.android.bluetooth.updatable", ], shared_libs: [ "libchrome", ], static_libs: [ "libbt_shim_ffi", ], } cc_library_static { name: "libbt_callbacks_cxx", header_libs: ["libbt_callbacks_cxx_headers"], srcs: ["callbacks/callbacks.cc"], generated_headers: ["libbt_hci_bridge_header", "cxx-bridge-header"], shared_libs: [ "libchrome", ], host_supported: true, } cc_library_headers { name: "libbt_callbacks_cxx_headers", local_include_dirs: ["callbacks"], host_supported: true, } genrule { name: "libbt_shim_bridge_header", tools: ["cxxbridge"], Loading Loading @@ -61,4 +100,18 @@ genrule { out: ["init_flags.cc"], } genrule { name: "libbt_hci_bridge_header", tools: ["cxxbridge"], cmd: "$(location cxxbridge) $(in) --header > $(out)", srcs: ["src/hci.rs"], out: ["src/hci.rs.h"], } genrule { name: "libbt_hci_bridge_code", tools: ["cxxbridge"], cmd: "$(location cxxbridge) $(in) >> $(out)", srcs: ["src/hci.rs"], out: ["hci.cc"], }
system/gd/rust/shim/callbacks/callbacks.cc 0 → 100644 +1 −0 Original line number Diff line number Diff line #include "callbacks/callbacks.h"
system/gd/rust/shim/callbacks/callbacks.h 0 → 100644 +26 −0 Original line number Diff line number Diff line #pragma once #include "base/callback.h" #include "rust/cxx.h" namespace bluetooth { namespace shim { namespace rust { class u8SliceCallback { public: u8SliceCallback(base::Callback<void(::rust::Slice<uint8_t>)> callback) : callback_(callback) {} void Run(::rust::Slice<uint8_t> value) const { callback_.Run(value); } private: base::Callback<void(::rust::Slice<uint8_t>)> callback_; }; } // namespace rust } // namespace shim } // namespace bluetooth #include "src/hci.rs.h"
system/gd/rust/shim/src/hci.rs 0 → 100644 +35 −0 Original line number Diff line number Diff line //! Hci shim #[cxx::bridge(namespace = bluetooth::shim::rust)] mod ffi { extern "C" { include!("callbacks/callbacks.h"); type u8SliceCallback; fn Run(&self, data: &[u8]); } extern "Rust" { fn hci_set_acl_callback(callback: UniquePtr<u8SliceCallback>); fn hci_send_command(data: &[u8]); fn hci_send_acl(data: &[u8]); fn hci_register_event(event: u8, callback: UniquePtr<u8SliceCallback>); fn hci_register_le_event(subevent: u8, callback: UniquePtr<u8SliceCallback>); } } fn hci_send_command(_data: &[u8]) { } fn hci_send_acl(_data: &[u8]) { } fn hci_register_event(_event: u8, _callback: cxx::UniquePtr<ffi::u8SliceCallback>) { } fn hci_register_le_event(_subevent: u8, _callback: cxx::UniquePtr<ffi::u8SliceCallback>) { } fn hci_set_acl_callback(_callback: cxx::UniquePtr<ffi::u8SliceCallback>) { }