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

Commit 011171d7 authored by Abhishek Pandit-Subedi's avatar Abhishek Pandit-Subedi
Browse files

Build support for Rust via Cargo

ChromeOS is missing support for mixing C++ and Rust in GN so we compile
Rust in a separate step using Cargo. Currently, only the direct code
portions were copied to the Cargo.toml and tests are still missing. The
final output from the Rust build is the libbt_shim_ffi staticlib.

Some BUILD.gn rules for rust libraries were also added (to try to make
it work with an experimental Rust toolchain in GN) but was abandonded
because dependencies couldn't be built. Leaving this in since it will be
useful when GN supports building Rust as well on ChromeOS.

Bug: 176847256
Tag: #floss
Test: atest --host bluetooth_test_gd
Change-Id: I4d1ab599309b153b2304cb87c4526bc476dc2637
parent cac9ab3f
Loading
Loading
Loading
Loading

Cargo.toml

0 → 100644
+58 −0
Original line number Diff line number Diff line
#
#  Copyright 2021 Google, Inc.
#
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
#  You may obtain a copy of the License at:
#
#  http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.

[package]
name = "bt_shim_ffi"
version = "0.0.1"
edition = "2018"

[dependencies]
# BT dependencies
bt_common = { path = "gd/rust/common" }
bt_facade_helpers = { path = "gd/rust/facade" }
bt_hal = { path = "gd/rust/hal" }
bt_hci = { path = "gd/rust/hci" }
bt_main = { path = "gd/rust/main" }
bt_packets = { path = "gd/rust/packets" }

# All external dependencies. Keep all versions at build/rust/Cargo.toml
bindgen = "0.51"
bytes = "1.0"
cxx = { version = "0.5.9", features = ["c++17"] }
env_logger = "0.8"
futures = "0.3"
grpcio = { version = "0.7", features = ["protobuf", "protobuf-codec", "openssl"] }
grpcio-sys = { version = "*", features = ["openssl"] }
lazy_static = "1.4"
log = "0.4"
nix = "0.19"
num-derive = "0.3"
num-traits = "0.2"
paste = "1.0"
proc-macro2 = "1.0.24"
protobuf = "2.0"
protoc-grpcio = "2.0"
protoc-rust = "2.0"
quote = "1.0.8"
thiserror = "1.0"
syn = { version = "1.0.58", features = ['default', 'full'] }
tokio = { version = "1.0", features = ['bytes', 'fs', 'io-util', 'libc', 'macros', 'memchr', 'mio', 'net', 'num_cpus', 'rt', 'rt-multi-thread', 'sync', 'time', 'tokio-macros'] }
tokio-stream = "0.1"
walkdir = "2.2"


[lib]
path = "gd/rust/shim/src/lib.rs"
crate-type = ["staticlib"]
+7 −2
Original line number Diff line number Diff line
@@ -13,12 +13,17 @@
#  See the License for the specific language governing permissions and
#  limitations under the License.

rust("libbt_common") {
import("//common-mk/cxxbridge.gni")

rust_library("libbt_common") {
  crate_name = "bt_common"

  sources = [ "src/lib.rs" ]

  configs += [ "//bt/gd:gd_rust_defaults" ]
  configs = [
    "//bt/gd/rust/shim:rust_libs",
    "//bt/gd:rust_defaults",
  ]
}

cxxbridge_cc("libbt_common_sys_prop_bridge_code") {
+34 −0
Original line number Diff line number Diff line
#
#  Copyright 2021 Google, Inc.
#
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
#  You may obtain a copy of the License at:
#
#  http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.

[package]
name = "bt_common"
version = "0.0.1"
edition = "2018"

[dependencies]
cxx = "*"
env_logger = "*"
grpcio = "*"
lazy_static = "*"
log = "*"
nix = "*"
tokio = { version = "*", features = ['bytes', 'net'] }

# Proc Macro dependency
paste = "*"

[lib]
crate-type = ["rlib"]
+26 −0
Original line number Diff line number Diff line
#
#  Copyright 2021 Google, Inc.
#
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
#  You may obtain a copy of the License at:
#
#  http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.

rust_library("libbt_facade_helpers") {
  crate_name = "bt_facade_helpers"
  sources = [
    "helpers/lib.rs",
  ]

  configs = [
    "//bt/gd/rust/shim:rust_libs",
    "//bt/gd:rust_defaults",
  ]
}
+37 −0
Original line number Diff line number Diff line
#
#  Copyright 2021 Google, Inc.
#
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
#  You may obtain a copy of the License at:
#
#  http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.

[package]
name = "bt_facade_helpers"
version = "0.0.1"
edition = "2018"

[dependencies]
# GD bluetooth deps
bt_facade_proto = { path = "../facade_proto" }
bt_packets = { path = "../packets" }

# External deps
bytes = "*"
cxx = "*"
futures = "*"
grpcio = "*"
log = "*"
protobuf = "*"
tokio = "*"

[lib]
path = "helpers/lib.rs"
crate-type = ["rlib"]
Loading