mirror of
https://github.com/esphome/esphome.git
synced 2025-06-18 14:25:48 +01:00
preprocess out proto_enum_to_string if not needed (#4119)
This commit is contained in:
@ -546,7 +546,8 @@ def build_enum_type(desc):
|
||||
out += f" {v.name} = {v.number},\n"
|
||||
out += "};\n"
|
||||
|
||||
cpp = f"template<> const char *proto_enum_to_string<enums::{name}>(enums::{name} value) {{\n"
|
||||
cpp = f"#ifdef HAS_PROTO_MESSAGE_DUMP\n"
|
||||
cpp += f"template<> const char *proto_enum_to_string<enums::{name}>(enums::{name} value) {{\n"
|
||||
cpp += f" switch (value) {{\n"
|
||||
for v in desc.value:
|
||||
cpp += f" case enums::{v.name}:\n"
|
||||
@ -555,6 +556,7 @@ def build_enum_type(desc):
|
||||
cpp += f' return "UNKNOWN";\n'
|
||||
cpp += f" }}\n"
|
||||
cpp += f"}}\n"
|
||||
cpp += f"#endif\n"
|
||||
|
||||
return out, cpp
|
||||
|
||||
|
Reference in New Issue
Block a user