Add flatbuffer to json using reflection schema

Change-Id: I6f32c0403a74ec951e6c730c4006ede3bc91099c
diff --git a/aos/BUILD b/aos/BUILD
index 8683d18..fca684b 100644
--- a/aos/BUILD
+++ b/aos/BUILD
@@ -336,6 +336,7 @@
 flatbuffer_cc_library(
     name = "json_to_flatbuffer_flatbuffer",
     srcs = ["json_to_flatbuffer.fbs"],
+    gen_reflections = 1,
 )
 
 cc_library(
@@ -359,7 +360,10 @@
 
 cc_library(
     name = "json_to_flatbuffer",
-    srcs = ["json_to_flatbuffer.cc"],
+    srcs = [
+        "flatbuffer_introspection.cc",
+        "json_to_flatbuffer.cc",
+    ],
     hdrs = ["json_to_flatbuffer.h"],
     visibility = ["//visibility:public"],
     deps = [
@@ -384,6 +388,23 @@
     ],
 )
 
+cc_test(
+    name = "flatbuffer_introspection_test",
+    srcs = [
+        "flatbuffer_introspection_test.cc",
+    ],
+    data = [
+        ":json_to_flatbuffer_flatbuffer_reflection_out",
+    ],
+    deps = [
+        ":json_to_flatbuffer",
+        ":json_to_flatbuffer_flatbuffer",
+        "//aos/testing:googletest",
+        "//aos/util:file",
+        "@com_github_google_flatbuffers//:flatbuffers",
+    ],
+)
+
 cc_library(
     name = "flatbuffer_merge",
     srcs = ["flatbuffer_merge.cc"],
@@ -440,6 +461,7 @@
         "testdata/expected.json",
         "//aos/events:config.fb.json",
         "//aos/events:ping.bfbs",
+        "//aos/events:pingpong_config.json",
         "//aos/events:pong.bfbs",
     ],
     deps = [
@@ -462,3 +484,18 @@
         "@com_github_google_glog//:glog",
     ],
 )
+
+cc_binary(
+    name = "log_fbs_shmem",
+    srcs = [
+        "log_fbs_shmem.cc",
+    ],
+    visibility = ["//visibility:public"],
+    deps = [
+        ":configuration",
+        ":json_to_flatbuffer",
+        "//aos:init",
+        "//aos/events:shm_event_loop",
+        "@com_github_google_glog//:glog",
+    ],
+)