Fix includes of reflection.fbs with static flatbuffer API
Because the base reflection_generated.h needs to be available to flatc
at compile-time, it gets checked into the repository. On top of this,
flatc special-cases `reflection/reflection.fbs` for inclusion, so we
need to treat it special in our #include paths as well.
This makes it so that we codegen the reflection_static.h from
reflection.fbs, and introduces a requirements that any flatbuffer files
which use the reflection.fbs must depend on
@aos//aos/flatbuffers/reflection:reflection_fbs
Change-Id: I22a11e86052b7bd90efadb209a7529ff58b6e0ca
Signed-off-by: James Kuszmaul <james.kuszmaul@bluerivertech.com>
diff --git a/aos/flatbuffers/reflection/BUILD.bazel b/aos/flatbuffers/reflection/BUILD.bazel
new file mode 100644
index 0000000..475f2a2
--- /dev/null
+++ b/aos/flatbuffers/reflection/BUILD.bazel
@@ -0,0 +1,18 @@
+load("@aspect_bazel_lib//lib:copy_file.bzl", "copy_file")
+load("//aos/flatbuffers:generate.bzl", "static_flatbuffer")
+
+copy_file(
+ name = "reflection_fbs_copy",
+ src = "@com_github_google_flatbuffers//reflection:reflection_fbs_schema",
+ out = "reflection.fbs",
+)
+
+# This autogenerates both a reflection_static.h and a reflection_generated.h.
+# However, in order to avoid having two conflicting headers floating around,
+# we forcibly override the #include to use flatbuffers/reflection_generated.h
+# in static_flatbuffers.cc
+static_flatbuffer(
+ name = "reflection_fbs",
+ srcs = ["reflection.fbs"],
+ visibility = ["//visibility:public"],
+)