From 96e9e34cf34a0d82c15dcd7a4a8ba0e04ac6bb76 Mon Sep 17 00:00:00 2001
From: Pavlin Radoslavov <pavlin@google.com>
Date: Thu, 2 Nov 2017 14:27:09 -0700
Subject: [PATCH] Add libbluetooth-for-tests static library

Add the most common dependencies to a static library
for building tests.

Bug: 68350333
Test: lunch gce_x86_pasan;
      SANITIZE_TARGET="address coverage" mma

Change-Id: I78e65a686873565d292ea0ad89047927ca6efb87
---
 system/btif/Android.bp  | 12 +++++++++++-
 system/main/Android.bp  | 25 +++++++++++++++++++++++++
 system/stack/Android.bp | 10 ++++++++++
 3 files changed, 46 insertions(+), 1 deletion(-)

diff --git a/system/btif/Android.bp b/system/btif/Android.bp
index f5e64044e09..b5442e8ea75 100644
--- a/system/btif/Android.bp
+++ b/system/btif/Android.bp
@@ -109,15 +109,25 @@ cc_test {
     srcs: ["test/btif_storage_test.cc"],
     header_libs: ["libbluetooth_headers"],
     shared_libs: [
+        "libhidlbase",
         "liblog",
+        "libprotobuf-cpp-lite",
         "libcutils",
+        "libutils",
     ],
     static_libs: [
-        "libbtcore",
         "libbtif",
+        "libbt-bta",
+        "libbtcore",
         "libbt-stack",
+        "libbtdevice",
+        "libbt-hci",
         "libbluetooth-types",
         "libosi",
+        "libbt-protos",
+    ],
+    whole_static_libs: [
+        "libbluetooth-for-tests",
     ],
     cflags: ["-DBUILDCFG"],
 }
diff --git a/system/main/Android.bp b/system/main/Android.bp
index 38e8b05536b..0b1566b8ca2 100644
--- a/system/main/Android.bp
+++ b/system/main/Android.bp
@@ -84,3 +84,28 @@ cc_library_shared {
         "-DBUILDCFG",
     ],
 }
+
+cc_library_static {
+    name: "libbluetooth-for-tests",
+    defaults: ["fluoride_defaults"],
+
+    srcs: [
+        "bte_init_cpp_logging.cc",
+        "bte_logmsg.cc",
+        "bte_main.cc",
+        "stack_config.cc",
+    ],
+    include_dirs: [
+        "packages/modules/Bluetooth/system",
+        "packages/modules/Bluetooth/system/bta/include",
+        "packages/modules/Bluetooth/system/btcore/include",
+        "packages/modules/Bluetooth/system/btif/include",
+        "packages/modules/Bluetooth/system/hci/include",
+        "packages/modules/Bluetooth/system/internal_include",
+        "packages/modules/Bluetooth/system/stack/include",
+        "packages/modules/Bluetooth/system/utils/include",
+    ],
+    cflags: [
+        "-DBUILDCFG",
+    ],
+}
diff --git a/system/stack/Android.bp b/system/stack/Android.bp
index ca7c4bd92c5..0f9a79c564c 100644
--- a/system/stack/Android.bp
+++ b/system/stack/Android.bp
@@ -199,15 +199,25 @@ cc_test {
     ],
     srcs: ["test/stack_a2dp_test.cc"],
     shared_libs: [
+        "libhidlbase",
         "liblog",
+        "libprotobuf-cpp-lite",
         "libcutils",
+        "libutils",
     ],
     static_libs: [
+        "libbt-bta",
         "libbt-stack",
         "libbt-sbc-decoder",
         "libbt-sbc-encoder",
         "libFraunhoferAAC",
+        "libbtdevice",
+        "libbt-hci",
         "libosi",
+        "libbt-protos",
+    ],
+    whole_static_libs: [
+        "libbluetooth-for-tests",
     ],
 }
 
-- 
GitLab