Skip to content

Commit

Permalink
Add BUILD rule to compile librootcanal_ffi.so
Browse files Browse the repository at this point in the history
- include librootcanal_ffi.so in the build artifacts
- the shared library is used by the python controller interface
  • Loading branch information
hchataing committed Sep 19, 2023
1 parent 811198d commit 2b57c6b
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 9 deletions.
15 changes: 12 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,22 @@ jobs:
run: cargo install pdl-compiler

- name: Build
run: bazel build :rootcanal
run: |
bazel build :rootcanal
bazel build :librootcanal_ffi.so
- name: Package Artifacts
run: |
mkdir bin
mkdir -p bin
mkdir -p lib
mkdir -p include
cp bazel-bin/rootcanal bin
zip -r rootcanal-${{ matrix.release }} bin/
cp bazel-bin/librootcanal_ffi.so lib
cp model/controller/ffi.h include/rootcanal_ffi.h
zip -r rootcanal-${{ matrix.release }} \
bin/rootcanal \
lib/librootcanal_ffi.so \
include/rootcanal_ffi.h
- name: Upload Artifacts
uses: actions/upload-artifact@v3
Expand Down
63 changes: 63 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,69 @@ cc_library(
],
)

cc_binary(
name = "librootcanal_ffi.so",
linkopts = ["-shared"],
srcs = [
"include/crypto/crypto.h",
"include/hci/address.h",
"include/hci/address_with_type.h",
"include/hci/pcap_filter.h",
"include/log.h",
"include/pcap.h",
"include/phy.h",
"lib/crypto/crypto.cc",
"lib/hci/address.cc",
"model/controller/acl_connection.cc",
"model/controller/acl_connection.h",
"model/controller/acl_connection_handler.cc",
"model/controller/acl_connection_handler.h",
"model/controller/controller_properties.cc",
"model/controller/controller_properties.h",
"model/controller/dual_mode_controller.cc",
"model/controller/dual_mode_controller.h",
"model/controller/le_advertiser.cc",
"model/controller/le_advertiser.h",
"model/controller/link_layer_controller.cc",
"model/controller/link_layer_controller.h",
"model/controller/sco_connection.cc",
"model/controller/sco_connection.h",
"model/controller/vendor_commands/csr.h",
"model/controller/ffi.cc",
"model/controller/ffi.h",
"model/devices/device.cc",
"model/devices/device.h",
"rust/include/rootcanal_rs.h",
],
copts = [
"-std=c++17",
"-Wno-c99-designator",
"-Wno-google3-literal-operator",
"-Wno-pessimizing-move",
"-include",
"string.h",
"-I.",
"-fmacro-prefix-map=external/rootcanal/=",
],
defines = [
"NDEBUG",
],
includes = [
"include",
"rust/include",
],
visibility = ["//visibility:public"],
deps = [
":rootcanal_config",
":rootcanal_log",
":rootcanal_rs",
"//packets:generated",
"@fmtlib",
"@boringssl//:crypto",
"@pdl//:packet_runtime",
],
)

cc_binary(
name = "rootcanal",
srcs = ["desktop/root_canal_main.cc"],
Expand Down
6 changes: 0 additions & 6 deletions model/controller/ffi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

#include "ffi.h"

#include <android-base/logging.h>

#include <iostream>

#include "dual_mode_controller.h"
Expand All @@ -35,10 +33,6 @@ enum Idc {
ISO,
};

__attribute__((constructor)) static void ConfigureLogging() {
android::base::InitLogging({}, android::base::StdioLogger);
}

} // namespace hci

extern "C" {
Expand Down

0 comments on commit 2b57c6b

Please sign in to comment.