Skip to content

Commit

Permalink
feat: added mqtt_topics header
Browse files Browse the repository at this point in the history
  • Loading branch information
guglielmo-boi committed Mar 21, 2024
1 parent c68907e commit bc93ce7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/generator/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
with open('src/templates/topics.cpp.j2', 'r') as file:
topics_cpp_template = jinja2.Template(file.read())
with open('src/templates/message_parser.h.j2', 'r') as file:
parser_h_template = jinja2.Template(file.read())
message_parser_h_template = jinja2.Template(file.read())
with open('src/templates/message_parser.cpp.j2', 'r') as file:
parser_cpp_template = jinja2.Template(file.read())
message_parser_cpp_template = jinja2.Template(file.read())
with open('src/templates/mqtt_topics.h.j2', 'r') as file:
mqtt_topics_h = jinja2.Template(file.read())
with open('src/templates/CMakeLists.txt.j2', 'r') as file:
cmake_template = jinja2.Template(file.read())

Expand Down Expand Up @@ -63,12 +65,16 @@
print(f'✅ Generated topics.cpp')

with open(os.path.join(args.output_dir, 'inc', 'message_parser.h'), 'w') as file:
file.write(parser_h_template.render(topics=topics, roles=roles, variables=variables, utils=utils))
file.write(message_parser_h_template.render(topics=topics, roles=roles, variables=variables, utils=utils))
print(f'✅ Generated message_parser.h')

with open(os.path.join(args.output_dir, 'src', 'message_parser.cpp'), 'w') as file:
file.write(parser_cpp_template.render(topics=topics, roles=roles, variables=variables, utils=utils))
file.write(message_parser_cpp_template.render(topics=topics, roles=roles, variables=variables, utils=utils))
print(f'✅ Generated message_parser.cpp')

with open(os.path.join(args.output_dir, 'mqtt_topics.h'), 'w') as file:
file.write(mqtt_topics_h.render(topics=topics, roles=roles, variables=variables, utils=utils))
print(f'✅ Generated mqtt_topics.h')

with open(os.path.join(args.output_dir, 'CMakeLists.txt'), 'w') as file:
file.write(cmake_template.render())
Expand Down
7 changes: 7 additions & 0 deletions src/templates/mqtt_topics.h.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#ifndef MQTT_TOPICS_H
#define MQTT_TOPICS_H

#include "topics.h"
#include "message_parser.h"

#endif

0 comments on commit bc93ce7

Please sign in to comment.