summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--BUILD.gn6
-rwxr-xr-xbuild.py51
-rw-r--r--system/btif/src/btif_bqr.cc6
-rw-r--r--system/gd/BUILD.gn2
-rw-r--r--system/gd/common/BUILD.gn4
-rw-r--r--system/gd/common/circular_buffer.h1
-rw-r--r--system/gd/common/strings.h1
-rw-r--r--system/gd/hal/BUILD.gn4
-rw-r--r--system/gd/os/BUILD.gn1
-rw-r--r--system/gd/security/ecdh_keys.h1
-rw-r--r--system/main/shim/hci_layer.cc2
-rw-r--r--system/osi/include/compat.h2
-rw-r--r--system/osi/src/compat.cc2
-rw-r--r--system/service/BUILD.gn5
-rw-r--r--system/stack/btm/btm_int_types.h4
-rw-r--r--system/types/BUILD.gn7
16 files changed, 78 insertions, 21 deletions
diff --git a/BUILD.gn b/BUILD.gn
index 109bf7167c..9d2f4c7adc 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -104,7 +104,9 @@ config("target_defaults") {
"-Wno-final-dtor-non-final-class",
]
- cflags_cc = [ "-std=c++17" ]
+ cflags_cc = [
+ "-std=c++17",
+ ]
defines = [
"HAS_NO_BDROID_BUILDCFG",
@@ -116,7 +118,7 @@ config("target_defaults") {
# If not configured as a dynamic library, default to static library
if (!(defined(use.bt_dynlib) && use.bt_dynlib)) {
- defines = [
+ defines += [
"STATIC_LIBBLUETOOTH",
]
}
diff --git a/build.py b/build.py
index 131cbb299e..3e79bff558 100755
--- a/build.py
+++ b/build.py
@@ -61,11 +61,21 @@ VALID_TARGETS = [
'tools', # Build the host tools (i.e. packetgen)
'rust', # Build only the rust components + copy artifacts to output dir
'main', # Build the main C++ codebase
- 'test', # Build and run the unit tests
+ 'test', # Run the unit tests
'clean', # Clean up output directory
'all', # All targets except test and clean
]
+HOST_TESTS = [
+ 'bluetooth_test_common',
+ 'bluetoothtbd_test',
+ 'net_test_avrcp',
+ 'net_test_btcore',
+ 'net_test_types',
+ 'net_test_btm_iso',
+ 'net_test_btpackets',
+]
+
class UseFlags():
@@ -110,6 +120,7 @@ class HostBuild():
self.jobs = self.args.jobs
if not self.jobs:
self.jobs = multiprocessing.cpu_count()
+ print("Number of jobs = {}".format(self.jobs))
# Normalize all directories
self.output_dir = os.path.abspath(self.args.output)
@@ -123,7 +134,13 @@ class HostBuild():
if hasattr(self.args, 'target') and self.args.target:
self.target = self.args.target
- self.use = UseFlags(self.args.use if self.args.use else [])
+ target_use = self.args.use if self.args.use else []
+
+ # Unless set, always build test code
+ if not self.args.notest:
+ target_use.append('test')
+
+ self.use = UseFlags(target_use)
# Validate platform directory
assert os.path.isdir(self.platform_dir), 'Platform dir does not exist'
@@ -137,6 +154,18 @@ class HostBuild():
self.configure_environ()
+ def _generate_rustflags(self):
+ """ Rustflags to include for the build.
+ """
+ rust_flags = [
+ '-L',
+ '{}/out/Default/'.format(self.output_dir),
+ '-C',
+ 'link-arg=-Wl,--allow-multiple-definition',
+ ]
+
+ return ' '.join(rust_flags)
+
def configure_environ(self):
""" Configure environment variables for GN and Cargo.
"""
@@ -150,6 +179,7 @@ class HostBuild():
# Configure Rust env variables
self.env['CARGO_TARGET_DIR'] = self.output_dir
self.env['CARGO_HOME'] = os.path.join(self.output_dir, 'cargo_home')
+ self.env['RUSTFLAGS'] = self._generate_rustflags()
# Configure some GN variables
if self.use_board:
@@ -364,7 +394,15 @@ class HostBuild():
def _target_test(self):
""" Runs the host tests.
"""
- raise Exception('Not yet implemented')
+ # Rust tests first
+ self.run_command('test', ['cargo', 'test'], cwd=os.path.join(self.platform_dir, 'bt'), env=self.env)
+
+ # Host tests second based on host test list
+ for t in HOST_TESTS:
+ self.run_command(
+ 'test', [os.path.join(self.output_dir, 'out/Default', t)],
+ cwd=os.path.join(self.output_dir),
+ env=self.env)
def _target_clean(self):
""" Delete the output directory entirely.
@@ -393,8 +431,6 @@ class HostBuild():
elif self.target == 'main':
self._target_main()
elif self.target == 'test':
- self.use.set_flag('test')
- self._target_all()
self._target_test()
elif self.target == 'clean':
self._target_clean()
@@ -406,14 +442,15 @@ if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Simple build for host.')
parser.add_argument('--output', help='Output directory for the build.', required=True)
parser.add_argument('--platform-dir', help='Directory where platform2 is staged.', required=True)
- parser.add_argument('--clang', help='Use clang compiler.', default=False, action="store_true")
+ parser.add_argument('--clang', help='Use clang compiler.', default=False, action='store_true')
parser.add_argument('--use', help='Set a specific use flag.')
+ parser.add_argument('--notest', help="Don't compile test code.", default=False, action='store_true')
parser.add_argument('--target', help='Run specific build target')
parser.add_argument('--sysroot', help='Set a specific sysroot path', default='/')
parser.add_argument('--libdir', help='Libdir - default = usr/lib64', default='usr/lib64')
parser.add_argument('--use-board', help='Use a built x86 board for dependencies. Provide path.')
parser.add_argument('--jobs', help='Number of jobs to run', default=0, type=int)
- parser.add_argument('--vendored-rust', help='Use vendored rust crates', default=False, action="store_true")
+ parser.add_argument('--vendored-rust', help='Use vendored rust crates', default=False, action='store_true')
parser.add_argument('--verbose', help='Verbose logs for build.')
args = parser.parse_args()
diff --git a/system/btif/src/btif_bqr.cc b/system/btif/src/btif_bqr.cc
index 7896ea225a..c437b2c1b1 100644
--- a/system/btif/src/btif_bqr.cc
+++ b/system/btif/src/btif_bqr.cc
@@ -17,7 +17,9 @@
#include <base/logging.h>
#include <errno.h>
#include <fcntl.h>
+#ifdef OS_ANDROID
#include <statslog.h>
+#endif
#include <stdio.h>
#include <sys/stat.h>
@@ -395,6 +397,7 @@ void AddLinkQualityEventToQueue(uint8_t length, uint8_t* p_link_quality_event) {
p_bqr_event->bqr_link_quality_event_.no_rx_count,
p_bqr_event->bqr_link_quality_event_.nak_count);
+#ifdef OS_ANDROID
int ret = android::util::stats_write(
android::util::BLUETOOTH_QUALITY_REPORT_REPORTED,
p_bqr_event->bqr_link_quality_event_.quality_report_id,
@@ -420,6 +423,9 @@ void AddLinkQualityEventToQueue(uint8_t length, uint8_t* p_link_quality_event) {
LOG(WARNING) << __func__ << ": failed to log BQR event to statsd, error "
<< ret;
}
+#else
+ // TODO(abps) Metrics for non-Android build
+#endif
kpBqrEventQueue->Enqueue(p_bqr_event.release());
}
diff --git a/system/gd/BUILD.gn b/system/gd/BUILD.gn
index 6abddb1f80..cd48264d02 100644
--- a/system/gd/BUILD.gn
+++ b/system/gd/BUILD.gn
@@ -67,7 +67,7 @@ static_library("libbluetooth_gd") {
"//bt/gd/crypto_toolbox:BluetoothCryptoToolboxSources",
"//bt/gd/dumpsys:BluetoothDumpsysSources",
"//bt/gd/hal:BluetoothHalSources",
- "//bt/gd/hal:BluetoothHalSources_hci_rootcanal",
+ "//bt/gd/hal:BluetoothHalSources_hci_host",
"//bt/gd/l2cap:BluetoothL2capSources",
"//bt/gd/neighbor:BluetoothNeighborSources",
"//bt/gd/rust/shim:libbluetooth_rust_interop",
diff --git a/system/gd/common/BUILD.gn b/system/gd/common/BUILD.gn
index 536bfb74a4..fb4dad973d 100644
--- a/system/gd/common/BUILD.gn
+++ b/system/gd/common/BUILD.gn
@@ -17,7 +17,7 @@
source_set("BluetoothCommonSources") {
sources = [
"init_flags.cc",
- "metric_id_manager.cc"
+ "metric_id_manager.cc",
"stop_watch.cc",
"strings.cc",
]
@@ -25,6 +25,6 @@ source_set("BluetoothCommonSources") {
configs += [ "//bt/gd:gd_defaults" ]
deps = [
"//bt/gd:gd_default_deps",
- "//bt/third_party/proto_logging/stats:libbt-platform-protos"
+ "//bt:libbt-platform-protos-lite",
]
}
diff --git a/system/gd/common/circular_buffer.h b/system/gd/common/circular_buffer.h
index 1914fa097b..46d6972fe1 100644
--- a/system/gd/common/circular_buffer.h
+++ b/system/gd/common/circular_buffer.h
@@ -18,6 +18,7 @@
#include <cstddef>
#include <iterator>
+#include <memory>
#include <mutex>
#include <queue>
diff --git a/system/gd/common/strings.h b/system/gd/common/strings.h
index a110cf45cc..c80d01effe 100644
--- a/system/gd/common/strings.h
+++ b/system/gd/common/strings.h
@@ -16,6 +16,7 @@
#pragma once
+#include <limits.h>
#include <string.h>
#include <charconv>
#include <iomanip>
diff --git a/system/gd/hal/BUILD.gn b/system/gd/hal/BUILD.gn
index 1752241d3c..9ed814a7c8 100644
--- a/system/gd/hal/BUILD.gn
+++ b/system/gd/hal/BUILD.gn
@@ -21,8 +21,8 @@ source_set("BluetoothHalSources") {
deps = [ "//bt/gd:gd_default_deps" ]
}
-source_set("BluetoothHalSources_hci_rootcanal") {
- sources = [ "hci_hal_host_rootcanal.cc" ]
+source_set("BluetoothHalSources_hci_host") {
+ sources = [ "hci_hal_host.cc" ]
configs += [ "//bt/gd:gd_defaults" ]
deps = [ "//bt/gd:gd_default_deps" ]
diff --git a/system/gd/os/BUILD.gn b/system/gd/os/BUILD.gn
index 84c9069214..56ddc598cb 100644
--- a/system/gd/os/BUILD.gn
+++ b/system/gd/os/BUILD.gn
@@ -20,6 +20,7 @@ source_set("BluetoothOsSources_linux") {
]
configs += [ "//bt/gd:gd_defaults" ]
+ deps = [ "//bt:libbt-platform-protos-lite" ]
}
source_set("BluetoothOsSources_linux_generic") {
diff --git a/system/gd/security/ecdh_keys.h b/system/gd/security/ecdh_keys.h
index 8ec25a8901..f9c43023ba 100644
--- a/system/gd/security/ecdh_keys.h
+++ b/system/gd/security/ecdh_keys.h
@@ -17,6 +17,7 @@
******************************************************************************/
#pragma once
+#include <stdint.h>
#include <array>
namespace bluetooth {
diff --git a/system/main/shim/hci_layer.cc b/system/main/shim/hci_layer.cc
index b273ddc6b1..85612cb028 100644
--- a/system/main/shim/hci_layer.cc
+++ b/system/main/shim/hci_layer.cc
@@ -344,7 +344,7 @@ void OnTransmitPacketCommandComplete(command_complete_cb complete_callback,
bluetooth::hci::CommandCompleteView view) {
LOG_DEBUG("Received cmd complete for %s",
bluetooth::hci::OpCodeText(view.GetCommandOpCode()).c_str());
- std::vector<const uint8_t> data(view.begin(), view.end());
+ std::vector<uint8_t> data(view.begin(), view.end());
BT_HDR* response = WrapPacketAndCopy(MSG_HC_TO_STACK_HCI_EVT, &view);
complete_callback(response, context);
}
diff --git a/system/osi/include/compat.h b/system/osi/include/compat.h
index 95fe0373ef..1d19a590d9 100644
--- a/system/osi/include/compat.h
+++ b/system/osi/include/compat.h
@@ -26,7 +26,7 @@
#include <unistd.h>
/* Get thread identification. */
-pid_t gettid(void);
+pid_t gettid(void) throw();
/* Copy src to string dst of size siz. */
size_t strlcpy(char* dst, const char* src, size_t siz);
diff --git a/system/osi/src/compat.cc b/system/osi/src/compat.cc
index 069964c22c..e5b41a5282 100644
--- a/system/osi/src/compat.cc
+++ b/system/osi/src/compat.cc
@@ -35,7 +35,7 @@
#include "osi/include/osi.h"
#if __GLIBC__
-pid_t gettid(void) { return syscall(SYS_gettid); }
+pid_t gettid(void) throw() { return syscall(SYS_gettid); }
#endif
/* These functions from bionic
diff --git a/system/service/BUILD.gn b/system/service/BUILD.gn
index f4b4f09d79..64d0844225 100644
--- a/system/service/BUILD.gn
+++ b/system/service/BUILD.gn
@@ -63,6 +63,8 @@ source_set("service_linux_src") {
sources = [
"ipc/ipc_handler_linux.cc",
"ipc/linux_ipc_host.cc",
+ "ipc/dbus/ipc_handler_dbus.cc",
+ "ipc/dbus/bluetooth_adapter.cc",
]
deps = [
@@ -91,8 +93,6 @@ source_set("service") {
"common/bluetooth/scan_settings.cc",
"common/bluetooth/service.cc",
"common/bluetooth/util/atomic_string.cc",
- "ipc/dbus/bluetooth_adapter.cc",
- "ipc/dbus/ipc_handler_dbus.cc",
]
deps = [
@@ -155,6 +155,7 @@ if (use.test) {
deps = [
":service_base_test_src",
":service_daemon_src",
+ ":service_linux_src",
"//bt/service/common:libbluetooth_common",
]
diff --git a/system/stack/btm/btm_int_types.h b/system/stack/btm/btm_int_types.h
index 90287e1601..9096ecc81a 100644
--- a/system/stack/btm/btm_int_types.h
+++ b/system/stack/btm/btm_int_types.h
@@ -126,7 +126,7 @@ typedef void(tBTM_BT_QUALITY_REPORT_RECEIVER)(uint8_t len, uint8_t* p_stream);
/* Define the Device Management control structure
*/
-typedef struct {
+typedef struct tBTM_DEVCB {
tBTM_VS_EVT_CB* p_vend_spec_cb[BTM_MAX_VSE_CALLBACKS]; /* Register for vendor
specific events */
@@ -202,7 +202,7 @@ typedef struct {
}
} tBTM_DEVCB;
-typedef struct {
+typedef struct tBTM_CB {
tBTM_CFG cfg; /* Device configuration */
/*****************************************************
diff --git a/system/types/BUILD.gn b/system/types/BUILD.gn
index 47604a9f44..08a47b6484 100644
--- a/system/types/BUILD.gn
+++ b/system/types/BUILD.gn
@@ -54,6 +54,13 @@ if (use.test) {
"z",
]
+ # For some reason, this is required for host build. Otherwise, I get
+ # a complaint from gmock:
+ # undefined reference to symbol 'pthread_getspecific@@GLIBC_2.2.5'
+ ldflags = [
+ "-lpthread"
+ ]
+
deps = [
":types",
]