#! /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 "};"
