Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f2dda050 authored by Jakub Pawlowski's avatar Jakub Pawlowski
Browse files

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
parent fb192451
Loading
Loading
Loading
Loading
+33 −85
Original line number Diff line number Diff line
subdirs = [
    "common",
]

cc_defaults {
    name: "fluoride_service_defaults",
    defaults: ["fluoride_defaults"],
    local_include_dirs: [
        "common"
    ],
    include_dirs: [
        "packages/modules/Bluetooth/system"
        "packages/modules/Bluetooth/system",
    ],
    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 = [
    "packages/modules/Bluetooth/system/service/common",
    "frameworks/native/aidl/binder",
]

btserviceDaemonSrc = [
    "adapter.cc",
    "daemon.cc",
@@ -77,7 +34,7 @@ btserviceLinuxSrc = [
    "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 @@ btserviceBinderDaemonImplSrc = [
    "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 @@ btserviceBaseTestSrc = [
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 @@ cc_test {
    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: [
            "packages/modules/Bluetooth/system/service/common",
            "frameworks/native/aidl/binder",
        ],
    },
    static_libs: [
        "libbluetooth-common",
        "libgmock",
        "liblog",
    ],
@@ -159,6 +118,9 @@ cc_test {
                "test/parcelable_unittest.cc",
                "test/ParcelableTest.aidl",
            ],
            static_libs: [
                "libbluetooth-binder-common",
            ],
            shared_libs: [
                "libbinder",
                "libutils",
@@ -184,31 +146,15 @@ cc_test {
    },
}

// 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 @@ cc_binary {
        "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 @@ cc_library_static {
    name: "libbluetoothtbd_hal",
    defaults: ["fluoride_defaults"],
    include_dirs: ["packages/modules/Bluetooth/system"],
    srcs = [
    srcs: [
        "hal/bluetooth_gatt_interface.cc",
        "hal/bluetooth_interface.cc",
        "logging_helpers.cc",
    ]
    ],
}
+76 −0
Original line number Diff line number Diff line
// 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: ["packages/modules/Bluetooth/system"],
    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",
            "packages/modules/Bluetooth/system/service/common",
        ],
    },
    export_include_dirs: ["./"],
    whole_static_libs: ["libbluetooth-common"],
    shared_libs: [
        "libbase",
        "libbinder",
    ],
}
+0 −6
Original line number Diff line number Diff line
@@ -10,9 +10,3 @@ root path, e.g.:
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"
+1 −1
Original line number Diff line number Diff line
@@ -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;

+3 −3
Original line number Diff line number Diff line
@@ -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>
Loading