Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 11995d67 authored by Abhishek Pandit-Subedi's avatar Abhishek Pandit-Subedi
Browse files

floss: Refactor build for bt_common tests

Add futures library to Cargo.toml and refactor cxxbridge build to
include the fake keystore required for tests in bt_common.

Bug: 232134607
Tag: #floss
Test: ./floss/build/build-in-podman.py and emerge-zork floss
Change-Id: I4e5c5e43d38587db902d77f4c20d64255e986371
parent ffef4a7c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ static_library("libbluetooth_gd") {
  include_dirs = [ "." ]
  configs += [ ":gd_defaults" ]
  deps = [
    "//bt/system/gd/rust/common:libbt_keystore_cc",
    "//bt/system/gd/rust/topshim:libbluetooth_topshim",
    "//bt/system/gd/rust/shim:libbluetooth_rust_interop",
    "//bt/system/gd:BluetoothGeneratedPackets_h",
+20 −17
Original line number Diff line number Diff line
@@ -15,29 +15,32 @@

import("//common-mk/cxxbridge.gni")

rust_library("libbt_common") {
  crate_name = "bt_common"
static_library("libbt_keystore_cc") {
  complete_static_lib = true
  sources = [ "keystore/fake_bt_keystore.cc" ]
  deps = [
    ":libbt_common_bridge_code"
  ]

  sources = [ "src/lib.rs" ]
  configs += ["//bt/system/gd:gd_defaults"]
}

  configs = [
    "//bt/system/gd/rust/shim:rust_libs",
    "//bt/system/gd:rust_defaults",
  ]
config("rust_common_config") {
  include_dirs = [ "//bt/system/gd/rust/common" ]
}

cxxbridge_cc("libbt_common_sys_prop_bridge_code") {
  sources = [ "src/sys_prop.rs" ]
cxxbridge_header("libbt_common_bridge_header") {
  sources = [ "src/bridge.rs" ]
  all_dependent_configs = [ ":rust_common_config" ]
  deps = [ ":cxxlibheader" ]
}

cxxbridge_cc("libbt_common_bridge_code") {
  sources = [ "src/bridge.rs" ]
  deps = [ ":libbt_common_bridge_header" ]
  configs = [ "//bt/system/gd:gd_defaults" ]
}

static_library("libbt_common_sys_prop_cxx") {
  sources = [ "src/ffi/sys_props.cc" ]

  include_dirs = [ "src/ffi" ]

  deps = [ ":libbt_common_sys_prop_bridge_code" ]

  configs += [ "//bt/system/gd:gd_defaults" ]
cxxbridge_libheader("cxxlibheader") {
  deps = []
}
+1 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ edition = "2018"
[dependencies]
cxx = "*"
env_logger = "*"
futures = "0.3.13"
grpcio = "*"
lazy_static = "*"
log = "*"
+12 −0
Original line number Diff line number Diff line
fn main() {
    let target_dir = std::env::var_os("CARGO_TARGET_DIR").unwrap();

    // Link the keystore static lib and make sure to use -lc++
    println!("cargo:rustc-link-lib=static=bt_keystore_cc");
    println!("cargo:rustc-link-search=native={}", target_dir.clone().into_string().unwrap());
    println!("cargo:rustc-link-lib=c++");

    // Re-run if static libs or this file changed.
    println!("cargo:rerun-if-changed={}", target_dir.into_string().unwrap());
    println!("cargo:rerun-if-changed=build.rs");
}