summaryrefslogtreecommitdiff
path: root/bin/kconfig-expand-includes
diff options
context:
space:
mode:
Diffstat (limited to 'bin/kconfig-expand-includes')
-rwxr-xr-xbin/kconfig-expand-includes25
1 files changed, 25 insertions, 0 deletions
diff --git a/bin/kconfig-expand-includes b/bin/kconfig-expand-includes
new file mode 100755
index 0000000..058cfd2
--- /dev/null
+++ b/bin/kconfig-expand-includes
@@ -0,0 +1,25 @@
+#!/usr/bin/env python3
+
+import re
+import sys
+
+
+def main(filename):
+ root = "/".join(filename.split("/")[:-1])
+ with open(filename, "r") as f:
+ lines = f.readlines()
+ i = 0
+ while i < len(lines):
+ line = lines[i]
+ if line.lower().startswith("source"):
+ included_file = re.sub(r"\s+", " ", line).strip().split("source ")[1]
+ included_file = re.sub(r"""['"]""", "", included_file.strip())
+ with open(f"{root}/{included_file}", "r") as f:
+ lines = lines[:i] + f.readlines() + lines[i + 1 :]
+ i += 1
+
+ print("".join(lines))
+
+
+if __name__ == "__main__":
+ main(sys.argv[1])