Stephan Pleines | 6191f1d | 2024-05-30 20:44:45 -0700 | [diff] [blame] | 1 | #include <stdlib.h> |
| 2 | |
Austin Schuh | 99f7c6a | 2024-06-25 22:07:44 -0700 | [diff] [blame] | 3 | #include "absl/flags/flag.h" |
James Kuszmaul | f5eb468 | 2023-09-22 17:16:59 -0700 | [diff] [blame] | 4 | #include "flatbuffers/reflection_generated.h" |
| 5 | |
| 6 | #include "aos/flatbuffers.h" |
| 7 | #include "aos/flatbuffers/static_flatbuffers.h" |
| 8 | #include "aos/init.h" |
| 9 | #include "aos/json_to_flatbuffer.h" |
| 10 | #include "aos/util/file.h" |
| 11 | |
Austin Schuh | 99f7c6a | 2024-06-25 22:07:44 -0700 | [diff] [blame] | 12 | ABSL_FLAG(std::string, reflection_bfbs, "", |
| 13 | "Path to the .bfbs reflection file."); |
| 14 | ABSL_FLAG(std::string, output_file, "", "Path to the output header to write."); |
| 15 | ABSL_FLAG(std::string, base_file_name, "", |
| 16 | "Name of the base file to generate code for as used by the " |
| 17 | "reflection::Schema object."); |
James Kuszmaul | f5eb468 | 2023-09-22 17:16:59 -0700 | [diff] [blame] | 18 | |
| 19 | namespace aos::fbs { |
| 20 | int Main() { |
| 21 | aos::FlatbufferVector<reflection::Schema> schema = |
Austin Schuh | 99f7c6a | 2024-06-25 22:07:44 -0700 | [diff] [blame] | 22 | aos::FileToFlatbuffer<reflection::Schema>( |
| 23 | absl::GetFlag(FLAGS_reflection_bfbs)); |
James Kuszmaul | f5eb468 | 2023-09-22 17:16:59 -0700 | [diff] [blame] | 24 | aos::util::WriteStringToFileOrDie( |
Austin Schuh | 99f7c6a | 2024-06-25 22:07:44 -0700 | [diff] [blame] | 25 | absl::GetFlag(FLAGS_output_file), |
| 26 | GenerateCodeForRootTableFile(&schema.message(), |
| 27 | absl::GetFlag(FLAGS_base_file_name))); |
James Kuszmaul | f5eb468 | 2023-09-22 17:16:59 -0700 | [diff] [blame] | 28 | return EXIT_SUCCESS; |
| 29 | } |
| 30 | } // namespace aos::fbs |
| 31 | int main(int argc, char *argv[]) { |
| 32 | aos::InitGoogle(&argc, &argv); |
| 33 | return aos::fbs::Main(); |
| 34 | } |