Create a "static" flatbuffer API

This provides a generated API for working with flatbuffer objects that
generates a statically determined layout for the flatbuffer and uses
that layout to construct the flatbuffer without needing to dynamically
allocate any memory. For situations where dynamic sizing is appropriate,
this API does allow for increasing the size of any vectors in the
flatbuffer objects.

This change includes a checked-in version of the generated code so that
reviewers for this and future changes can readily examine what the
generated code looks like.

Future tasks:
* Support for unions?
* Consider precomputing some constants for sizes/alignments rather than
  massive constant expressions.

Change-Id: I6bf72d6c722d5390ab2239289a8a2a4e118c8d47
Signed-off-by: James Kuszmaul <james.kuszmaul@bluerivertech.com>
diff --git a/aos/flatbuffers/generate.cc b/aos/flatbuffers/generate.cc
new file mode 100644
index 0000000..2e081f3
--- /dev/null
+++ b/aos/flatbuffers/generate.cc
@@ -0,0 +1,24 @@
+#include "flatbuffers/reflection_generated.h"
+
+#include "aos/flatbuffers.h"
+#include "aos/flatbuffers/static_flatbuffers.h"
+#include "aos/init.h"
+#include "aos/json_to_flatbuffer.h"
+#include "aos/util/file.h"
+
+DEFINE_string(reflection_bfbs, "", "Path to the .bfbs reflection file.");
+DEFINE_string(output_file, "", "Path to the output header to write.");
+
+namespace aos::fbs {
+int Main() {
+  aos::FlatbufferVector<reflection::Schema> schema =
+      aos::FileToFlatbuffer<reflection::Schema>(FLAGS_reflection_bfbs);
+  aos::util::WriteStringToFileOrDie(
+      FLAGS_output_file, GenerateCodeForRootTableFile(&schema.message()));
+  return EXIT_SUCCESS;
+}
+}  // namespace aos::fbs
+int main(int argc, char *argv[]) {
+  aos::InitGoogle(&argc, &argv);
+  return aos::fbs::Main();
+}