More work cleaning up the BUILD files

Change-Id: I47fb18e7a12cd7e081631a5369274ef1e25f22c4
diff --git a/aos/common/BUILD b/aos/common/BUILD
index ccb9191..06ba2c6 100644
--- a/aos/common/BUILD
+++ b/aos/common/BUILD
@@ -18,6 +18,7 @@
     'queue_testutils.h',
   ],
   deps = [
+    '//aos/testing:googletest',
     '//aos/common/logging',
     ':once',
     '//aos/linux_code/ipc_lib:shared_mem',
@@ -56,16 +57,24 @@
 )
 
 cc_library(
+  name = 'generated_queue_headers',
+  visibility = ['//aos/common/logging:__pkg__'],
+  hdrs = [
+    ':gen_queue_primitives',
+  ],
+)
+
+cc_library(
   name = 'queue_types',
   srcs = [
     'queue_types.cc',
-    ':gen_queue_primitives',
     ':gen_print_field',
   ],
   hdrs = [
     'queue_types.h',
   ],
   deps = [
+    ':generated_queue_headers',
     '//aos/common/logging:logging_interface',
     '//aos/linux_code/ipc_lib:shared_mem',
     '//aos/linux_code/ipc_lib:core_lib',
@@ -81,7 +90,7 @@
   ],
   deps = [
     ':queue_types',
-    '//third_party/gtest',
+    '//aos/testing:googletest',
     ':test_queue',
     '//aos/common/logging',
     ':queue_testutils',
@@ -115,7 +124,7 @@
     'queue_test.cc',
   ],
   deps = [
-    '//third_party/gtest',
+    '//aos/testing:googletest',
     ':queue_testutils',
     ':test_queue',
     '//aos/common/util:thread',
@@ -129,7 +138,7 @@
     'type_traits_test.cpp',
   ],
   deps = [
-    '//third_party/gtest',
+    '//aos/testing:googletest',
   ],
 )
 
@@ -150,7 +159,7 @@
     'once_test.cc',
   ],
   deps = [
-    '//third_party/gtest',
+    '//aos/testing:googletest',
     ':once',
   ],
 )
@@ -161,7 +170,7 @@
     'time_test.cc',
   ],
   deps = [
-    '//third_party/gtest',
+    '//aos/testing:googletest',
     ':time',
     '//aos/common/logging',
     '//aos/common/util:death_test_log_implementation',
@@ -187,7 +196,7 @@
     'queue_testutils_test.cc',
   ],
   deps = [
-    '//third_party/gtest',
+    '//aos/testing:googletest',
     ':queue_testutils',
     '//aos/common/logging',
   ],
@@ -199,7 +208,7 @@
     'mutex_test.cc',
   ],
   deps = [
-    '//third_party/gtest',
+    '//aos/testing:googletest',
     '//aos/linux_code/ipc_lib:mutex',
     ':die',
     '//aos/common/logging',
@@ -216,8 +225,8 @@
     'event_test.cc',
   ],
   deps = [
-    '//third_party/gtest',
-    ':event',
+    '//aos/testing:googletest',
+    '//aos/linux_code/ipc_lib:event',
     ':queue_testutils',
     ':time',
   ],
@@ -229,8 +238,8 @@
     'condition_test.cc',
   ],
   deps = [
-    '//third_party/gtest',
-    ':condition',
+    '//aos/testing:googletest',
+    '//aos/linux_code/ipc_lib:condition',
     '//aos/common/util:thread',
     ':time',
     '//aos/linux_code/ipc_lib:mutex',
@@ -248,7 +257,7 @@
     'die_test.cc',
   ],
   deps = [
-    '//third_party/gtest',
+    '//aos/testing:googletest',
     ':die',
   ],
 )
@@ -268,7 +277,7 @@
   ],
   deps = [
     ':stl_mutex',
-    '//third_party/gtest',
+    '//aos/testing:googletest',
     ':queue_testutils',
     '//aos/common/util:thread',
     ':die',
diff --git a/aos/common/actions/BUILD b/aos/common/actions/BUILD
index 22db816..6669ef1 100644
--- a/aos/common/actions/BUILD
+++ b/aos/common/actions/BUILD
@@ -45,7 +45,7 @@
     'action_test.cc',
   ],
   deps = [
-    '//third_party/gtest',
+    '//aos/testing:googletest',
     ':action_lib',
     ':test_action_queue',
     '//aos/common:queue_testutils',
diff --git a/aos/common/common.gyp b/aos/common/common.gyp
index ff8cbe2..c9e1b6a 100644
--- a/aos/common/common.gyp
+++ b/aos/common/common.gyp
@@ -44,7 +44,7 @@
       'type': 'static_library',
       'variables': {
         'print_field_cc': '<(SHARED_INTERMEDIATE_DIR)/print_field.cc',
-        'queue_primitives_h': '<(SHARED_INTERMEDIATE_DIR)/aos_queue_primitives/aos/queue_primitives.h',
+        'queue_primitives_h': '<(SHARED_INTERMEDIATE_DIR)/aos_queue_primitives/aos/common/queue_primitives.h',
       },
       'sources': [
         'queue_types.cc',
diff --git a/aos/common/controls/BUILD b/aos/common/controls/BUILD
index c021714..6c0805c 100644
--- a/aos/common/controls/BUILD
+++ b/aos/common/controls/BUILD
@@ -24,7 +24,7 @@
   deps = [
     '//aos/common:time',
     '//aos/common/messages:robot_state',
-    '//third_party/gtest',
+    '//aos/testing:googletest',
     '//aos/common:queue_testutils',
   ],
 )
@@ -33,7 +33,7 @@
   name = 'polytope',
   deps = [
     '//third_party/eigen',
-    '//third_party/libcdd',
+    '//third_party/cddlib',
   ],
 )
 
diff --git a/aos/common/controls/polytope.h b/aos/common/controls/polytope.h
index e37346e..1ca1ec6 100644
--- a/aos/common/controls/polytope.h
+++ b/aos/common/controls/polytope.h
@@ -2,8 +2,13 @@
 #define AOS_COMMON_CONTROLS_POLYTOPE_H_
 
 #include "Eigen/Dense"
+#ifdef AOS_BAZEL
+#include "third_party/cddlib/lib-src/setoper.h"
+#include "third_party/cddlib/lib-src/cdd.h"
+#else
 #include "libcdd-094g-prefix/include/setoper.h"
 #include "libcdd-094g-prefix/include/cdd.h"
+#endif
 
 namespace aos {
 namespace controls {
diff --git a/aos/common/libc/BUILD b/aos/common/libc/BUILD
index ad88f9d..5db9257 100644
--- a/aos/common/libc/BUILD
+++ b/aos/common/libc/BUILD
@@ -20,7 +20,7 @@
   ],
   deps = [
     ':aos_strsignal',
-    '//third_party/gtest',
+    '//aos/testing:googletest',
     '//aos/common/logging',
   ],
 )
@@ -42,7 +42,7 @@
   ],
   deps = [
     ':dirname',
-    '//third_party/gtest',
+    '//aos/testing:googletest',
   ],
 )
 
@@ -63,6 +63,6 @@
   ],
   deps = [
     ':aos_strerror',
-    '//third_party/gtest',
+    '//aos/testing:googletest',
   ],
 )
diff --git a/aos/common/logging/BUILD b/aos/common/logging/BUILD
index 82aaf16..8bd59b9 100644
--- a/aos/common/logging/BUILD
+++ b/aos/common/logging/BUILD
@@ -6,7 +6,7 @@
     'logging_impl_test.cc',
   ],
   deps = [
-    '//third_party/gtest',
+    '//aos/testing:googletest',
     '//aos/common/logging',
   ],
 )
@@ -35,6 +35,7 @@
     'matrix_logging.h',
   ],
   deps = [
+    '//aos/common:generated_queue_headers',
     '//aos/common/logging',
     '//aos/common:die',
     '//aos/common:queue_types',
@@ -58,7 +59,6 @@
   name = 'logging',
   srcs = [
     'logging_impl.cc',
-    'linux_logging.cc',
   ],
   deps = [
     '//aos/linux_code/logging:linux_logging',
diff --git a/aos/common/logging/matrix_logging-tmpl.h b/aos/common/logging/matrix_logging-tmpl.h
index bfc3ce5..9e458fb 100644
--- a/aos/common/logging/matrix_logging-tmpl.h
+++ b/aos/common/logging/matrix_logging-tmpl.h
@@ -2,7 +2,7 @@
 
 #include <functional>
 
-#include "aos/queue_primitives.h"
+#include "aos/common/queue_primitives.h"
 
 namespace aos {
 namespace logging {
diff --git a/aos/common/queue_types_test.cc b/aos/common/queue_types_test.cc
index 868820f..b8b5e47 100644
--- a/aos/common/queue_types_test.cc
+++ b/aos/common/queue_types_test.cc
@@ -8,7 +8,7 @@
 
 #include "aos/common/test_queue.q.h"
 #include "aos/common/byteorder.h"
-#include "aos/queue_primitives.h"
+#include "aos/common/queue_primitives.h"
 #include "aos/common/logging/logging.h"
 #include "aos/common/queue_testutils.h"
 
diff --git a/aos/common/util/BUILD b/aos/common/util/BUILD
index 2409e00..dedec24 100644
--- a/aos/common/util/BUILD
+++ b/aos/common/util/BUILD
@@ -20,7 +20,7 @@
   ],
   deps = [
     ':run_command',
-    '//third_party/gtest',
+    '//aos/testing:googletest',
     '//aos/common/logging',
     ':thread',
   ],
@@ -76,7 +76,7 @@
   ],
   deps = [
     ':string_to_num',
-    '//third_party/gtest',
+    '//aos/testing:googletest',
   ],
 )
 
@@ -112,7 +112,7 @@
   ],
   deps = [
     ':trapezoid_profile',
-    '//third_party/gtest',
+    '//aos/testing:googletest',
   ],
 )
 
@@ -133,7 +133,7 @@
   ],
   deps = [
     ':wrapping_counter',
-    '//third_party/gtest',
+    '//aos/testing:googletest',
   ],
 )
 
@@ -143,6 +143,6 @@
     'options_test.cc',
   ],
   deps = [
-    '//third_party/gtest',
+    '//aos/testing:googletest',
   ],
 )