summaryrefslogtreecommitdiffstats
path: root/src/tools/vppapigen/vppapigen_c.py
diff options
context:
space:
mode:
authorOle Troan <otroan@employees.org>2023-05-11 22:02:30 +0200
committerOle Troan <otroan@employees.org>2023-05-11 22:04:46 +0200
commit683bdb6743e0568bbf02c1f4953d3f73e6f2b544 (patch)
treea3a464b75713b5aee961b5d5708b1c2274f0e7bf /src/tools/vppapigen/vppapigen_c.py
parent0b7200f7eef8881018c1e6dfb7ef10cf1e221362 (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/vppapigen/vppapigen_c.py')
-rwxr-xr-xsrc/tools/vppapigen/vppapigen_c.py23
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",