Refactor topshim with bindgen and unsafe code
Writing topshim interfaces is very tedious and lots of code is
duplicated in C++. Rather that depend on unsafe C++ code, we write
a small amount of unsafe Rust code and use macros to interact with the
native layer directly from Rust.
A few major changes introduced in this patch:
- Bindgen to get Rust interface into C
- Macros to call raw pointer functions directly
- Macros to handle converting a callback into an enum variant
- Refactor code to use new data structures
- Replace use of closures for callbacks with an enum and dispatch fn
This change also updates the bindgen requirement to 0.57 to match what
Android is already using.
BYPASS_INCLUSIVE_LANGUAGE_REASON=Bindgen dependency provides this api
Bug: 183208689
Tag: #floss
Test: atest --host bluetooth_test_gd
Change-Id: Iebe904ebc2643b48d1a371051fbf3c06f2bf04d4
diff --git a/build.py b/build.py
index c6cbabd..808c808 100755
--- a/build.py
+++ b/build.py
@@ -180,6 +180,7 @@
self.env['CARGO_TARGET_DIR'] = self.output_dir
self.env['CARGO_HOME'] = os.path.join(self.output_dir, 'cargo_home')
self.env['RUSTFLAGS'] = self._generate_rustflags()
+ self.env['CXX_ROOT_PATH'] = os.path.join(self.platform_dir, 'bt')
# Configure some GN variables
if self.use_board: