diff options
Diffstat (limited to 'volk/gen/volk_tmpl_utils.py')
-rw-r--r-- | volk/gen/volk_tmpl_utils.py | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/volk/gen/volk_tmpl_utils.py b/volk/gen/volk_tmpl_utils.py index 8b00f2f1f..804cc2f28 100644 --- a/volk/gen/volk_tmpl_utils.py +++ b/volk/gen/volk_tmpl_utils.py @@ -22,7 +22,10 @@ import os import re +import sys import volk_arch_defs +import volk_machine_defs +import volk_kernel_defs from Cheetah import Template def __escape_pre_processor(code): @@ -31,10 +34,10 @@ def __escape_pre_processor(code): m = re.match('^(\s*)#(\s*)(\w+)(.*)$', line) if m: p0, p1, fcn, stuff = m.groups() - pponly = fcn in ('include', 'define', 'ifdef', 'ifndef', 'endif', 'elif') + conly = fcn in ('include', 'define', 'ifdef', 'ifndef', 'endif', 'elif') both = fcn in ('if', 'else') istmpl = '$' in stuff - if pponly or (both and not istmpl): + if conly or (both and not istmpl): line = '%s\\#%s%s%s'%(p0, p1, fcn, stuff) out.append(line) return '\n'.join(out) @@ -42,10 +45,17 @@ def __escape_pre_processor(code): def __parse_tmpl(_tmpl, **kwargs): defs = { 'archs': volk_arch_defs.archs, + 'machines': volk_machine_defs.machines, + 'kernels': volk_kernel_defs.kernels, } defs.update(kwargs) _tmpl = __escape_pre_processor(_tmpl) + _tmpl = """ + +/* this file was generated by volk template utils, do not edit! */ + +""" + _tmpl return str(Template.Template(_tmpl, defs)) -import sys -print __parse_tmpl(open(sys.argv[1]).read()) +if __name__ == '__main__': + print __parse_tmpl(open(sys.argv[1]).read()) |