summaryrefslogtreecommitdiff
path: root/volk/gen
diff options
context:
space:
mode:
Diffstat (limited to 'volk/gen')
-rw-r--r--volk/gen/volk_compile_utils.py9
-rw-r--r--volk/gen/volk_tmpl_utils.py18
2 files changed, 16 insertions, 11 deletions
diff --git a/volk/gen/volk_compile_utils.py b/volk/gen/volk_compile_utils.py
index cd9f9f0a9..cf1357375 100644
--- a/volk/gen/volk_compile_utils.py
+++ b/volk/gen/volk_compile_utils.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python
#
# Copyright 2012 Free Software Foundation, Inc.
#
@@ -44,10 +45,10 @@ def do_machine_flags_list(compiler, machine_name):
def main():
parser = optparse.OptionParser()
- parser.add_option('--mode', type='string', default='')
- parser.add_option('--compiler', type='string', default='')
- parser.add_option('--archs', type='string', default='')
- parser.add_option('--machine', type='string', default='')
+ parser.add_option('--mode', type='string')
+ parser.add_option('--compiler', type='string')
+ parser.add_option('--archs', type='string')
+ parser.add_option('--machine', type='string')
(opts, args) = parser.parse_args()
if opts.mode == 'arch_flags': return do_arch_flags_list(opts.compiler.lower())
diff --git a/volk/gen/volk_tmpl_utils.py b/volk/gen/volk_tmpl_utils.py
index c215e389e..6c08a8213 100644
--- a/volk/gen/volk_tmpl_utils.py
+++ b/volk/gen/volk_tmpl_utils.py
@@ -23,6 +23,7 @@
import os
import re
import sys
+import optparse
import volk_arch_defs
import volk_machine_defs
import volk_kernel_defs
@@ -60,11 +61,14 @@ def __parse_tmpl(_tmpl, **kwargs):
""" + _tmpl
return str(Template.Template(_tmpl, defs))
-if __name__ == '__main__':
- input_file = sys.argv[1]
- output_file = sys.argv[2]
- try: which = sys.argv[3]
- except: which = ''
- output = __parse_tmpl(open(input_file).read(), which=which)
- if output_file: open(output_file, 'w').write(output)
+def main():
+ parser = optparse.OptionParser()
+ parser.add_option('--input', type='string')
+ parser.add_option('--output', type='string')
+ (opts, args) = parser.parse_args()
+
+ output = __parse_tmpl(open(opts.input).read(), args=args)
+ if opts.output: open(opts.output, 'w').write(output)
else: print output
+
+if __name__ == '__main__': main()