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

Commit f19d6093 authored by Henri Chataing's avatar Henri Chataing
Browse files

RootCanal: Move liblmp sources to rootcanal/rust

Prepare for adding LLCP procedure implementation
in the same library, since multiple rust libraries
cannot be linked in the same binary (causes duplicate
symbols because of rust std lib).

Bug: 253535400
Test: m root-canal
Change-Id: I0e7ba4da2aa9b946eb7e5c7b720562cf59de6846
parent a6d7de9b
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -114,7 +114,7 @@ cc_library_static {
        "rootcanal_link_layer_packets_cxx_gen",
    ],
    whole_static_libs: [
        "liblmp",
        "librootcanal_rs",
    ],
    shared_libs: [
        "libbase",
@@ -159,7 +159,7 @@ cc_library_host_shared {
    ],
    whole_static_libs: [
        "libbase",
        "liblmp",
        "librootcanal_rs",
        "liblog",
    ],
    cflags: [
+1 −1
Original line number Diff line number Diff line
@@ -278,4 +278,4 @@ target_include_directories(
target_compile_options(libbt-rootcanal
                       PUBLIC -Wno-inconsistent-missing-override)

add_subdirectory(lmp)
add_subdirectory(rust)
+1 −1
Original line number Diff line number Diff line
@@ -16,5 +16,5 @@
[workspace]

members = [
  "lmp",
  "rust",
]
+7 −9
Original line number Diff line number Diff line
@@ -8,14 +8,13 @@ package {
}

rust_ffi {
    name: "liblmp",
    name: "librootcanal_rs",
    host_supported: true,
    vendor_available: true,
    crate_name: "lmp",
    crate_name: "rootcanal_rs",
    srcs: [
        "src/lib.rs",

        ":LmpGeneratedPackets_rust",
        ":rootcanal_lmp_packets_rust_gen",
        ":rootcanal_hci_packets_rust_gen",
    ],
    edition: "2018",
@@ -33,19 +32,18 @@ rust_ffi {
}

genrule {
    name: "LmpGeneratedPackets_rust",
    name: "rootcanal_lmp_packets_rust_gen",
    defaults: ["pdl_rust_generator_defaults"],
    srcs: ["lmp_packets.pdl"],
    out: ["lmp_packets.rs"],
}

rust_test_host {
    name: "liblmp_tests",
    crate_name: "lmp",
    name: "rootcanal_rs_test",
    crate_name: "rootcanal_rs",
    srcs: [
        "src/lib.rs",

        ":LmpGeneratedPackets_rust",
        ":rootcanal_lmp_packets_rust_gen",
        ":rootcanal_hci_packets_rust_gen",
    ],
    auto_gen_config: true,
+7 −7
Original line number Diff line number Diff line
@@ -7,27 +7,27 @@ android_bluetooth_packet_gen(

pdl_gen(
    NAME lmp_packets_rs
    INPUT ${ROOTCANAL_ROOT}/lmp/lmp_packets.pdl
    INPUT ${ROOTCANAL_ROOT}/rust/lmp_packets.pdl
    OUTPUT lmp_packets.rs
    LANG rust)

# This will automatically register all the tests as well.
corrosion_import_crate(MANIFEST_PATH ${ROOTCANAL_ROOT}/lmp/Cargo.toml FLAGS
corrosion_import_crate(MANIFEST_PATH ${ROOTCANAL_ROOT}/rust/Cargo.toml FLAGS
                       --offline --verbose --verbose)
corrosion_set_env_vars(lmp
corrosion_set_env_vars(rootcanal-rs
  LMP_PACKETS_PREBUILT=${lmp_packets_rs}
  HCI_PACKETS_PREBUILT=${hci_packets_rs}
  CARGO_HOME=${Rust_CARGO_HOME})

android_license(TARGET "lmp" LIBNAME None SPDX None LICENSE None LOCAL None)
android_license(TARGET rootcanal-rs LIBNAME None SPDX None LICENSE None LOCAL None)

add_custom_target(lmp_rust_packets DEPENDS ${lmp_packets_rs}
                                           ${hci_packets_rs})

# Make sure we have the rust packets generated before we build them.
add_dependencies(cargo-build_lmp lmp_rust_packets)
add_dependencies(cargo-build_rootcanal-rs lmp_rust_packets)

# Enable lmp in rootcanal.
target_link_libraries(libbt-rootcanal PUBLIC lmp)
target_link_libraries(libbt-rootcanal PUBLIC rootcanal-rs)
target_include_directories(libbt-rootcanal
    PUBLIC ${ROOTCANAL_ROOT}/lmp/include)
    PUBLIC ${ROOTCANAL_ROOT}/rust/include)
Loading