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
2018-04-07 02:00:04 +02:00

26 lines
679 B
Python
Executable File

#!/usr/bin/env python
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()))
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")
print ("config_template_t config_templates[] = {")
for index, (file_name, content) in enumerate(config):
print ("{")
print (".name = \"" + file_name + "\",")
print (".config = \"\\")
for line in content.splitlines():
print (line + "\\n\\")
print ("\"\n},\n")
print ("};")