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

Commit 9457ecfe authored by Zach Johnson's avatar Zach Johnson
Browse files

Revert "Revert "rusty-gd: add stack start stubs, define shim lib..."

Revert submission 1518559-revert-1512686-LIHRZNOOWL

Reason for revert: build system fixed
Reverted Changes:
I760eea76d:Revert "rusty-gd: add stack start stubs, define sh...
I5740575cf:Revert "rusty-gd: move init_flag parsing to rust"
I0cfbe779c:Revert "rusty-gd: compile into libbluetooth"

Change-Id: I5f0f76450889d7906e9a763a4ebc5a46daf673b7
parent 7623fd3c
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -90,6 +90,9 @@ fluoride_defaults {
    },
    static_libs: [
        "libbluetooth_gd",
        "libbluetooth_rust_interop",
        "libbt_shim_ffi",
        "libcxxbridge05",
    ],
    target: {
        darwin: {
@@ -97,9 +100,6 @@ fluoride_defaults {
            enabled: false,
        },
    },
    generated_headers: [
        "libbt_common_bridge_header",
    ],
}

// Enables code coverage for a set of source files. Must be combined with
+16 −20
Original line number Diff line number Diff line
@@ -76,7 +76,6 @@ cc_defaults {
    name: "gd_clang_tidy",
    tidy: true,
    tidy_checks: [
        "cppcoreguidelines-pro-type-member-init",
        "clang-analyzer-core.CallAndMessage",
        "clang-analyzer-optin.cplusplus.UninitializedObject",
        "-google*",
@@ -154,7 +153,6 @@ cc_defaults {
        "BluetoothGeneratedDumpsysDataSchema_h",
        "BluetoothGeneratedDumpsysBundledSchema_h",
        "BluetoothGeneratedPackets_h",
        "libbt_common_bridge_header",
    ],
    shared_libs: [
        "libchrome",
@@ -164,26 +162,10 @@ cc_defaults {
    static_libs: [
        "libbluetooth-protos",
        "libbluetooth_rust_interop",
        "libbt_common_ffi",
        "libbt_shim_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",
    ],
    export_static_lib_headers: [ "libbluetooth_rust_interop" ],
}

cc_library {
@@ -242,6 +224,9 @@ cc_binary {
        "libbluetooth-protos",
        "libbluetooth_gd",
        "libflatbuffers-cpp",
        "libbluetooth_rust_interop",
        "libbt_shim_ffi",
        "libcxxbridge05",
    ],
    shared_libs: [
        "libbacktrace",
@@ -330,6 +315,9 @@ cc_test {
        "libc++fs",
        "libflatbuffers-cpp",
        "libgmock",
        "libbluetooth_rust_interop",
        "libbt_shim_ffi",
        "libcxxbridge05",
    ],
    shared_libs: [
        "libchrome",
@@ -360,6 +348,11 @@ cc_test {
        address: true,
        cfi: true,
    },
    static_libs: [
        "libbluetooth_rust_interop",
        "libbt_shim_ffi",
        "libcxxbridge05",
    ],
}

cc_defaults {
@@ -375,6 +368,9 @@ cc_defaults {
        "libchrome",
        "libgmock",
        "libgtest",
        "libbluetooth_rust_interop",
        "libbt_shim_ffi",
        "libcxxbridge05",
    ],
    host_supported: true,
    generated_headers: [
+5 −31
Original line number Diff line number Diff line
rust_defaults {
    name: "libbt_common_defaults",
    stem: "libbt_common",
rust_library {
    name: "libbt_common",
    crate_name: "bt_common",
    srcs: ["src/lib.rs"],
    edition: "2018",
@@ -28,16 +27,6 @@ rust_defaults {
    host_supported: true,
}

rust_library {
    name: "libbt_common",
    defaults: ["libbt_common_defaults"],
}

rust_ffi_static {
    name: "libbt_common_ffi",
    defaults: ["libbt_common_defaults"],
}

rust_test_host {
    name: "libbt_common_inline_tests",
    srcs: ["src/lib.rs"],
@@ -50,22 +39,7 @@ rust_test_host {
        "libenv_logger",
        "libcxx",
    ],
    proc_macros: [
        "libpaste",
    ],
}

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"],
}

+6 −22
Original line number Diff line number Diff line
@@ -2,24 +2,6 @@ use log::{error, info};
use paste::paste;
use std::sync::Mutex;

#[cxx::bridge(namespace = bluetooth::common::init_flags)]
mod ffi {
    extern "Rust" {
        fn load(flags: Vec<String>);
        fn set_all_for_testing();

        fn gd_core_is_enabled() -> bool;
        fn gd_security_is_enabled() -> bool;
        fn gd_advertising_is_enabled() -> bool;
        fn gd_acl_is_enabled() -> bool;
        fn gd_l2cap_is_enabled() -> bool;
        fn gd_hci_is_enabled() -> bool;
        fn gd_controller_is_enabled() -> bool;
        fn gatt_robust_caching_is_enabled() -> bool;
        fn btaa_hci_is_enabled() -> bool;
    }
}

macro_rules! init_flags {
    (flags: { $($flag:ident),* }, dependencies: { $($parent:ident => $child:ident),* }) => {
        #[derive(Default)]
@@ -27,6 +9,7 @@ macro_rules! init_flags {
            $($flag: bool,)*
        }

        /// Sets all flags to true, for testing
        pub fn set_all_for_testing() {
            *FLAGS.lock().unwrap() = InitFlags { $($flag: true,)* };
        }
@@ -81,6 +64,7 @@ macro_rules! init_flags {

        paste! {
            $(
                #[allow(missing_docs)]
                pub fn [<$flag _is_enabled>]() -> bool {
                    FLAGS.lock().unwrap().$flag
                }
@@ -99,7 +83,8 @@ init_flags!(
        gd_hci,
        gd_controller,
        gatt_robust_caching,
        btaa_hci
        btaa_hci,
        gd_rust
    },
    dependencies: {
        gd_core => gd_security,
@@ -113,12 +98,11 @@ lazy_static! {
    static ref FLAGS: Mutex<InitFlags> = Mutex::new(InitFlags::default());
}

fn load(flags: Vec<String>) {
/// Loads the flag values from the passed-in vector of string values
pub fn load(flags: Vec<String>) {
    crate::init_logging();

    let flags = InitFlags::parse(flags);
    flags.log();
    *FLAGS.lock().unwrap() = flags;
}

+4 −2
Original line number Diff line number Diff line
@@ -12,7 +12,8 @@ mod ready;
#[macro_use]
mod asserts;

mod init_flags;
/// Provides runtime configured-at-startup flags
pub mod init_flags;

/// Inits logging for Android
#[cfg(target_os = "android")]
@@ -30,5 +31,6 @@ pub fn init_logging() {
    env_logger::Builder::new()
        .filter(None, log::LevelFilter::Debug)
        .parse_default_env()
        .init();
        .try_init()
        .ok();
}
Loading