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

Commit e1af94ec authored by Jeff DeCew's avatar Jeff DeCew
Browse files

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

Revert submission 1512686

Reason for revert: DroidMonitor-triggered revert due to breakage https://android-build.googleplex.com/builds/quarterdeck?branch=aosp-master&target=mainline_modules&lkgb=7010703&lkbb=7011903&fkbb=7010786, bug b/174815635
Bug: 174815635
Reverted Changes:
I163111bc8:rusty-gd: move init_flag parsing to rust
I54cffe93d:rusty-gd: compile into libbluetooth
I5207f4df9:rusty-gd: add stack start stubs, define shim libra...

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

// Enables code coverage for a set of source files. Must be combined with
+20 −16
Original line number Diff line number Diff line
@@ -76,6 +76,7 @@ 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*",
@@ -153,6 +154,7 @@ cc_defaults {
        "BluetoothGeneratedDumpsysDataSchema_h",
        "BluetoothGeneratedDumpsysBundledSchema_h",
        "BluetoothGeneratedPackets_h",
        "libbt_common_bridge_header",
    ],
    shared_libs: [
        "libchrome",
@@ -162,10 +164,26 @@ cc_defaults {
    static_libs: [
        "libbluetooth-protos",
        "libbluetooth_rust_interop",
        "libbt_shim_ffi",
        "libbt_common_ffi",
        "libcxxbridge05",
    ],
    export_static_lib_headers: [ "libbluetooth_rust_interop" ],
}

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

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

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

+22 −6
Original line number Diff line number Diff line
@@ -2,6 +2,24 @@ 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)]
@@ -9,7 +27,6 @@ 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,)* };
        }
@@ -64,7 +81,6 @@ macro_rules! init_flags {

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

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

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

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

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

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