blob: 9a2e5fdfaf0a65582383c8ce049745d6481dbbd0 [file] [log] [blame]
Stephan Pleines6191f1d2024-05-30 20:44:45 -07001#include <stdlib.h>
2
James Kuszmaulf5eb4682023-09-22 17:16:59 -07003#include "flatbuffers/reflection_generated.h"
Stephan Pleines6191f1d2024-05-30 20:44:45 -07004#include "gflags/gflags.h"
James Kuszmaulf5eb4682023-09-22 17:16:59 -07005
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
12DEFINE_string(reflection_bfbs, "", "Path to the .bfbs reflection file.");
13DEFINE_string(output_file, "", "Path to the output header to write.");
James Kuszmaul9a2d5f02023-12-14 11:38:35 -080014DEFINE_string(base_file_name, "",
15 "Name of the base file to generate code for as used by the "
16 "reflection::Schema object.");
James Kuszmaulf5eb4682023-09-22 17:16:59 -070017
18namespace aos::fbs {
19int Main() {
20 aos::FlatbufferVector<reflection::Schema> schema =
21 aos::FileToFlatbuffer<reflection::Schema>(FLAGS_reflection_bfbs);
22 aos::util::WriteStringToFileOrDie(
James Kuszmaul9a2d5f02023-12-14 11:38:35 -080023 FLAGS_output_file,
24 GenerateCodeForRootTableFile(&schema.message(), FLAGS_base_file_name));
James Kuszmaulf5eb4682023-09-22 17:16:59 -070025 return EXIT_SUCCESS;
26}
27} // namespace aos::fbs
28int main(int argc, char *argv[]) {
29 aos::InitGoogle(&argc, &argv);
30 return aos::fbs::Main();
31}