806eb493ca
Instead of always defining config values, only #define options that are enabled, so that #ifdef/#ifndef can be used. Generate #undef lines for the disabled variables so the names are still visible in config.h. Change-Id: Iaf56597ea6ae57b384387cc8a292d63960b611e4 Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
33 lines
1.1 KiB
Python
Executable File
33 lines
1.1 KiB
Python
Executable File
#!/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':
|
|
print "#define SPDK_{} 1".format(var)
|
|
else:
|
|
print "#undef SPDK_{}".format(var)
|
|
else:
|
|
strval = val.replace('"', '\"')
|
|
print "#define SPDK_{} \"{}\"".format(var, strval)
|