1package {
2    // See: http://go/android-license-faq
3    // A large-scale-change added 'default_applicable_licenses' to import
4    // all of the 'license_kinds' from "system_bt_license"
5    // to get the below license kinds:
6    //   SPDX-license-identifier-Apache-2.0
7    default_applicable_licenses: ["system_bt_license"],
8}
9
10rust_library_host_rlib {
11    name: "libbt_topshim",
12    defaults: ["gd_rust_defaults"],
13    crate_name: "bt_topshim",
14    srcs: [
15        "src/lib.rs",
16
17        ":libbt_topshim_wrapper_bindgen",
18    ],
19    rustlibs: [
20        "libbitflags",
21        "libbt_common",
22        "libcxx",
23        "libfutures",
24        "libgrpcio",
25        "liblazy_static",
26        "liblog_rust",
27        "libnix",
28        "libnum_traits",
29        "libtokio",
30        "libtokio_stream",
31    ],
32    proc_macros: [
33        "libnum_derive",
34        "libpaste",
35        "libtopshim_macros",
36    ],
37    lints: "none",
38    clippy_lints: "none",
39}
40
41cc_library_static {
42    name: "libbt_topshim_cxx",
43    defaults: [
44        "gd_ffi_defaults",
45    ],
46    srcs: [
47        "btav/btav_shim.cc",
48        "btav_sink/btav_sink_shim.cc",
49        "btif/btif_shim.cc",
50        "controller/controller_shim.cc",
51        "csis/csis_shim.cc",
52        "gatt/gatt_ble_advertiser_shim.cc",
53        "gatt/gatt_ble_scanner_shim.cc",
54        "gatt/gatt_shim.cc",
55        "hfp/hfp_shim.cc",
56        "le_audio/le_audio_shim.cc",
57        "vc/vc_shim.cc",
58    ],
59    generated_headers: [
60        "BluetoothGeneratedDumpsysDataSchema_h",
61        "cxx-bridge-header",
62        "libbt_init_flags_bridge_header",
63        "libbt_topshim_bridge_header",
64    ],
65    generated_sources: ["libbt_topshim_bridge_code"],
66    include_dirs: [
67        "packages/modules/Bluetooth/system",
68        "packages/modules/Bluetooth/system/gd",
69        "packages/modules/Bluetooth/system/gd/rust/topshim",
70        "packages/modules/Bluetooth/system/include",
71        "packages/modules/Bluetooth/system/types",
72    ],
73    host_supported: true,
74    static_libs: [
75        "libbluetooth_hci_pdl",
76        "libbluetooth_log",
77        "libchrome",
78        "libflatbuffers-cpp",
79    ],
80}
81
82gensrcs {
83    name: "libbt_topshim_bridge_header",
84    tools: ["cxxbridge"],
85    cmd: "$(location cxxbridge) $(in) --header > $(out)",
86    srcs: [
87        "src/btif.rs",
88        "src/controller.rs",
89        "src/profiles/a2dp.rs",
90        "src/profiles/avrcp.rs",
91        "src/profiles/csis.rs",
92        "src/profiles/gatt.rs",
93        "src/profiles/hfp.rs",
94        "src/profiles/le_audio.rs",
95        "src/profiles/vc.rs",
96    ],
97    output_extension: "rs.h",
98    export_include_dirs: ["."],
99}
100
101gensrcs {
102    name: "libbt_topshim_bridge_code",
103    tools: ["cxxbridge"],
104    cmd: "$(location cxxbridge) $(in) > $(out)",
105    srcs: [
106        "src/btif.rs",
107        "src/controller.rs",
108        "src/profiles/a2dp.rs",
109        "src/profiles/avrcp.rs",
110        "src/profiles/csis.rs",
111        "src/profiles/gatt.rs",
112        "src/profiles/hfp.rs",
113        "src/profiles/le_audio.rs",
114        "src/profiles/vc.rs",
115    ],
116    output_extension: "cc",
117    export_include_dirs: ["."],
118}
119
120rust_bindgen {
121    name: "libbt_topshim_wrapper_bindgen",
122    wrapper_src: "bindings/wrapper.hpp",
123    crate_name: "bt_topshim_wrapper_bindgen",
124    source_stem: "bindings",
125    defaults: ["bluetooth_cflags"],
126    c_std: "",
127    host_supported: true,
128    bindgen_flags: [
129        "--allowlist-function=bt_.*",
130        "--allowlist-function=btgatt_.*",
131        "--allowlist-function=bthh_.*",
132        "--allowlist-function=btsdp.*",
133        "--allowlist-function=hal_util_.*",
134        "--allowlist-function=osi_property_get.*",
135        "--allowlist-type=bluetooth_sdp.*",
136        "--allowlist-type=bt_.*",
137        "--allowlist-type=btgatt_.*",
138        "--allowlist-type=bthf_.*",
139        "--allowlist-type=bthh_.*",
140        "--allowlist-type=btrc_.*",
141        "--allowlist-type=btsdp.*",
142        "--allowlist-type=btsock_.*",
143        "--allowlist-type=sock_connect_signal_t",
144        "--enable-cxx-namespaces",
145        "--opaque-type=std::.*",
146        "--with-derive-default",
147        "--with-derive-eq",
148        "--with-derive-partialeq",
149    ],
150    shared_libs: [
151        "libc++",
152    ],
153    static_libs: [
154        "libbluetooth_log",
155    ],
156    // The bindgen rule can only include headers via header_libs and does not
157    // support include_dirs. Make sure newly added headers have the correct
158    // header export target listed here.
159    header_libs: [
160        "libbluetooth_headers",
161        "libbluetooth_system_headers",
162    ],
163}
164