blob: eb19beb820788fd0009383d2e7aeda328a07a234 [file] [log] [blame]
Austin Schuh0de30f32020-12-06 12:44:28 -08001def cc_static_flatbuffer(name, target, function):
2 """Creates a cc_library which encodes a file as a Span.
3
4 args:
5 target, The file to encode.
6 function, The inline function, with full namespaces, to create.
7 """
8 native.genrule(
9 name = name + "_gen",
10 tools = ["//aos:flatbuffers_static"],
11 srcs = [target],
12 outs = [name + ".h"],
13 cmd = "$(location //aos:flatbuffers_static) $(SRCS) $(OUTS) '" + function + "'",
14 )
15
16 native.cc_library(
17 name = name,
18 hdrs = [name + ".h"],
19 deps = [
20 "@com_google_absl//absl/types:span",
21 ],
22 )