summaryrefslogtreecommitdiffstats
path: root/src/spdk/scripts/genconfig.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:54:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:54:28 +0000
commite6918187568dbd01842d8d1d2c808ce16a894239 (patch)
tree64f88b554b444a49f656b6c656111a145cbbaa28 /src/spdk/scripts/genconfig.py
parentInitial commit. (diff)
downloadceph-e6918187568dbd01842d8d1d2c808ce16a894239.tar.xz
ceph-e6918187568dbd01842d8d1d2c808ce16a894239.zip
Adding upstream version 18.2.2.upstream/18.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/spdk/scripts/genconfig.py')
-rwxr-xr-xsrc/spdk/scripts/genconfig.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/spdk/scripts/genconfig.py b/src/spdk/scripts/genconfig.py
new file mode 100755
index 000000000..cd4f17510
--- /dev/null
+++ b/src/spdk/scripts/genconfig.py
@@ -0,0 +1,46 @@
+#!/usr/bin/env python3
+
+import os
+import re
+import sys
+
+comment = re.compile(r'^\s*#')
+assign = re.compile(r'^\s*([a-zA-Z0-9_]+)\s*(\?)?=\s*([^#]*)')
+
+args = os.environ.copy()
+for arg in sys.argv:
+ m = assign.match(arg)
+ if m:
+ var = m.group(1).strip()
+ val = m.group(3).strip()
+ args[var] = val
+
+defs = {}
+try:
+ with open("mk/config.mk") 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
+ if var in args:
+ val = args[var]
+ if default.lower() == 'y' or default.lower() == 'n':
+ if val.lower() == 'y':
+ defs["SPDK_{0}".format(var)] = 1
+ else:
+ defs["SPDK_{0}".format(var)] = 0
+ else:
+ strval = val.replace('"', '\"')
+ defs["SPDK_{0}".format(var)] = strval
+except IOError:
+ print("mk/config.mk not found")
+
+for key, value in sorted(defs.items()):
+ if value == 0:
+ print("#undef {0}".format(key))
+ else:
+ print("#define {0} {1}".format(key, value))