Skip to content

Commit

Permalink
Alternative check for binary schema output to specified out file
Browse files Browse the repository at this point in the history
  • Loading branch information
mikkelfj committed Oct 26, 2023
1 parent 3d96495 commit 9d2c05d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion include/flatcc/flatcc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 5 additions & 4 deletions src/cli/flatcc_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
9 changes: 8 additions & 1 deletion src/compiler/flatcc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 9d2c05d

Please sign in to comment.