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

Commit 9bd8242a authored by Abhishek Pandit-Subedi's avatar Abhishek Pandit-Subedi
Browse files

Build support and abstractions for Linux build

This has a large number of fixes to build on Linux/ChromeOS. In general,
it is making sure the BUILD.gn and Android.bp for a directory structure
match and it has all the configs + deps needed to build.

Besides a number of simple fixups (missing headers), there are also
a few abstractions that need to be noted:

* All of audio HAL is stubbed out (using the host implementation)
* Parameter provider and system_properties (under gd/os) now have
  a linux variant that changes where configuration files are kept. The
  current location for linux is now /etc/systembt. This implementation
  was copied from the host versions (which seems to be used for host
  testing).

Bug: 176847256
Tag: #floss
Test: atest --host bluetooth_test_gd
Change-Id: I1a6b3b362cedbe5f675794a115a330cc7f85f9c1
parent b3fe88bf
Loading
Loading
Loading
Loading
+41 −21
Original line number Diff line number Diff line
@@ -21,14 +21,10 @@
# file to your new one or GN won't know about it.

group("all") {
  deps = [
    ":bluetooth",
  ]
  deps = [ ":bluetooth" ]

  if (use.test) {
    deps += [
      ":bluetooth_tests"
    ]
    deps += [ ":bluetooth_tests" ]
  }
}

@@ -43,24 +39,34 @@ group("bluetooth") {
if (use.test) {
  group("bluetooth_tests") {
    deps = [
      "//bt/btcore:net_test_btcore",
      "//bt/common:bluetooth_test_common",
      "//bt/service:bluetoothtbd_test",
      "//bt/profile/avrcp:net_test_avrcp",
      "//bt/btcore:net_test_btcore",
      "//bt/types:net_test_types",
      "//bt/service:bluetoothtbd_test",
      "//bt/stack:net_test_btm_iso",
      "//bt/types:net_test_types",

      #"//bt/packet:net_test_btpackets",
    ]
  }
}

if (host_cpu == target_cpu && host_os == target_os) {
  group("tools") {
    deps = [
      "//bt/gd/dumpsys/bundler:bluetooth_flatbuffer_bundler",
      "//bt/gd/packet/parser:bluetooth_packetgen",
    ]
  }
}

if (defined(use.android) && use.android) {
  group("android_bluetooth_tests") {
    deps = [
      "//bt/test/suite:net_test_bluetooth",
      "//bt/device:net_test_device",
      "//bt/hci:net_test_hci",
      "//bt/osi:net_test_osi",
      "//bt/device:net_test_device",
      "//bt/test/suite:net_test_bluetooth",
    ]
  }
}
@@ -71,11 +77,13 @@ config("target_defaults") {
    "//bt/linux_include",
    "//bt/types",
    "//bt/include",

    # For flatbuffer generated headers
    "${root_gen_dir}/bt/gd/",
    "${root_gen_dir}/bt/gd/dumpsys/bundler",
  ]

  cflags = [
    "-DEXPORT_SYMBOL=__attribute__((visibility(\"default\")))",
    "-DFALLTHROUGH_INTENDED=[[clang::fallthrough]]",
    "-fPIC",
    "-Wno-non-c-typedef-for-linkage",
    "-Wno-unreachable-code-return",
@@ -91,20 +99,26 @@ config("target_defaults") {
    "-Wno-unused-variable",
    "-Wno-unused-const-variable",
    "-Wno-format",
    "-Wno-pessimizing-move",
    "-Wno-unknown-warning-option",
    "-Wno-final-dtor-non-final-class",
  ]

  cflags_cc = [
    "-std=c++17",
  ]
  cflags_cc = [ "-std=c++17" ]

  defines = [
    "HAS_NO_BDROID_BUILDCFG",
    "OS_GENERIC",
    "OS_LINUX_GENERIC",
    "EXPORT_SYMBOL=__attribute__((visibility(\"default\")))",
    "FALLTHROUGH_INTENDED=[[clang::fallthrough]]",
  ]

  configs = [
    ":external_libchrome",
  ]
  if (!(defined(use.bt_nonstandard_codecs) && use.bt_nonstandard_codecs)) {
    defines += [ "EXCLUDE_NONSTANDARD_CODECS" ]
  }

  configs = [ ":external_libchrome" ]
}

# Configurations to use as dependencies for GN build
@@ -135,6 +149,12 @@ config("external_tinyxml2") {
  configs = [ ":pkg_tinyxml2" ]
}

config("external_flatbuffers") {
  lib_dirs = [ "${libdir}" ]

  libs = [ "flatbuffers" ]
}

# Package configurations to extract dependencies from env
pkg_config("pkg_gtest") {
  pkg_deps = [ "gtest" ]
@@ -184,10 +204,10 @@ if (defined(use.bt_nonstandard_codecs) && use.bt_nonstandard_codecs) {
  }

  pkg_config("pkg_libldacBT_enc") {
    pkg_deps = [ "ldacBT-enc", ]
    pkg_deps = [ "ldacBT-enc" ]
  }

  pkg_config("pkg_libldacBT_abr") {
    pkg_deps = [ "ldacBT-abr", ]
    pkg_deps = [ "ldacBT-abr" ]
  }
}
+36 −0
Original line number Diff line number Diff line
#
#  Copyright 2021 Google, Inc.
#
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
#  You may obtain a copy of the License at:
#
#  http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.
#

static_library("audio_hal_interface") {
  sources = [
    "a2dp_encoding_host.cc",
    "hearing_aid_software_encoding_host.cc",
  ]

  include_dirs = [
    "//bt/bta/include",
    "//bt/btif/include",
    "//bt/stack/include",
    "//bt/gd/rust/shim",
  ]

  configs += [ "//bt:target_defaults" ]

  deps = [
    "//bt/common",
    "//bt/osi:osi",
  ]
}
+1 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
#include <hardware/bt_hearing_aid.h>
#include <cstdint>
#include <deque>
#include <functional>
#include <vector>

constexpr uint16_t HEARINGAID_MAX_NUM_UUIDS = 1;
+3 −5
Original line number Diff line number Diff line
@@ -19,8 +19,8 @@ static_library("btcore") {
    "src/device_class.cc",
    "src/hal_util.cc",
    "src/module.cc",
    "src/property.cc",
    "src/osi_module.cc",
    "src/property.cc",
  ]

  include_dirs = [
@@ -28,9 +28,7 @@ static_library("btcore") {
    "//bt",
  ]

  configs += [
    "//bt:target_defaults",
  ]
  configs += [ "//bt:target_defaults" ]

  deps = [
    "//bt/gd/rust/shim:init_flags_bridge_header",
@@ -41,9 +39,9 @@ static_library("btcore") {
if (use.test) {
  executable("net_test_btcore") {
    sources = [
      "//bt/osi/test/AllocationTestHarness.cc",
      "test/device_class_test.cc",
      "test/property_test.cc",
      "//bt/osi/test/AllocationTestHarness.cc",
    ]

    include_dirs = [
+21 −12
Original line number Diff line number Diff line
@@ -16,17 +16,35 @@

static_library("btif") {
  sources = [
    # TODO(abps) - Do we need this?
    "//bt/audio_a2dp_hw/src/audio_a2dp_hw_utils.cc",
    "//bt/audio_hearing_aid_hw/src/audio_hearing_aid_hw_utils.cc",

    # AVRCP Target Service
    "avrcp/avrcp_service.cc",
    "co/bta_av_co.cc",

    # Callouts
    "co/bta_dm_co.cc",
    "co/bta_gatts_co.cc",
    "co/bta_hh_co.cc",
    "co/bta_pan_co.cc",

    # HAL layer
    "src/bluetooth.cc",

    # BTIF implementation
    "src/btif_a2dp.cc",

    # "TODO(abps) - Move this abstraction elsewhere
    # "src/btif_a2dp_audio_interface.cc",
    "src/btif_a2dp_audio_interface_linux.cc",
    "src/btif_a2dp_control.cc",
    "src/btif_a2dp_sink.cc",
    # "src/btif_a2dp_source.cc",
    "src/btif_a2dp_source.cc",
    "src/btif_av.cc",

    #TODO(jpawlowski): heavily depends on Android,
    # TODO(abps) - Move this abstraction elsewhere
    # "src/btif_avrcp_audio_track.cc",
    "src/btif_avrcp_audio_track_linux.cc",
    "src/btif_ble_advertiser.cc",
@@ -70,15 +88,6 @@ static_library("btif") {
    "src/stack_manager.cc",
  ]

  # BTIF callouts
  sources += [
    "co/bta_av_co.cc",
    "co/bta_dm_co.cc",
    "co/bta_gatts_co.cc",
    "co/bta_hh_co.cc",
    "co/bta_pan_co.cc",
  ]

  include_dirs = [
    "include",
    "//bt/",
Loading