James Kuszmaul | f5eb468 | 2023-09-22 17:16:59 -0700 | [diff] [blame] | 1 | #include "flatbuffers/reflection_generated.h" |
| 2 | |
| 3 | #include "aos/flatbuffers.h" |
| 4 | #include "aos/flatbuffers/static_flatbuffers.h" |
| 5 | #include "aos/init.h" |
| 6 | #include "aos/json_to_flatbuffer.h" |
| 7 | #include "aos/util/file.h" |
| 8 | |
| 9 | DEFINE_string(reflection_bfbs, "", "Path to the .bfbs reflection file."); |
| 10 | DEFINE_string(output_file, "", "Path to the output header to write."); |
James Kuszmaul | 9a2d5f0 | 2023-12-14 11:38:35 -0800 | [diff] [blame] | 11 | DEFINE_string(base_file_name, "", |
| 12 | "Name of the base file to generate code for as used by the " |
| 13 | "reflection::Schema object."); |
James Kuszmaul | f5eb468 | 2023-09-22 17:16:59 -0700 | [diff] [blame] | 14 | |
| 15 | namespace aos::fbs { |
| 16 | int Main() { |
| 17 | aos::FlatbufferVector<reflection::Schema> schema = |
| 18 | aos::FileToFlatbuffer<reflection::Schema>(FLAGS_reflection_bfbs); |
| 19 | aos::util::WriteStringToFileOrDie( |
James Kuszmaul | 9a2d5f0 | 2023-12-14 11:38:35 -0800 | [diff] [blame] | 20 | FLAGS_output_file, |
| 21 | GenerateCodeForRootTableFile(&schema.message(), FLAGS_base_file_name)); |
James Kuszmaul | f5eb468 | 2023-09-22 17:16:59 -0700 | [diff] [blame] | 22 | return EXIT_SUCCESS; |
| 23 | } |
| 24 | } // namespace aos::fbs |
| 25 | int main(int argc, char *argv[]) { |
| 26 | aos::InitGoogle(&argc, &argv); |
| 27 | return aos::fbs::Main(); |
| 28 | } |