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
diff --git a/BUILD.gn b/BUILD.gn
index bf9b51c..902a9cd 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -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 @@
 if (use.test) {
   group("bluetooth_tests") {
     deps = [
-      "//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/common:bluetooth_test_common",
+      "//bt/profile/avrcp:net_test_avrcp",
+      "//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 @@
     "//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 @@
     "-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 @@
   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 @@
   }
 
   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" ]
   }
 }