diff options
author | Ole Troan <otroan@employees.org> | 2023-05-11 22:02:30 +0200 |
---|---|---|
committer | Ole Troan <otroan@employees.org> | 2023-05-11 22:04:46 +0200 |
commit | 683bdb6743e0568bbf02c1f4953d3f73e6f2b544 (patch) | |
tree | a3a464b75713b5aee961b5d5708b1c2274f0e7bf /src/tools | |
parent | 0b7200f7eef8881018c1e6dfb7ef10cf1e221362 (diff) |
vppapigen: support counters only .api
In some cases an .api file may contain only counter definitions.
If so do not generate the setup_msg functions.
Type: improvement
Change-Id: Idf89a7a5ab135428e9577726bc356acfd7c30113
Signed-off-by: Ole Troan <otroan@employees.org>
Diffstat (limited to 'src/tools')
-rwxr-xr-x | src/tools/vppapigen/vppapigen_c.py | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/tools/vppapigen/vppapigen_c.py b/src/tools/vppapigen/vppapigen_c.py index 26a348f3910..41317f89a16 100755 --- a/src/tools/vppapigen/vppapigen_c.py +++ b/src/tools/vppapigen/vppapigen_c.py @@ -1524,14 +1524,15 @@ def generate_c_boilerplate(services, defines, counters, file_crc, module, stream """ write(hdr.format(module=module)) - write("static u16\n") - write("setup_message_id_table (void) {\n") - write(" api_main_t *am = my_api_main;\n") - write(" vl_msg_api_msg_config_t c;\n") - write( - ' u16 msg_id_base = vl_msg_api_get_msg_ids ("{}_{crc:08x}", ' - "VL_MSG_{m}_LAST);\n".format(module, crc=file_crc, m=module.upper()) - ) + if len(defines) > 0: + write("static u16\n") + write("setup_message_id_table (void) {\n") + write(" api_main_t *am = my_api_main;\n") + write(" vl_msg_api_msg_config_t c;\n") + write( + ' u16 msg_id_base = vl_msg_api_get_msg_ids ("{}_{crc:08x}", ' + "VL_MSG_{m}_LAST);\n".format(module, crc=file_crc, m=module.upper()) + ) for d in defines: write( @@ -1605,9 +1606,9 @@ def generate_c_boilerplate(services, defines, counters, file_crc, module, stream write(" vl_msg_api_config (&c);\n") except KeyError: pass - - write(" return msg_id_base;\n") - write("}\n") + if len(defines) > 0: + write(" return msg_id_base;\n") + write("}\n") severity = { "error": "VL_COUNTER_SEVERITY_ERROR", |