Add a simple proto_cc_library rule

It only supports a single .proto file without any dependencies, but
that's enough for now.

Change-Id: Ibd80c8594b90956c3c5b0b46db10cf991d7ed1ad
diff --git a/build_tests/BUILD b/build_tests/BUILD
index cce2e01..be6a201 100644
--- a/build_tests/BUILD
+++ b/build_tests/BUILD
@@ -1,5 +1,6 @@
 load('/tools/build_rules/ruby', 'ruby_binary')
 load('/aos/build/queues', 'queue_library')
+load('/tools/build_rules/protobuf', 'proto_cc_library')
 
 cc_test(
   name = 'gflags_build_test',
@@ -69,3 +70,20 @@
   ],
   size = 'small',
 )
+
+proto_cc_library(
+  name = 'proto_build_test_library',
+  src = 'proto.proto',
+)
+
+cc_test(
+  name = 'proto_build_test',
+  srcs = [
+    'proto.cc',
+  ],
+  deps = [
+    ':proto_build_test_library',
+    '//aos/testing:googletest',
+  ],
+  size = 'small',
+)
diff --git a/build_tests/proto.cc b/build_tests/proto.cc
new file mode 100644
index 0000000..23ff879
--- /dev/null
+++ b/build_tests/proto.cc
@@ -0,0 +1,16 @@
+#include "gtest/gtest.h"
+
+#include "build_tests/proto.pb.h"
+
+TEST(ProtoBuildTest, Serialize) {
+  ::frc971::TestProto test_proto1, test_proto2;
+  test_proto1.set_s("Hi!");
+  test_proto1.set_i(971);
+
+  ::std::string serialized;
+  ASSERT_TRUE(test_proto1.SerializeToString(&serialized));
+  ASSERT_TRUE(test_proto2.ParseFromString(serialized));
+
+  EXPECT_EQ("Hi!", test_proto2.s());
+  EXPECT_EQ(971, test_proto2.i());
+}
diff --git a/build_tests/proto.proto b/build_tests/proto.proto
new file mode 100644
index 0000000..367a650
--- /dev/null
+++ b/build_tests/proto.proto
@@ -0,0 +1,12 @@
+syntax = "proto3";
+
+package frc971;
+
+import "google/protobuf/empty.proto";
+
+message TestProto {
+  string s = 1;
+  int32 i = 2;
+  // Making sure that well-known protos work.
+  .google.protobuf.Empty empty = 3;
+}