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

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

Fix up files to compile on Linux

Fix up all the .gn files so that they will compile on Linux. In order to
compile with GN, there is a new dependency on common-mk (currently part
of chromiumos/platform2) and most third-party libraries now use
pkg-config to include and link. As a result, all build paths are
prefixed with //bt now.

In addition, also disable building non standard codecs temporarily (i.e.
ldac, aptx, aac). We will add a way to enable them via build flags later
but we're disabling them entirely for now.

Bug: 176847216
Bug: 176846220
Tag: #refactor
Test: run --host bluetooth_test_gd
Test: run --host bluetooth_test_common
Change-Id: I85e5f8bd64c9ad074537cdd1393d373d5644aca0
parent d4d9f061
Loading
Loading
Loading
Loading
+134 −7
Original line number Diff line number Diff line
@@ -20,11 +20,17 @@
# you add a new build file, there must be some path of dependencies from this
# file to your new one or GN won't know about it.

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

# This pulls in main/BUILD.gn and all of its dependencies.
group("bluetooth") {
  deps = [
    "//main:bluetooth",
    "//service:bluetoothtbd",
    "//bt/main:bluetooth",
    "//bt/service:bluetoothtbd",
  ]
}

@@ -32,10 +38,131 @@ group("bluetooth_tests") {
  testonly = true

  deps = [
    "//test/suite:net_test_bluetooth",
    "//btcore:net_test_btcore",
    "//hci:net_test_hci",
    "//osi:net_test_osi",
    "//device:net_test_device",
    "//bt/test/suite:net_test_bluetooth",
    "//bt/btcore:net_test_btcore",
    "//bt/hci:net_test_hci",
    "//bt/osi:net_test_osi",
    "//bt/device:net_test_device",
  ]
}

config("target_defaults") {
  include_dirs = [
    "//bt/linux_include",
    "//bt/types",
    "//bt/include",
  ]

  cflags = [
    "-DEXPORT_SYMBOL=__attribute__((visibility(\"default\")))",
    "-DFALLTHROUGH_INTENDED=[[clang::fallthrough]]",
    "-fPIC",
    "-Wno-non-c-typedef-for-linkage",
    "-Wno-unreachable-code-return",
    "-Wno-defaulted-function-deleted",
    "-Wno-gnu-variable-sized-type-not-at-end",
    "-Wno-format-nonliteral",
    "-Wno-inconsistent-missing-override",
    "-Wno-unreachable-code",
    "-Wno-range-loop-construct",
    "-Wno-reorder-init-list",
    "-Wno-unused-function",
    "-Wno-unused-result",
    "-Wno-unused-variable",
    "-Wno-unused-const-variable",
  ]

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

  defines = [
    "HAS_NO_BDROID_BUILDCFG",
    "OS_GENERIC",
  ]

  configs = [
    ":external_libchrome",
  ]
}

# Configurations to use as dependencies for GN build
config("external_gtest") {
  configs = [
    ":pkg_gtest",
    ":pkg_gmock",
  ]
}

config("external_gtest_main") {
  configs = [ ":pkg_gtest_main" ]
}

config("external_gmock_main") {
  configs = [ ":pkg_gmock_main" ]
}

config("external_libchrome") {
  configs = [ ":pkg_libchrome" ]
}

config("external_modp_b64") {
  configs = [ ":pkg_modp_b64" ]
}

config("external_tinyxml2") {
  configs = [ ":pkg_tinyxml2" ]
}

# Package configurations to extract dependencies from env
pkg_config("pkg_gtest") {
  pkg_deps = [ "gtest" ]
}

pkg_config("pkg_gtest_main") {
  pkg_deps = [ "gtest_main" ]
}

pkg_config("pkg_gmock") {
  pkg_deps = [ "gmock" ]
}

pkg_config("pkg_gmock_main") {
  pkg_deps = [ "gmock_main" ]
}

pkg_config("pkg_libchrome") {
  pkg_deps = [ "libchrome" ]
}

pkg_config("pkg_modp_b64") {
  pkg_deps = [ "libmodp_b64" ]
}

pkg_config("pkg_tinyxml2") {
  pkg_deps = [ "tinyxml2" ]
}

# Uncomment if building nonstandard codecs
# config("external_aac") {
#   configs = [ ":pkg_aac" ]
# }
#
# pkg_config("pkg_aac") {
#   pkg_deps = [ "fdk-aac" ]
# }
#
# config("external_libldac") {
#   configs = [
#     ":pkg_libldacBT_enc",
#     ":pkg_libldacBT_abr",
#   ]
# }
#
# pkg_config("pkg_libldacBT_enc") {
#   pkg_deps = [ "ldacBT-enc", ]
# }
#
# pkg_config("pkg_libldacBT_abr") {
#   pkg_deps = [ "ldacBT-abr", ]
# }
+36 −29
Original line number Diff line number Diff line
@@ -92,28 +92,32 @@ static_library("bta") {
    "hd",
    "include",
    "sys",
    "//",
    "//linux_include",
    "//bta",
    "//internal_include",
    "//btcore/include",
    "//hci/include",
    "//internal_include",
    "//stack/include",
    "//stack/btm",
    "//udrv/include",
    "//utils/include",
    "//vnd/include",
    "//btif/include",
    "//btif/avrcp",
    "//include/hardware/avrcp",
    "//profile/avrcp",
    "//packet/avrcp",
    "//packet/base",
    "//bt/",
    "//bt/linux_include",
    "//bt/bta",
    "//bt/internal_include",
    "//bt/btcore/include",
    "//bt/hci/include",
    "//bt/internal_include",
    "//bt/stack/include",
    "//bt/stack/btm",
    "//bt/udrv/include",
    "//bt/utils/include",
    "//bt/vnd/include",
    "//bt/btif/include",
    "//bt/btif/avrcp",
    "//bt/include/hardware/avrcp",
    "//bt/profile/avrcp",
    "//bt/packet/avrcp",
    "//bt/packet/base",
  ]

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

  deps = [
    "//third_party/libchrome:base"
    "//bt/gd/rust/shim:init_flags_bridge_header",
  ]
}

@@ -128,18 +132,21 @@ executable("net_test_bta") {

  include_dirs = [
    "include",
    "//",
    "//bta",
    "//btcore/include",
    "//hci/include",
    "//internal_include",
    "//stack/btm",
    "//bt/",
    "//bt/bta",
    "//bt/btcore/include",
    "//bt/hci/include",
    "//bt/internal_include",
    "//bt/stack/btm",
  ]

  deps = [
    "//bta",
    "//types",
    "//third_party/googletest:gmock_main",
    "//third_party/libchrome:base",
    "//bt/bta",
    "//bt/types",
  ]

  configs += [
    "//bt:external_gmock_main",
    "//bt:target_defaults",
  ]
}
+16 −9
Original line number Diff line number Diff line
@@ -25,11 +25,15 @@ static_library("btcore") {

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

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

  deps = [
    "//third_party/libchrome:base",
    "//bt/gd/rust/shim:init_flags_bridge_header",
  ]
}

@@ -38,20 +42,23 @@ executable("net_test_btcore") {
  sources = [
    "test/device_class_test.cc",
    "test/property_test.cc",
    "//osi/test/AllocationTestHarness.cc",
    "//bt/osi/test/AllocationTestHarness.cc",
  ]

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

  deps = [
    "//btcore",
    "//osi",
    "//types",
    "//third_party/googletest:gtest_main",
    "//third_party/libchrome:base",
    "//bt/btcore",
    "//bt/osi",
    "//bt/types",
  ]

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

  libs = [
+34 −28
Original line number Diff line number Diff line
@@ -16,13 +16,13 @@

static_library("btif") {
  sources = [
    "//audio_a2dp_hw/src/audio_a2dp_hw_utils.cc",
    "//audio_hearing_aid_hw/src/audio_hearing_aid_hw_utils.cc",
    "//bt/audio_a2dp_hw/src/audio_a2dp_hw_utils.cc",
    "//bt/audio_hearing_aid_hw/src/audio_hearing_aid_hw_utils.cc",
    "src/btif_a2dp.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",
    "avrcp/avrcp_service.cc",

@@ -31,7 +31,7 @@ static_library("btif") {
    "src/btif_avrcp_audio_track_linux.cc",
    "src/btif_ble_advertiser.cc",
    "src/btif_ble_scanner.cc",
    "src/btif_config.cc",
    # "src/btif_config.cc",
    "src/btif_config_transcode.cc",
    "src/btif_core.cc",
    "src/btif_debug.cc",
@@ -77,32 +77,38 @@ static_library("btif") {

  include_dirs = [
    "include",
    "//",
    "//linux_include",
    "//audio_a2dp_hw/include",
    "//audio_hearing_aid_hw/include",
    "//bta/include",
    "//bta/sys",
    "//btcore/include",
    "//device/include",
    "//embdrv/sbc/encoder/include",
    "//embdrv/sbc/decoder/include",
    "//hci/include",
    "//stack/a2dp",
    "//stack/btm",
    "//stack/l2cap",
    "//stack/include",
    "//third_party/tinyxml2",
    "//internal_include",
    "//udrv/include",
    "//utils/include",
    "//vnd/include",
    "//profile/avrcp",
    "//bt/",
    "//bt/bta/dm",
    "//bt/linux_include",
    "//bt/audio_a2dp_hw/include",
    "//bt/audio_hearing_aid_hw/include",
    "//bt/bta/include",
    "//bt/bta/sys",
    "//bt/btcore/include",
    "//bt/device/include",
    "//bt/embdrv/sbc/encoder/include",
    "//bt/embdrv/sbc/decoder/include",
    "//bt/hci/include",
    "//bt/stack/a2dp",
    "//bt/stack/btm",
    "//bt/stack/l2cap",
    "//bt/stack/include",
    "//bt/internal_include",
    "//bt/udrv/include",
    "//bt/utils/include",
    "//bt/vnd/include",
    "//bt/profile/avrcp",
  ]

  deps = [
    "//common",
    "//third_party/libchrome:base",
    "//profile/avrcp:profile_avrcp"
    "//bt/common",
    "//bt/gd/rust/shim:init_flags_bridge_header",
    "//bt/profile/avrcp:profile_avrcp",
    "//bt/third_party/proto_logging/stats:libbt-platform-protos",
  ]

  configs += [
    "//bt:target_defaults",
    "//bt:external_tinyxml2",
  ]
}
+1 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@

#include <map>
#include <memory>
#include <mutex>

#include "hardware/avrcp/avrcp.h"
#include "osi/include/properties.h"
Loading