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

34 lines
770 B
Python
Executable File

#! /bin/sh
"true" '''\'
if command -v python2 > /dev/null; then
exec python2 "$0" "$@"
else
exec python "$0" "$@"
fi
exit $?
'''
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 "};"