2016-06-07 11:31:12 -07:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
import re
|
|
|
|
import sys
|
|
|
|
|
|
|
|
comment = re.compile('^\s*#')
|
|
|
|
assign = re.compile('^\s*([a-zA-Z_]+)\s*(\?)?=\s*([^#]*)')
|
|
|
|
|
|
|
|
with open('CONFIG') as f:
|
|
|
|
for line in f:
|
|
|
|
line = line.strip()
|
|
|
|
if not comment.match(line):
|
|
|
|
m = assign.match(line)
|
|
|
|
if m:
|
|
|
|
var = m.group(1).strip()
|
|
|
|
default = m.group(3).strip()
|
|
|
|
val = default
|
|
|
|
for arg in sys.argv:
|
|
|
|
m = assign.match(arg)
|
|
|
|
if m:
|
|
|
|
argvar = m.group(1).strip()
|
|
|
|
argval = m.group(3).strip()
|
|
|
|
if argvar == var:
|
|
|
|
val = argval
|
|
|
|
if default.lower() == 'y' or default.lower() == 'n':
|
|
|
|
if val.lower() == 'y':
|
2016-06-23 09:50:57 -07:00
|
|
|
print "#define SPDK_{} 1".format(var)
|
2016-06-07 11:31:12 -07:00
|
|
|
else:
|
2016-06-23 09:50:57 -07:00
|
|
|
print "#undef SPDK_{}".format(var)
|
2016-06-07 11:31:12 -07:00
|
|
|
else:
|
|
|
|
strval = val.replace('"', '\"')
|
|
|
|
print "#define SPDK_{} \"{}\"".format(var, strval)
|