blob: 3db4ca092f81d8e5898de868726a005256b603b5 [file] [log] [blame]
Austin Schuha9df9ad2021-06-16 14:49:39 -07001def cc_static_flatbuffer(name, target, function, visibility = None):
Austin Schuh0de30f32020-12-06 12:44:28 -08002 """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",
Austin Schuha9df9ad2021-06-16 14:49:39 -070010 tools = ["@org_frc971//aos:flatbuffers_static"],
Austin Schuh0de30f32020-12-06 12:44:28 -080011 srcs = [target],
12 outs = [name + ".h"],
Austin Schuha9df9ad2021-06-16 14:49:39 -070013 cmd = "$(location @org_frc971//aos:flatbuffers_static) $(SRCS) $(OUTS) '" + function + "'",
Austin Schuh0de30f32020-12-06 12:44:28 -080014 )
15
16 native.cc_library(
17 name = name,
18 hdrs = [name + ".h"],
19 deps = [
20 "@com_google_absl//absl/types:span",
21 ],
Austin Schuha9df9ad2021-06-16 14:49:39 -070022 visibility = visibility,
Austin Schuh0de30f32020-12-06 12:44:28 -080023 )