Import foxglove schemas repo
This has to do a couple of things:
* Actually import the repo as an http_archive.
* Modify the cc_static_flatbuffer rule to allow it to handle a
flatbuffer target with multiple fbs files.
* Move foxglove-related third_party files into one directory.
Change-Id: I0123fc8037b107019f9c29b781418c9a03639eca
Signed-off-by: James Kuszmaul <jabukuszmaul@gmail.com>
diff --git a/aos/flatbuffers.bzl b/aos/flatbuffers.bzl
index 3db4ca0..c26906a 100644
--- a/aos/flatbuffers.bzl
+++ b/aos/flatbuffers.bzl
@@ -1,16 +1,18 @@
-def cc_static_flatbuffer(name, target, function, visibility = None):
+def cc_static_flatbuffer(name, target, function, bfbs_name = None, visibility = None):
"""Creates a cc_library which encodes a file as a Span.
args:
target, The file to encode.
function, The inline function, with full namespaces, to create.
+ bfbs_name, For flatbuffer targets that have multiple fbs files, this
+ specifies the basename of the bfbs file to generate a schema for.
"""
native.genrule(
name = name + "_gen",
tools = ["@org_frc971//aos:flatbuffers_static"],
srcs = [target],
outs = [name + ".h"],
- cmd = "$(location @org_frc971//aos:flatbuffers_static) $(SRCS) $(OUTS) '" + function + "'",
+ cmd = "$(location @org_frc971//aos:flatbuffers_static) '$(SRCS)' $(OUTS) '" + function + "' " + (bfbs_name if bfbs_name else "-"),
)
native.cc_library(
diff --git a/aos/flatbuffers_static.py b/aos/flatbuffers_static.py
index 199c5b9..3bd28fe 100644
--- a/aos/flatbuffers_static.py
+++ b/aos/flatbuffers_static.py
@@ -8,12 +8,26 @@
def main(argv):
- if len(argv) != 4:
+ if len(argv) != 5:
+ print(
+ f"Incorrect number of arguments {len(argv)} to flatbuffers_static."
+ )
+ print(argv)
return 1
input_path = sys.argv[1]
output_path = sys.argv[2]
function = sys.argv[3].split("::")
+ bfbs_name = sys.argv[4]
+ if bfbs_name != '-':
+ inputs = input_path.split(' ')
+ valid_paths = [path for path in inputs if path.endswith(bfbs_name)]
+ if len(valid_paths) != 1:
+ print(
+ f"Expected exactly one match for {bfbs_name}; got {valid_paths}."
+ )
+ return 1
+ input_path = valid_paths[0]
include_guard = output_path.replace('/', '_').replace('-', '_').replace(
'.', '_').upper() + '_'