From 9d2c05deed2cd9a0323216cc4a74c0ead6571174 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikkel=20Fahn=C3=B8e=20J=C3=B8rgensen?= Date: Thu, 26 Oct 2023 15:01:00 +0200 Subject: [PATCH] Alternative check for binary schema output to specified out file --- include/flatcc/flatcc.h | 2 +- src/cli/flatcc_cli.c | 9 +++++---- src/compiler/flatcc.c | 9 ++++++++- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/include/flatcc/flatcc.h b/include/flatcc/flatcc.h index 04eb187f4..4098690f0 100644 --- a/include/flatcc/flatcc.h +++ b/include/flatcc/flatcc.h @@ -84,7 +84,7 @@ struct flatcc_options { int cgen_recursive; int cgen_spacing; int cgen_no_conflicts; - + int cgen; int bgen_bfbs; int bgen_qualify_names; diff --git a/src/cli/flatcc_cli.c b/src/cli/flatcc_cli.c index ee5b40385..7d57cc05a 100644 --- a/src/cli/flatcc_cli.c +++ b/src/cli/flatcc_cli.c @@ -406,7 +406,7 @@ int main(int argc, const char *argv[]) { flatcc_options_t opts; flatcc_context_t ctx = 0; - int i, ret, cgen; + int i, ret; const char **src; ctx = 0; @@ -447,14 +447,15 @@ int main(int argc, const char *argv[]) ctx = 0; goto done; } - cgen = opts.cgen_reader || opts.cgen_builder || opts.cgen_verifier + opts.cgen = opts.cgen_reader || opts.cgen_builder || opts.cgen_verifier || opts.cgen_common_reader || opts.cgen_common_builder || opts.cgen_json_parser || opts.cgen_json_printer; - if (!opts.bgen_bfbs && (!cgen || opts.cgen_builder || opts.cgen_verifier)) { + if (!opts.bgen_bfbs && (!opts.cgen || opts.cgen_builder || opts.cgen_verifier)) { /* Assume default if no other output specified when deps required it. */ opts.cgen_reader = 1; + opts.cgen = 1; } - if (opts.bgen_bfbs && cgen) { + if (opts.bgen_bfbs && opts.cgen) { if (opts.gen_stdout) { fprintf(stderr, "--stdout cannot be used with mixed text and binary output\n"); goto fail; diff --git a/src/compiler/flatcc.c b/src/compiler/flatcc.c index e9fa0a1ad..b55897d7f 100644 --- a/src/compiler/flatcc.c +++ b/src/compiler/flatcc.c @@ -471,12 +471,19 @@ int flatcc_generate_files(flatcc_context_t ctx) } } #endif - +#ifdef PR216 + /* Note: P->opts.cgen now represents the below expression, and bfbs_gen is mutually exclusive with cgen */ if (!(P->opts.cgen_reader | P->opts.cgen_builder | P->opts.cgen_verifier | P->opts.cgen_common_reader | P->opts.cgen_common_builder | P->opts.cgen_json_parser | P->opts.cgen_json_printer)) { return 0; } +#else + /* Experimental alternative to PR216 */ + if (P->opts.bgen_bfbs) { + return 0; + } +#endif if (fb_init_output_c(out, &P->opts)) { return -1; }