gn-build: Clean up GN files

Removed unnecessary library and include flags from build files. To make the
initial build outputs more similar to Android, this CL changes the usage of the
GN "source_set" idiom to "static_library". This comes at a performance loss
while keeping the builds similar until we get the whole stack to compile.

BUG=21339022

Change-Id: I46f70b3b64b2537634a1dbb517a5168566230efb
diff --git a/bta/BUILD.gn b/bta/BUILD.gn
index 04b75d4..d315d86 100644
--- a/bta/BUILD.gn
+++ b/bta/BUILD.gn
@@ -14,86 +14,90 @@
 #  limitations under the License.
 #
 
-source_set("bta") {
+static_library("bta") {
   sources = [
-    "dm/bta_dm_ci.c",
-    "dm/bta_dm_act.c",
-    "dm/bta_dm_pm.c",
-    "dm/bta_dm_main.c",
-    "dm/bta_dm_cfg.c",
-    "dm/bta_dm_api.c",
-    "dm/bta_dm_sco.c",
-    "gatt/bta_gattc_api.c",
-    "gatt/bta_gatts_act.c",
-    "gatt/bta_gatts_main.c",
-    "gatt/bta_gattc_utils.c",
-    "gatt/bta_gattc_ci.c",
-    "gatt/bta_gatts_api.c",
-    "gatt/bta_gattc_main.c",
-    "gatt/bta_gattc_act.c",
-    "gatt/bta_gattc_cache.c",
-    "gatt/bta_gatts_utils.c",
-    "ag/bta_ag_sdp.c",
-    "ag/bta_ag_sco.c",
-    "ag/bta_ag_cfg.c",
-    "ag/bta_ag_main.c",
-    "ag/bta_ag_api.c",
-    "ag/bta_ag_rfc.c",
     "ag/bta_ag_act.c",
-    "ag/bta_ag_cmd.c",
-    "ag/bta_ag_ci.c",
+    "ag/bta_ag_api.c",
     "ag/bta_ag_at.c",
+    "ag/bta_ag_cfg.c",
+    "ag/bta_ag_ci.c",
+    "ag/bta_ag_cmd.c",
+    "ag/bta_ag_main.c",
+    "ag/bta_ag_rfc.c",
+    "ag/bta_ag_sco.c",
+    "ag/bta_ag_sdp.c",
+    "ar/bta_ar.c",
+    "av/bta_av_aact.c",
+    "av/bta_av_act.c",
+    "av/bta_av_api.c",
+    "av/bta_av_cfg.c",
+    "av/bta_av_ci.c",
+    "av/bta_av_main.c",
+    "av/bta_av_sbc.c",
+    "av/bta_av_ssm.c",
+    "dm/bta_dm_act.c",
+    "dm/bta_dm_api.c",
+    "dm/bta_dm_cfg.c",
+    "dm/bta_dm_ci.c",
+    "dm/bta_dm_main.c",
+    "dm/bta_dm_pm.c",
+    "dm/bta_dm_sco.c",
+    "gatt/bta_gattc_act.c",
+    "gatt/bta_gattc_api.c",
+    "gatt/bta_gattc_cache.c",
+    "gatt/bta_gattc_ci.c",
+    "gatt/bta_gattc_main.c",
+    "gatt/bta_gattc_utils.c",
+    "gatt/bta_gatts_act.c",
+    "gatt/bta_gatts_api.c",
+    "gatt/bta_gatts_main.c",
+    "gatt/bta_gatts_utils.c",
     "hf_client/bta_hf_client_act.c",
     "hf_client/bta_hf_client_api.c",
+    "hf_client/bta_hf_client_at.c",
+    "hf_client/bta_hf_client_cmd.c",
     "hf_client/bta_hf_client_main.c",
     "hf_client/bta_hf_client_rfc.c",
-    "hf_client/bta_hf_client_at.c",
     "hf_client/bta_hf_client_sdp.c",
     "hf_client/bta_hf_client_sco.c",
-    "hf_client/bta_hf_client_cmd.c",
-    "hh/bta_hh_cfg.c",
     "hh/bta_hh_act.c",
     "hh/bta_hh_api.c",
+    "hh/bta_hh_cfg.c",
     "hh/bta_hh_le.c",
-    "hh/bta_hh_utils.c",
     "hh/bta_hh_main.c",
-    "pan/bta_pan_main.c",
-    "pan/bta_pan_ci.c",
-    "pan/bta_pan_act.c",
-    "pan/bta_pan_api.c",
-    "av/bta_av_act.c",
-    "av/bta_av_ci.c",
-    "av/bta_av_api.c",
-    "av/bta_av_aact.c",
-    "av/bta_av_main.c",
-    "av/bta_av_cfg.c",
-    "av/bta_av_ssm.c",
-    "av/bta_av_sbc.c",
-    "ar/bta_ar.c",
+    "hh/bta_hh_utils.c",
     "hl/bta_hl_act.c",
     "hl/bta_hl_api.c",
-    "hl/bta_hl_main.c",
-    "hl/bta_hl_utils.c",
-    "hl/bta_hl_sdp.c",
     "hl/bta_hl_ci.c",
-    "mce/bta_mce_api.c",
-    "mce/bta_mce_main.c",
-    "mce/bta_mce_act.c",
-    "mce/bta_mce_cfg.c",
-    "sys/bta_sys_main.c",
-    "sys/bta_sys_conn.c",
-    "sys/utl.c",
+    "hl/bta_hl_main.c",
+    "hl/bta_hl_sdp.c",
+    "hl/bta_hl_utils.c",
     "jv/bta_jv_act.c",
+    "jv/bta_jv_api.c",
     "jv/bta_jv_cfg.c",
     "jv/bta_jv_main.c",
-    "jv/bta_jv_api.c",
+    "mce/bta_mce_act.c",
+    "mce/bta_mce_api.c",
+    "mce/bta_mce_cfg.c",
+    "mce/bta_mce_main.c",
+    "pan/bta_pan_act.c",
+    "pan/bta_pan_api.c",
+    "pan/bta_pan_ci.c",
+    "pan/bta_pan_main.c",
+    "sdp/bta_sdp.c",
+    "sdp/bta_sdp_act.c",
+    "sdp/bta_sdp_api.c",
+    "sdp/bta_sdp_cfg.c",
+    "sys/bta_sys_conn.c",
+    "sys/bta_sys_main.c",
+    "sys/utl.c",
   ]
 
   include_dirs = [
-    "include",
-    "sys",
     "dm",
     "hh",
+    "include",
+    "sys",
     "//",
     "//btcore/include",
     "//gki/common",
@@ -104,8 +108,8 @@
     "//stack/btm",
     "//osi/include",
     "//udrv/include",
-    "//vnd/include",
     "//utils/include",
+    "//vnd/include",
   ]
 
   cflags = [
diff --git a/btcore/BUILD.gn b/btcore/BUILD.gn
index 16173b1..56719ad 100644
--- a/btcore/BUILD.gn
+++ b/btcore/BUILD.gn
@@ -14,7 +14,7 @@
 #  limitations under the License.
 #
 
-source_set("btcore") {
+static_library("btcore") {
   sources = [
     "src/bdaddr.c",
     "src/counter.c",
@@ -50,7 +50,7 @@
   deps = [
     "//btcore",
     "//osi",
-    "//testing/gtest:gtest_main",
+    "//third_party/gtest:gtest_main",
   ]
 
   libs = [ "-lpthread", "-lrt", "-ldl" ]
diff --git a/build/config/BUILDCONFIG.gn b/build/config/BUILDCONFIG.gn
index 8a7fe2c..419d62f 100644
--- a/build/config/BUILDCONFIG.gn
+++ b/build/config/BUILDCONFIG.gn
@@ -39,3 +39,11 @@
     "//build:default_include_dirs",
   ]
 }
+
+set_defaults("static_library") {
+  configs = [
+    "//build:linux",
+    "//build:gc",
+    "//build:default_include_dirs",
+  ]
+}
diff --git a/build/toolchain/gcc/BUILD.gn b/build/toolchain/gcc/BUILD.gn
index d5a4cf6..ecf9057 100644
--- a/build/toolchain/gcc/BUILD.gn
+++ b/build/toolchain/gcc/BUILD.gn
@@ -47,8 +47,7 @@
     ]
     default_output_extension = ".a"
 
-    # TODO(armansito): is the following needed?
-    #output_prefix = "lib"
+    output_prefix = "lib"
   }
 
   tool("solink") {
@@ -71,8 +70,7 @@
     link_output = soname
     depend_output = soname
 
-    # TODO(armansito): is the following needed?
-    #output_prefix = "lib"
+    output_prefix = "lib"
   }
 
   tool("link") {
diff --git a/device/BUILD.gn b/device/BUILD.gn
index d72d578..4629bd4 100644
--- a/device/BUILD.gn
+++ b/device/BUILD.gn
@@ -14,7 +14,7 @@
 #  limitations under the License.
 #
 
-source_set("device") {
+static_library("device") {
   sources = [
     "src/classic/peer.c",
     "src/controller.c"
@@ -22,7 +22,6 @@
 
   include_dirs = [
     "//",
-    "include",
     "//btcore/include",
     "//gki/common",
     "//hci/include",
diff --git a/gki/BUILD.gn b/gki/BUILD.gn
index 54b15fa..95993ac 100644
--- a/gki/BUILD.gn
+++ b/gki/BUILD.gn
@@ -14,7 +14,7 @@
 #  limitations under the License.
 #
 
-source_set("gki") {
+static_library("gki") {
   sources = [
     "common/gki_buffer.c",
     "ulinux/gki_ulinux.c",
@@ -23,11 +23,8 @@
   include_dirs = [
     "common",
     "ulinux",
-    "//btcore/include",
-    "//include",
-    "//osi/include",
-    "//stack/include",
-    "//utils/include",
     "//",
+    "//include",
+    "//stack/include",
   ]
 }
diff --git a/hci/BUILD.gn b/hci/BUILD.gn
index 5d9163c..27f4a65 100644
--- a/hci/BUILD.gn
+++ b/hci/BUILD.gn
@@ -14,11 +14,12 @@
 #  limitations under the License.
 #
 
-source_set("hci") {
+static_library("hci") {
   sources = [
     "src/btsnoop.c",
     "src/btsnoop_net.c",
     "src/buffer_allocator.c",
+    "src/hci_audio.c",
     "src/hci_hal.c",
     "src/hci_hal_h4.c",
     "src/hci_hal_mct.c",
@@ -37,10 +38,8 @@
     "//include",
     "//btcore/include",
     "//gki/common",
-    "//gki/ulinux",
     "//osi/include",
     "//stack/include",
-    "//utils/include",
   ]
 }
 
diff --git a/osi/BUILD.gn b/osi/BUILD.gn
index abefdbc..3c12636 100644
--- a/osi/BUILD.gn
+++ b/osi/BUILD.gn
@@ -14,7 +14,7 @@
 #  limitations under the License.
 #
 
-source_set("osi") {
+static_library("osi") {
   sources = [
     "src/alarm.c",
     "src/allocation_tracker.c",
@@ -41,8 +41,6 @@
     "include",
     "//"
   ]
-
-  libs = [ "-lpthread", "-lrt" ]
 }
 
 executable("net_test_osi") {
diff --git a/stack/BUILD.gn b/stack/BUILD.gn
index 3740a0a..c224e19 100644
--- a/stack/BUILD.gn
+++ b/stack/BUILD.gn
@@ -14,7 +14,7 @@
 #  limitations under the License.
 #
 
-source_set("stack") {
+static_library("stack") {
   sources = [
     "a2dp/a2d_api.c",
     "a2dp/a2d_sbc.c",
@@ -45,6 +45,7 @@
     "btm/btm_ble_multi_adv.c",
     "btm/btm_ble_batchscan.c",
     "btm/btm_ble_cont_energy.c",
+    "btm/btm_ble_privacy.c",
     "btm/btm_acl.c",
     "btm/btm_sco.c",
     "btm/btm_pm.c",
@@ -87,6 +88,10 @@
     "smp/smp_keys.c",
     "smp/smp_api.c",
     "smp/aes.c",
+    "smp/smp_br_main.c",
+    "smp/p_256_curvepara.c",
+    "smp/p_256_ecc_pp.c",
+    "smp/p_256_multprecision.c",
     "avdt/avdt_ccb.c",
     "avdt/avdt_scb_act.c",
     "avdt/avdt_msg.c",
@@ -124,7 +129,8 @@
     "l2cap/l2cap_client.c",
     "gap/gap_api.c",
     "gap/gap_ble.c",
-    "//vnd/ble/vendor_ble.c",
+    "gap/gap_conn.c",
+    "gap/gap_utils.c",
   ]
 
   include_dirs = [
@@ -161,8 +167,7 @@
     "//",
   ]
 
-  deps = [ "//hci" ]
-
+  # TODO(armansito): Remove all of these flags.
   cflags = [
     "-Wno-unused-variable",
     "-Wno-unused-value",
diff --git a/utils/BUILD.gn b/utils/BUILD.gn
index 961bc7c..2b7dc59 100644
--- a/utils/BUILD.gn
+++ b/utils/BUILD.gn
@@ -14,16 +14,14 @@
 #  limitations under the License.
 #
 
-source_set("utils") {
+static_library("utils") {
   sources = [
     "src/bt_utils.c"
   ]
 
   include_dirs = [
     "include",
-    "//btcore/include",
-    "//osi/include",
-    "//stack/include",
     "//",
+    "//stack/include",
   ]
 }