mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-03 04:21:13 +00:00
Implement --file-names-only (#8788)
* flatc builds and seems to work, some of the extra targets are having linker errors * fix build system * pipeline failures * un-rename files * refactor to use unique_ptr * typo * rm make_unique, add comments * fix cmake --------- Co-authored-by: Wouter van Oortmerssen <aardappel@gmail.com>
This commit is contained in:
@@ -181,9 +181,25 @@ int main(int argc, const char* argv[]) {
|
||||
flatbuffers::NewTsCodeGenerator());
|
||||
|
||||
// Create the FlatC options by parsing the command line arguments.
|
||||
const flatbuffers::FlatCOptions& options =
|
||||
flatbuffers::FlatCOptions options =
|
||||
flatc.ParseFromCommandLineArguments(argc, argv);
|
||||
|
||||
// this exists here to ensure file_saver outlives the compilation process
|
||||
std::unique_ptr<flatbuffers::FileSaver> file_saver;
|
||||
if (options.file_names_only) {
|
||||
file_saver.reset(new flatbuffers::FileNameSaver{});
|
||||
} else {
|
||||
file_saver.reset(new flatbuffers::RealFileSaver{});
|
||||
}
|
||||
|
||||
options.opts.file_saver = file_saver.get();
|
||||
FLATBUFFERS_ASSERT(options.opts.file_saver);
|
||||
|
||||
// Compile with the extracted FlatC options.
|
||||
return flatc.Compile(options);
|
||||
int success = flatc.Compile(options);
|
||||
|
||||
// print file names if file-names-only option is set
|
||||
options.opts.file_saver->Finish();
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user