X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Ftools%2Fvppapigen%2Fnode.c;h=37ba4931a1f72855300000b4751da2658a13a530;hb=0d056e5ede136cd0111dc3f9f41ef7b36a938027;hp=359ac9c918d007eccd82cdef41400f238841cd94;hpb=a80ab84531fb1abd1e896d1adfa7e50fed80db39;p=vpp.git diff --git a/src/tools/vppapigen/node.c b/src/tools/vppapigen/node.c index 359ac9c918d..37ba4931a1f 100644 --- a/src/tools/vppapigen/node.c +++ b/src/tools/vppapigen/node.c @@ -39,7 +39,7 @@ time_t starttime; char *vlib_app_name; char *input_filename; node_vft_t *the_vft[NODE_N_TYPES]; -static int indent; +static u32 indent; static int dont_output_version; int dump_tree; static char *fixed_name; @@ -397,7 +397,7 @@ void node_define_generate (node_t *this, enum passid which, FILE *fp) fprintf(fp, ",\n"); } indent_me(fp); - fprintf (fp, "{\"crc\" : \"0x%08x\"}\n", (u32)(u64)CDATA3); + fprintf (fp, "{\"crc\" : \"0x%08x\"}\n", (u32)(uword)CDATA3); indent -= 4; indent_me(fp); fprintf(fp, "]"); @@ -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, }; @@ -1050,6 +1067,11 @@ YYSTYPE set_flags(YYSTYPE a1, YYSTYPE a2) flags = (int)(uword) a1; np->flags |= flags; + + /* Generate a foo_reply_t right here */ + if (flags & NODE_FLAG_AUTOREPLY) + autoreply(np); + return (a2); } /* @@ -1109,7 +1131,12 @@ char *fixup_input_filename(void) void generate_top_boilerplate(FILE *fp) { - char *datestring = ctime(&starttime); + time_t curtime; + char *datestring; + char *source_date_epoch; + if ((source_date_epoch = getenv("SOURCE_DATE_EPOCH")) == NULL || (curtime = (time_t)strtol(source_date_epoch, NULL, 10)) <= 0) + curtime = starttime; + datestring = asctime(gmtime(&curtime)); fixed_name = fixup_input_filename(); datestring[24] = 0; @@ -1123,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); @@ -1134,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"); @@ -1143,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"); } @@ -1214,7 +1244,7 @@ void generate_msg_name_crc_list (YYSTYPE a1, FILE *fp) if (!(np->flags & NODE_FLAG_TYPEONLY)) { fprintf (fp, "\\\n_(VL_API_%s, %s, %08x) ", uppercase (np->data[0]), (i8 *) np->data[0], - (u32)(u64)np->data[3]); + (u32)(uword)np->data[3]); } } np = np->peer; @@ -1406,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; @@ -1507,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) { @@ -1525,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); }