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

Commit a5a04027 authored by Zach Johnson's avatar Zach Johnson
Browse files

Revert^2 "rusty-gd: compile into libbluetooth"

ca4841e4

Change-Id: I56860a238c483b55b5eb728eb8cd6cfb6ada4d28
parent ca4841e4
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
apex {
    name: "com.android.bluetooth.updatable",
    enabled: false,

    manifest: "apex_manifest.json",

+22 −1
Original line number Diff line number Diff line
@@ -154,6 +154,7 @@ cc_defaults {
        "BluetoothGeneratedDumpsysDataSchema_h",
        "BluetoothGeneratedDumpsysBundledSchema_h",
        "BluetoothGeneratedPackets_h",
        "libbt_common_bridge_header",
    ],
    shared_libs: [
        "libchrome",
@@ -162,7 +163,27 @@ cc_defaults {
    ],
    static_libs: [
        "libbluetooth-protos",
    ]
        "libbluetooth_rust_interop",
        "libbt_common_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",
    ],
}

cc_library {
+8 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@

#include "common/strings.h"
#include "os/log.h"
#include "src/init_flags.rs.h"

namespace bluetooth {
namespace common {
@@ -51,6 +52,13 @@ bool ParseBoolFlag(const std::vector<std::string>& flag_pair, const std::string&
}

void InitFlags::Load(const char** flags) {
  rust::Vec<rust::String> rusted_flags = rust::Vec<rust::String>();
  while (flags != nullptr && *flags != nullptr) {
    rusted_flags.push_back(rust::String(*flags));
    flags++;
  }
  init_flags_load(std::move(rusted_flags));

  SetAll(false);
  while (flags != nullptr && *flags != nullptr) {
    std::string flag_element = *flags;
+47 −0
Original line number Diff line number Diff line
@@ -7,6 +7,34 @@ rust_library {
        "libtokio",
        "libnix",
        "liblog_rust",
        "libcxx",
    ],
    target: {
        android: {
            rustlibs: [
                "libandroid_logger",
            ],
        },
        host: {
            rustlibs: [
                "libenv_logger",
            ],
        },
    },
    host_supported: true,
}

rust_ffi_static {
    name: "libbt_common_ffi",
    stem: "libbt_common",
    crate_name: "bt_common",
    srcs: ["src/lib.rs"],
    edition: "2018",
    rustlibs: [
        "libtokio",
        "libnix",
        "liblog_rust",
        "libcxx",
    ],
    target: {
        android: {
@@ -33,5 +61,24 @@ rust_test_host {
        "libnix",
        "liblog_rust",
        "libenv_logger",
        "libcxx",
    ],
}

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

+16 −0
Original line number Diff line number Diff line
use log::error;

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

fn init_flags_load(flags: Vec<String>) {
    crate::init_logging();

    for flag in flags {
        error!("hello from rust: {}", flag);
    }
}
Loading