Austin Schuh | 0de30f3 | 2020-12-06 12:44:28 -0800 | [diff] [blame^] | 1 | def 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 | ) |