blob: 4c76785f98ea3fcacf37c2afa6c46b1fa3cd74b7 [file] [log] [blame]
Stephan Pleines6191f1d2024-05-30 20:44:45 -07001#include <stdlib.h>
2
Austin Schuh99f7c6a2024-06-25 22:07:44 -07003#include "absl/flags/flag.h"
James Kuszmaulf5eb4682023-09-22 17:16:59 -07004#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 Schuh99f7c6a2024-06-25 22:07:44 -070012ABSL_FLAG(std::string, reflection_bfbs, "",
13 "Path to the .bfbs reflection file.");
14ABSL_FLAG(std::string, output_file, "", "Path to the output header to write.");
15ABSL_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 Kuszmaulf5eb4682023-09-22 17:16:59 -070018
19namespace aos::fbs {
20int Main() {
21 aos::FlatbufferVector<reflection::Schema> schema =
Austin Schuh99f7c6a2024-06-25 22:07:44 -070022 aos::FileToFlatbuffer<reflection::Schema>(
23 absl::GetFlag(FLAGS_reflection_bfbs));
James Kuszmaulf5eb4682023-09-22 17:16:59 -070024 aos::util::WriteStringToFileOrDie(
Austin Schuh99f7c6a2024-06-25 22:07:44 -070025 absl::GetFlag(FLAGS_output_file),
26 GenerateCodeForRootTableFile(&schema.message(),
27 absl::GetFlag(FLAGS_base_file_name)));
James Kuszmaulf5eb4682023-09-22 17:16:59 -070028 return EXIT_SUCCESS;
29}
30} // namespace aos::fbs
31int main(int argc, char *argv[]) {
32 aos::InitGoogle(&argc, &argv);
33 return aos::fbs::Main();
34}