1
0
mirror of https://github.com/rene-dev/stmbl.git synced 2024-12-20 23:52:15 +00:00
stmbl/tools/create_config.py

26 lines
679 B
Python
Raw Permalink Normal View History

2018-04-07 00:00:04 +00:00
#!/usr/bin/env python
2017-07-12 20:11:18 +00:00
import re
import sys
import os
config = []
for infile in sys.argv[1:]:
with open(infile) as f:
config.append((os.path.splitext(os.path.basename(infile))[0], f.read()))
2018-04-07 00:00:04 +00:00
print ("//generated by " + sys.argv[0] + " DO NOT EDIT\n")
print ("#include \"config.h\"\n")
print ("const uint32_t num_of_config_templates = " + str(len(config)) + ";\n")
2017-07-12 20:11:18 +00:00
2018-04-07 00:00:04 +00:00
print ("config_template_t config_templates[] = {")
2017-07-12 20:11:18 +00:00
for index, (file_name, content) in enumerate(config):
2018-04-07 00:00:04 +00:00
print ("{")
print (".name = \"" + file_name + "\",")
print (".config = \"\\")
2017-07-12 20:11:18 +00:00
for line in content.splitlines():
2018-04-07 00:00:04 +00:00
print (line + "\\n\\")
print ("\"\n},\n")
print ("};")