bluetoothtbd common library reconfiguration
This patch change how code in service/common directory is compiled. Up
till now, .cc files were generated from .aidl, and the .cc files were
build for each target that used them. From now on, static lib is build
from .aidl and .cc files, and it is included into all targets that
require them.
This reduces build steps from around 1240 to 849.
Test: compilation test
Change-Id: Iebaf0c75497bc435dcc013be09a1f82e75547aa3
diff --git a/service/Android.bp b/service/Android.bp
index 83761c9..c28be7e 100644
--- a/service/Android.bp
+++ b/service/Android.bp
@@ -1,60 +1,17 @@
+subdirs = [
+ "common",
+]
+
cc_defaults {
name: "fluoride_service_defaults",
defaults: ["fluoride_defaults"],
- local_include_dirs: [
- "common"
- ],
include_dirs: [
- "system/bt"
+ "system/bt",
],
- srcs: [
- "common/bluetooth/adapter_state.cc",
- "common/bluetooth/advertise_data.cc",
- "common/bluetooth/advertise_settings.cc",
- "common/bluetooth/descriptor.cc",
- "common/bluetooth/characteristic.cc",
- "common/bluetooth/scan_filter.cc",
- "common/bluetooth/scan_result.cc",
- "common/bluetooth/scan_settings.cc",
- "common/bluetooth/service.cc",
- "common/bluetooth/util/address_helper.cc",
- "common/bluetooth/util/atomic_string.cc",
- "common/bluetooth/uuid.cc",
- ]
}
// Source variables
// ========================================================
-btserviceCommonBinderSrc = [
- "common/android/bluetooth/IBluetooth.aidl",
- "common/android/bluetooth/IBluetoothCallback.aidl",
- "common/android/bluetooth/IBluetoothGattClient.aidl",
- "common/android/bluetooth/IBluetoothGattClientCallback.aidl",
- "common/android/bluetooth/IBluetoothGattServer.aidl",
- "common/android/bluetooth/IBluetoothGattServerCallback.aidl",
- "common/android/bluetooth/IBluetoothLeAdvertiser.aidl",
- "common/android/bluetooth/IBluetoothLeAdvertiserCallback.aidl",
- "common/android/bluetooth/IBluetoothLeScanner.aidl",
- "common/android/bluetooth/IBluetoothLeScannerCallback.aidl",
- "common/android/bluetooth/IBluetoothLowEnergy.aidl",
- "common/android/bluetooth/IBluetoothLowEnergyCallback.aidl",
- "common/android/bluetooth/advertise_data.cc",
- "common/android/bluetooth/advertise_settings.cc",
- "common/android/bluetooth/bluetooth_gatt_characteristic.cc",
- "common/android/bluetooth/bluetooth_gatt_descriptor.cc",
- "common/android/bluetooth/bluetooth_gatt_included_service.cc",
- "common/android/bluetooth/bluetooth_gatt_service.cc",
- "common/android/bluetooth/scan_filter.cc",
- "common/android/bluetooth/scan_result.cc",
- "common/android/bluetooth/scan_settings.cc",
- "common/android/bluetooth/uuid.cc",
-]
-
-btserviceCommonAidlInclude = [
- "system/bt/service/common",
- "frameworks/native/aidl/binder",
-]
-
btserviceDaemonSrc = [
"adapter.cc",
"daemon.cc",
@@ -77,7 +34,7 @@
"ipc/linux_ipc_host.cc",
]
-btserviceBinderDaemonImplSrc = [
+btserviceBinderDaemonSrc = [
"ipc/binder/bluetooth_binder_server.cc",
"ipc/binder/bluetooth_gatt_client_binder_server.cc",
"ipc/binder/bluetooth_gatt_server_binder_server.cc",
@@ -88,8 +45,6 @@
"ipc/binder/ipc_handler_binder.cc",
]
-btserviceBinderDaemonSrc = btserviceCommonBinderSrc + btserviceBinderDaemonImplSrc
-
// Main unit test sources. These get built for host and target.
// ========================================================
btserviceBaseTestSrc = [
@@ -113,15 +68,15 @@
cc_binary {
name: "bluetoothtbd",
defaults: ["fluoride_service_defaults"],
- srcs: btserviceBinderDaemonSrc
- + btserviceLinuxSrc
- + btserviceDaemonSrc
- + ["main.cc"],
- aidl: {
- include_dirs: btserviceCommonAidlInclude
- },
+ srcs: btserviceBinderDaemonSrc +
+ btserviceLinuxSrc +
+ btserviceDaemonSrc +
+ ["main.cc"],
required: ["bluetooth.default"],
- static_libs: ["libbtcore"],
+ static_libs: [
+ "libbluetooth-binder-common",
+ "libbtcore",
+ ],
shared_libs: [
"libbinder",
"libcutils",
@@ -139,14 +94,18 @@
name: "bluetoothtbd_test",
test_suites: ["device-tests"],
defaults: ["fluoride_service_defaults"],
- srcs: btserviceBaseTestSrc
- + btserviceDaemonSrc + [
- "test/main.cc"
+ srcs: btserviceBaseTestSrc +
+ btserviceDaemonSrc + [
+ "test/main.cc",
],
aidl: {
- include_dirs: btserviceCommonAidlInclude,
+ include_dirs: [
+ "system/bt/service/common",
+ "frameworks/native/aidl/binder",
+ ],
},
static_libs: [
+ "libbluetooth-common",
"libgmock",
"liblog",
],
@@ -159,6 +118,9 @@
"test/parcelable_unittest.cc",
"test/ParcelableTest.aidl",
],
+ static_libs: [
+ "libbluetooth-binder-common",
+ ],
shared_libs: [
"libbinder",
"libutils",
@@ -184,31 +146,15 @@
},
}
-// Client library for interacting with Bluetooth daemon
-// This is a static library for target.
-// ========================================================
-cc_library_static {
- name: "libbluetooth-client",
- defaults: ["fluoride_service_defaults"],
- srcs: btserviceCommonBinderSrc,
- aidl: {
- export_aidl_headers: true,
- include_dirs: btserviceCommonAidlInclude
- },
- export_include_dirs: ["common"],
- shared_libs: [
- "libbinder",
- "libutils",
- ],
-}
-
// Native system service CLI for target
// ========================================================
cc_binary {
name: "bluetooth-cli",
defaults: ["fluoride_defaults"],
srcs: ["client/main.cc"],
- static_libs: ["libbluetooth-client"],
+ static_libs: [
+ "libbluetooth-binder-common",
+ ],
shared_libs: [
"libbinder",
"libutils",
@@ -225,7 +171,9 @@
"example/heart_rate/heart_rate_server.cc",
"example/heart_rate/server_main.cc",
],
- static_libs: ["libbluetooth-client"],
+ static_libs: [
+ "libbluetooth-binder-common",
+ ],
shared_libs: [
"libbinder",
"libutils",
@@ -236,9 +184,9 @@
name: "libbluetoothtbd_hal",
defaults: ["fluoride_defaults"],
include_dirs: ["system/bt"],
- srcs = [
+ srcs: [
"hal/bluetooth_gatt_interface.cc",
"hal/bluetooth_interface.cc",
"logging_helpers.cc",
- ]
+ ],
}
diff --git a/service/common/Android.bp b/service/common/Android.bp
new file mode 100644
index 0000000..d4d46b8
--- /dev/null
+++ b/service/common/Android.bp
@@ -0,0 +1,76 @@
+// Bluetooth types
+cc_library_static {
+ name: "libbluetooth-common",
+ defaults: ["fluoride_defaults"],
+ cflags: [
+ /* we export all classes, so change default visibility, instead of having EXPORT_SYMBOL on each class*/
+ "-fvisibility=default",
+ ],
+ host_supported: true,
+ srcs: [
+ "bluetooth/adapter_state.cc",
+ "bluetooth/advertise_data.cc",
+ "bluetooth/advertise_settings.cc",
+ "bluetooth/characteristic.cc",
+ "bluetooth/descriptor.cc",
+ "bluetooth/scan_filter.cc",
+ "bluetooth/scan_result.cc",
+ "bluetooth/scan_settings.cc",
+ "bluetooth/service.cc",
+ "bluetooth/util/address_helper.cc",
+ "bluetooth/util/atomic_string.cc",
+ "bluetooth/uuid.cc",
+ ],
+ export_include_dirs: ["./"],
+ include_dirs: ["system/bt"],
+ shared_libs: [
+ "libbase",
+ ],
+}
+
+// Bluetooth Binder shared library
+cc_library_static {
+ name: "libbluetooth-binder-common",
+ defaults: ["fluoride_defaults"],
+ cflags: [
+ /* we export all classes, so change default visibility, instead of having EXPORT_SYMBOL on each class*/
+ "-fvisibility=default",
+ ],
+ srcs: [
+ "android/bluetooth/IBluetooth.aidl",
+ "android/bluetooth/IBluetoothCallback.aidl",
+ "android/bluetooth/IBluetoothGattClient.aidl",
+ "android/bluetooth/IBluetoothGattClientCallback.aidl",
+ "android/bluetooth/IBluetoothGattServer.aidl",
+ "android/bluetooth/IBluetoothGattServerCallback.aidl",
+ "android/bluetooth/IBluetoothLeAdvertiser.aidl",
+ "android/bluetooth/IBluetoothLeAdvertiserCallback.aidl",
+ "android/bluetooth/IBluetoothLeScanner.aidl",
+ "android/bluetooth/IBluetoothLeScannerCallback.aidl",
+ "android/bluetooth/IBluetoothLowEnergy.aidl",
+ "android/bluetooth/IBluetoothLowEnergyCallback.aidl",
+ "android/bluetooth/advertise_data.cc",
+ "android/bluetooth/advertise_settings.cc",
+ "android/bluetooth/bluetooth_gatt_characteristic.cc",
+ "android/bluetooth/bluetooth_gatt_descriptor.cc",
+ "android/bluetooth/bluetooth_gatt_included_service.cc",
+ "android/bluetooth/bluetooth_gatt_service.cc",
+ "android/bluetooth/scan_filter.cc",
+ "android/bluetooth/scan_result.cc",
+ "android/bluetooth/scan_settings.cc",
+ "android/bluetooth/uuid.cc",
+ ],
+ aidl: {
+ export_aidl_headers: true,
+ include_dirs: [
+ "frameworks/native/aidl/binder",
+ "system/bt/service/common",
+ ],
+ },
+ export_include_dirs: ["./"],
+ whole_static_libs: ["libbluetooth-common"],
+ shared_libs: [
+ "libbase",
+ "libbinder",
+ ],
+}
diff --git a/service/common/README b/service/common/README
index de9e914..55f95fa 100644
--- a/service/common/README
+++ b/service/common/README
@@ -10,9 +10,3 @@
This is so that client applications that link against the client library have
one common include path exported to them, and our headers can find eachother
within that.
-
-It is however OK to include from the package root when including common headers
-from source files as these are pre-compiled. For example,
-common/bluetooth/adapter_state.cpp should do:
-
-#include "service/common/bluetooth/adapter_state.h"
diff --git a/service/common/android/bluetooth/advertise_data.cc b/service/common/android/bluetooth/advertise_data.cc
index 07eb50a..7fe3601 100644
--- a/service/common/android/bluetooth/advertise_data.cc
+++ b/service/common/android/bluetooth/advertise_data.cc
@@ -14,7 +14,7 @@
// limitations under the License.
//
-#include "service/common/android/bluetooth/advertise_data.h"
+#include "android/bluetooth/advertise_data.h"
using android::OK;
diff --git a/service/common/android/bluetooth/bluetooth_gatt_characteristic.cc b/service/common/android/bluetooth/bluetooth_gatt_characteristic.cc
index cf1fb2f..6ed9e1a 100644
--- a/service/common/android/bluetooth/bluetooth_gatt_characteristic.cc
+++ b/service/common/android/bluetooth/bluetooth_gatt_characteristic.cc
@@ -14,9 +14,9 @@
// limitations under the License.
//
-#include "service/common/android/bluetooth/bluetooth_gatt_characteristic.h"
-#include "service/common/android/bluetooth/bluetooth_gatt_descriptor.h"
-#include "service/common/android/bluetooth/uuid.h"
+#include "android/bluetooth/bluetooth_gatt_characteristic.h"
+#include "android/bluetooth/bluetooth_gatt_descriptor.h"
+#include "android/bluetooth/uuid.h"
#include <utils/String16.h>
#include <utils/String8.h>
diff --git a/service/common/android/bluetooth/bluetooth_gatt_descriptor.cc b/service/common/android/bluetooth/bluetooth_gatt_descriptor.cc
index 7749404..ecec0e0 100644
--- a/service/common/android/bluetooth/bluetooth_gatt_descriptor.cc
+++ b/service/common/android/bluetooth/bluetooth_gatt_descriptor.cc
@@ -14,8 +14,8 @@
// limitations under the License.
//
-#include "service/common/android/bluetooth/bluetooth_gatt_descriptor.h"
-#include "service/common/android/bluetooth/uuid.h"
+#include "android/bluetooth/bluetooth_gatt_descriptor.h"
+#include "android/bluetooth/uuid.h"
#include <utils/String16.h>
#include <utils/String8.h>
diff --git a/service/common/android/bluetooth/bluetooth_gatt_included_service.cc b/service/common/android/bluetooth/bluetooth_gatt_included_service.cc
index 02dc546..c66e0d2 100644
--- a/service/common/android/bluetooth/bluetooth_gatt_included_service.cc
+++ b/service/common/android/bluetooth/bluetooth_gatt_included_service.cc
@@ -14,9 +14,9 @@
// limitations under the License.
//
-#include "service/common/android/bluetooth/bluetooth_gatt_characteristic.h"
-#include "service/common/android/bluetooth/bluetooth_gatt_service.h"
-#include "service/common/android/bluetooth/uuid.h"
+#include "android/bluetooth/bluetooth_gatt_characteristic.h"
+#include "android/bluetooth/bluetooth_gatt_service.h"
+#include "android/bluetooth/uuid.h"
#include <utils/String16.h>
#include <utils/String8.h>
diff --git a/service/common/android/bluetooth/bluetooth_gatt_service.cc b/service/common/android/bluetooth/bluetooth_gatt_service.cc
index f4915cb..0c0daeb 100644
--- a/service/common/android/bluetooth/bluetooth_gatt_service.cc
+++ b/service/common/android/bluetooth/bluetooth_gatt_service.cc
@@ -14,9 +14,9 @@
// limitations under the License.
//
-#include "service/common/android/bluetooth/bluetooth_gatt_service.h"
-#include "service/common/android/bluetooth/bluetooth_gatt_characteristic.h"
-#include "service/common/android/bluetooth/uuid.h"
+#include "android/bluetooth/bluetooth_gatt_service.h"
+#include "android/bluetooth/bluetooth_gatt_characteristic.h"
+#include "android/bluetooth/uuid.h"
#include <utils/String16.h>
#include <utils/String8.h>
diff --git a/service/common/android/bluetooth/scan_filter.cc b/service/common/android/bluetooth/scan_filter.cc
index bf9eaf2..6bb6119 100644
--- a/service/common/android/bluetooth/scan_filter.cc
+++ b/service/common/android/bluetooth/scan_filter.cc
@@ -14,8 +14,8 @@
// limitations under the License.
//
-#include "service/common/android/bluetooth/scan_filter.h"
-#include "service/common/android/bluetooth/uuid.h"
+#include "android/bluetooth/scan_filter.h"
+#include "android/bluetooth/uuid.h"
#include <binder/Parcel.h>
#include <utils/String16.h>
diff --git a/service/common/android/bluetooth/scan_result.cc b/service/common/android/bluetooth/scan_result.cc
index 17378df..32acae3 100644
--- a/service/common/android/bluetooth/scan_result.cc
+++ b/service/common/android/bluetooth/scan_result.cc
@@ -14,7 +14,7 @@
// limitations under the License.
//
-#include "service/common/android/bluetooth/scan_result.h"
+#include "android/bluetooth/scan_result.h"
#include <base/logging.h>
#include <binder/Parcel.h>
diff --git a/service/common/android/bluetooth/scan_settings.cc b/service/common/android/bluetooth/scan_settings.cc
index 0920cca..8c79cea 100644
--- a/service/common/android/bluetooth/scan_settings.cc
+++ b/service/common/android/bluetooth/scan_settings.cc
@@ -14,7 +14,7 @@
// limitations under the License.
//
-#include "service/common/android/bluetooth/scan_settings.h"
+#include "android/bluetooth/scan_settings.h"
#include <binder/Parcel.h>
diff --git a/service/common/android/bluetooth/uuid.cc b/service/common/android/bluetooth/uuid.cc
index 6d03bb6..6cfc6db 100644
--- a/service/common/android/bluetooth/uuid.cc
+++ b/service/common/android/bluetooth/uuid.cc
@@ -14,7 +14,7 @@
// limitations under the License.
//
-#include "service/common/android/bluetooth/uuid.h"
+#include "android/bluetooth/uuid.h"
#include <binder/Parcel.h>
diff --git a/service/common/bluetooth/adapter_state.cc b/service/common/bluetooth/adapter_state.cc
index 9ca5998..47c07af 100644
--- a/service/common/bluetooth/adapter_state.cc
+++ b/service/common/bluetooth/adapter_state.cc
@@ -14,7 +14,7 @@
// limitations under the License.
//
-#include "service/common/bluetooth/adapter_state.h"
+#include "bluetooth/adapter_state.h"
namespace bluetooth {
diff --git a/service/common/bluetooth/advertise_data.cc b/service/common/bluetooth/advertise_data.cc
index 93bffa8..d9cac21 100644
--- a/service/common/bluetooth/advertise_data.cc
+++ b/service/common/bluetooth/advertise_data.cc
@@ -14,7 +14,7 @@
// limitations under the License.
//
-#include "service/common/bluetooth/advertise_data.h"
+#include "bluetooth/advertise_data.h"
#include <base/logging.h>
diff --git a/service/common/bluetooth/advertise_settings.cc b/service/common/bluetooth/advertise_settings.cc
index ca3428c..4d2605b 100644
--- a/service/common/bluetooth/advertise_settings.cc
+++ b/service/common/bluetooth/advertise_settings.cc
@@ -14,7 +14,7 @@
// limitations under the License.
//
-#include "service/common/bluetooth/advertise_settings.h"
+#include "bluetooth/advertise_settings.h"
namespace bluetooth {
diff --git a/service/common/bluetooth/scan_filter.cc b/service/common/bluetooth/scan_filter.cc
index c0b7375..1baa0b4 100644
--- a/service/common/bluetooth/scan_filter.cc
+++ b/service/common/bluetooth/scan_filter.cc
@@ -14,9 +14,9 @@
// limitations under the License.
//
-#include "service/common/bluetooth/scan_filter.h"
+#include "bluetooth/scan_filter.h"
-#include "service/common/bluetooth/util/address_helper.h"
+#include "bluetooth/util/address_helper.h"
namespace bluetooth {
diff --git a/service/common/bluetooth/scan_result.cc b/service/common/bluetooth/scan_result.cc
index 099cac7..168dae7 100644
--- a/service/common/bluetooth/scan_result.cc
+++ b/service/common/bluetooth/scan_result.cc
@@ -14,11 +14,11 @@
// limitations under the License.
//
-#include "service/common/bluetooth/scan_result.h"
+#include "bluetooth/scan_result.h"
#include <base/logging.h>
-#include "service/common/bluetooth/util/address_helper.h"
+#include "bluetooth/util/address_helper.h"
namespace bluetooth {
diff --git a/service/common/bluetooth/scan_settings.cc b/service/common/bluetooth/scan_settings.cc
index a405a28..dac0391 100644
--- a/service/common/bluetooth/scan_settings.cc
+++ b/service/common/bluetooth/scan_settings.cc
@@ -14,7 +14,7 @@
// limitations under the License.
//
-#include "service/common/bluetooth/scan_settings.h"
+#include "bluetooth/scan_settings.h"
namespace bluetooth {
diff --git a/service/common/bluetooth/uuid.cc b/service/common/bluetooth/uuid.cc
index b7ae9e5..16547ae 100644
--- a/service/common/bluetooth/uuid.cc
+++ b/service/common/bluetooth/uuid.cc
@@ -14,7 +14,7 @@
// limitations under the License.
//
-#include "service/common/bluetooth/uuid.h"
+#include "bluetooth/uuid.h"
#include <algorithm>
#include <array>