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

Commit 6268f388 authored by Zijun Zhao's avatar Zijun Zhao Committed by Automerger Merge Worker
Browse files

Revert "GD Rust: Port parameter_provider to rust" am: dc27c4ac am: 11e7a782

parents 4615226f 11e7a782
Loading
Loading
Loading
Loading
+19 −158
Original line number Diff line number Diff line
@@ -7,10 +7,12 @@ package {
    default_applicable_licenses: ["system_bt_license"],
}


rust_library {
    name: "libbt_common",
  defaults: ["libbt_common_defaults"],
    defaults: ["gd_rust_defaults"],
    crate_name: "bt_common",
    srcs: ["src/lib.rs"],
    edition: "2018",
    rustlibs: [
        "libtokio",
        "libnix",
@@ -35,156 +37,17 @@ rust_library {
            ],
        },
    },
  apex_available: [
       "//apex_available:platform",
       "com.android.bluetooth",
  ],
  min_sdk_version: "Tiramisu",
}

rust_defaults {
    name: "libbt_common_defaults",
    defaults: ["gd_rust_defaults"],
    crate_name: "bt_common",
    srcs: ["src/lib.rs"],
    rustlibs: [
        "libtokio",
        "libnix",
        "liblazy_static",
        "liblog_rust",
        "libcxx",
        "libgrpcio",
        "libbt_packets",
        "libfutures",
        "libnum_traits",
        "libnix",
        "liblog_rust",
        "libbt_facade_helpers",
        "libenv_logger",
    ],
    proc_macros: [
        "libpaste",
    ],
    whole_static_libs: [
        "libbt_keystore_cc",
    ],
}

rust_ffi_static {
    name: "libbt_common_ffi",
    defaults: ["libbt_common_defaults"],
    target: {
          android: {
              rustlibs: [
                  "librustutils",
                  "libandroid_logger",
              ]
          },
     },
    apex_available: [
        "com.android.bluetooth",
    ],
    min_sdk_version: "30",
}

cc_library_static {
    name: "libbt_common_bridge",
    defaults: ["gd_ffi_defaults"],
    generated_headers: [
        "libbt_common_bridge_header",
        "cxx-bridge-header",
    ],
    generated_sources: [
        "libbt_common_bridge_code",
    ],
    export_generated_headers: [
        "libbt_common_bridge_header",
        "cxx-bridge-header",
    ],
    include_dirs: [
        "packages/modules/Bluetooth/system/gd",
        "packages/modules/Bluetooth/system/gd/rust/common",
    ],
    header_libs: ["libbt_keystore_cc_headers"],
    export_header_lib_headers: ["libbt_keystore_cc_headers"],
    cflags: [
        "-Wno-unused-const-variable",
    ],
    host_supported: true,
    apex_available: [
        "//apex_available:platform",
        "com.android.bluetooth",
    ],
    shared_libs: [
        "libchrome",
    ],
    min_sdk_version: "30",
}


cc_library_static {
    name: "libbt_keystore_cc",
    defaults: ["gd_ffi_defaults"],
    header_libs: ["libbt_keystore_cc_headers"],
    srcs: ["keystore/fake_bt_keystore.cc"],
    generated_headers: ["libbt_common_bridge_header", "cxx-bridge-header"],
    generated_sources: ["libbt_common_bridge_code"],
    shared_libs: [
        "libchrome",
    ],
    host_supported: true,
    apex_available: [
        "//apex_available:platform",
        "com.android.bluetooth",
    ],
    min_sdk_version: "30",
}

cc_library_headers {
    name: "libbt_keystore_cc_headers",
    local_include_dirs: ["keystore"],
    host_supported: true,
    apex_available: [
        "//apex_available:platform",
        "com.android.bluetooth",
    ],
    min_sdk_version: "30",
}

cc_library_static {
    name: "libbluetooth_common_rust_interop",
    defaults: ["gd_ffi_defaults"],
    whole_static_libs: [
        "libbt_common_bridge",
        "libbt_common_ffi",
    ],
    host_supported: true,
    apex_available: [
        "//apex_available:platform",
        "com.android.bluetooth",
    ],
    min_sdk_version: "30",
}

genrule {
    name: "libbt_common_bridge_header",
    tools: ["cxxbridge"],
    cmd: "$(location cxxbridge) $(in) --header > $(out)",
    srcs: ["src/bridge.rs"],
    out: ["src/bridge.rs.h"],
}

genrule {
    name: "libbt_common_bridge_code",
    tools: ["cxxbridge"],
    cmd: "$(location cxxbridge) $(in) >> $(out)",
    srcs: ["src/bridge.rs"],
    out: ["bridge.cc"],
}

rust_test_host {
    name: "libbt_common_inline_tests",
    defaults: ["gd_rust_defaults"],
    srcs: ["src/lib.rs"],
    test_suites: ["general-tests"],
    auto_gen_config: true,
@@ -193,11 +56,9 @@ rust_test_host {
        "libnix",
        "liblazy_static",
        "liblog_rust",
        "libfutures",
        "libenv_logger",
        "libgrpcio",
        "libbt_common",
        "libcxx",
        "libgrpcio",
    ],
    proc_macros: [
        "libpaste",
+0 −22
Original line number Diff line number Diff line
//#include "string"
#include "keystore/fake_bt_keystore.h"

#include <algorithm>
#include <functional>
#include <memory>

namespace bluetooth {
namespace fake_bluetooth_keystore {

class BluetoothKeystoreInterface::impl {
  friend BluetoothKeystoreInterface;
};

BluetoothKeystoreInterface::BluetoothKeystoreInterface() : impl(new class BluetoothKeystoreInterface::impl) {}

std::unique_ptr<BluetoothKeystoreInterface> new_bt_keystore_interface() {
  return std::make_unique<BluetoothKeystoreInterface>();
}

}  // namespace fake_bluetooth_keystore
}  // namespace bluetooth
+0 −23
Original line number Diff line number Diff line
#pragma once
#include <memory>

#include "rust/cxx.h"

namespace bluetooth {
namespace fake_bluetooth_keystore {

class BluetoothKeystoreInterface {
 public:
  BluetoothKeystoreInterface();

 private:
  class impl;
  std::shared_ptr<impl> impl;
};

std::unique_ptr<BluetoothKeystoreInterface> new_bt_keystore_interface();

}  // namespace fake_bluetooth_keystore
}  // namespace bluetooth

#include "src/bridge.rs.h"
 No newline at end of file
+1 −3
Original line number Diff line number Diff line
@@ -4,9 +4,7 @@ macro_rules! assert_near {
    ($thing:expr, $expected:expr, $error:expr) => {
        match (&$thing, &$expected, &$error) {
            (thing_val, expected_val, error_val) => {
                if thing_val < &(expected_val - error_val)
                    || thing_val > &(expected_val + error_val)
                {
                if thing_val < &(expected_val - error_val) || thing_val > &(expected_val + error_val) {
                    panic!(
                        "assertion failed: {:?} is not within {:?} of {:?}",
                        &*thing_val, &*error_val, &*expected_val
+0 −23
Original line number Diff line number Diff line
//! Merged bridge

pub use crate::parameter_provider::*;

#[cxx::bridge(namespace = "bluetooth::fake_bluetooth_keystore")]
/// ffi extern module
pub mod ffi {
    extern "Rust" {
        // ParameterProvider
        type ParameterProvider;
    }

    unsafe extern "C++" {
        include!("keystore/fake_bt_keystore.h");

        /// BluetoothKeystoreInterface
        type BluetoothKeystoreInterface;
        /// Construct a new BluetoothKeystoreInterface
        fn new_bt_keystore_interface() -> UniquePtr<BluetoothKeystoreInterface>;
    }

    impl UniquePtr<BluetoothKeystoreInterface> {}
}
Loading