diff options
author | Dave Barach <dave@barachs.net> | 2017-09-28 15:11:16 -0400 |
---|---|---|
committer | Ole Troan <ot@cisco.com> | 2017-10-09 13:32:40 +0200 |
commit | 0d056e5ede136cd0111dc3f9f41ef7b36a938027 (patch) | |
tree | 2f7c61d50f922a55ab7da199e0304a581ee7516f /src/tools/vppapigen/node.c | |
parent | 87da476db0cd804e11463cc453a2bb41c6808542 (diff) |
vppapigen: support per-file (major,minor,patch) version stamps
Add one of these statements to foo.api:
vl_api_version 1.2.3
to generate a version tuple stanza in foo.api.h:
/****** Version tuple *****/
vl_api_version_tuple(foo, 1, 2, 3)
Change-Id: Ic514439e4677999daa8463a94f948f76b132ff15
Signed-off-by: Dave Barach <dave@barachs.net>
Signed-off-by: Ole Troan <ot@cisco.com>
Diffstat (limited to 'src/tools/vppapigen/node.c')
-rw-r--r-- | src/tools/vppapigen/node.c | 59 |
1 files changed, 57 insertions, 2 deletions
diff --git a/src/tools/vppapigen/node.c b/src/tools/vppapigen/node.c index 4c85a11305f..37ba4931a1f 100644 --- a/src/tools/vppapigen/node.c +++ b/src/tools/vppapigen/node.c @@ -832,6 +832,22 @@ node_vft_t node_noversion_vft = { 0, }; +void node_version_print (node_t *this) +{ + primtype_recursive_print (this, "version "); +} + +void node_version_generate (node_t *this, enum passid which, FILE *ofp) +{ + fprintf(stderr, "node_version_generate called...\n"); +} + +node_vft_t node_version_vft = { + node_version_print, + node_version_generate, + 0, +}; + void node_uword_print (node_t *this) { primtype_recursive_print(this, "uword "); @@ -866,6 +882,7 @@ node_vft_t *the_vft[NODE_N_TYPES] = { &node_vector_vft, &node_complex_vft, &node_noversion_vft, + &node_version_vft, &node_uword_vft, }; @@ -1133,7 +1150,8 @@ void generate_top_boilerplate(FILE *fp) fprintf (fp, "#if defined(vl_msg_id)||defined(vl_union_id)||"); fprintf (fp, "defined(vl_printfun) \\\n ||defined(vl_endianfun)||"); fprintf (fp, " defined(vl_api_version)||defined(vl_typedefs) \\\n"); - fprintf (fp, " ||defined(vl_msg_name)||defined(vl_msg_name_crc_list)\n"); + fprintf (fp, " ||defined(vl_msg_name)||defined(vl_msg_name_crc_list) \\\n"); + fprintf (fp, " ||defined(vl_api_version_tuple)\n"); fprintf (fp, "/* ok, something was selected */\n"); fprintf (fp, "#else\n"); fprintf (fp, "#warning no content included from %s\n", input_filename); @@ -1144,7 +1162,8 @@ void generate_top_boilerplate(FILE *fp) void generate_bottom_boilerplate(FILE *fp) { - fprintf (fp, "\n#ifdef vl_api_version\n"); + fprintf(fp, "/****** API CRC (whole file) *****/\n\n"); + fprintf (fp, "#ifdef vl_api_version\n"); if (dont_output_version) { fprintf (fp, "/* WARNING: API FILE VERSION CHECK DISABLED */\n"); @@ -1153,6 +1172,7 @@ void generate_bottom_boilerplate(FILE *fp) fprintf (fp, "vl_api_version(%s, 0x%08x)\n\n", fixed_name, (unsigned int)input_crc); + fprintf (fp, "#endif\n\n"); } @@ -1416,6 +1436,20 @@ void add_msg_ids(YYSTYPE a1) } } +/* + * add_scalar_vbl (char *name) + */ +YYSTYPE add_version (YYSTYPE a1, YYSTYPE a2, YYSTYPE a3) +{ + node_t *np; + + np = make_node(NODE_VERSION); + np->data[0] = (void *) a1; + np->data[1] = (void *) a2; + np->data[2] = (void *) a3; + return ((YYSTYPE) np); +} + void generate_python_msg_definitions(YYSTYPE a1, FILE *fp) { node_t *np = (node_t *)a1; @@ -1517,6 +1551,26 @@ void generate_json(YYSTYPE a1, FILE *fp) fprintf (fp, "}\n"); } +void generate_version_tuple(YYSTYPE a1, FILE *fp) +{ + node_t *this = (node_t *)a1; + + fprintf(fp, "/****** Version tuple *****/\n\n"); + + fprintf(fp, "#ifdef vl_api_version_tuple\n\n"); + + /* Walk the top-level node-list */ + while (this) { + if (this->type == NODE_VERSION) { + fprintf (fp, "vl_api_version_tuple(%s, %d, %d, %d)\n", + fixed_name, IDATA0, IDATA1, IDATA2); + } + this = this->peer; + } + + fprintf(fp, "\n#endif /* vl_api_version_tuple */\n\n"); +} + void generate(YYSTYPE a1) { if (dump_tree) { @@ -1535,6 +1589,7 @@ void generate(YYSTYPE a1) generate_uniondefs(a1, ofp); generate_printfun(a1, ofp); generate_endianfun(a1, ofp); + generate_version_tuple(a1, ofp); generate_bottom_boilerplate(ofp); } |