Skip to contentSkip to conversation

kconfig: Kconfiglib: a flexible Python Kconfig parser

PATCH Superseded Ulf Magnusson 1 participant 1 message Feb 5, 2011

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 kconfig: Kconfiglib: a flexible Python Kconfig parser

This patch builds on https://lkml.org/lkml/2011/2/1/439 . A compound patch (original patch + all fixes) is available at
http://dl.dropbox.com/u/10406197/kconfiglib.patch (apply with 'git am').

Changelog:
v2:
- Now supports alternative output directories (O=).
- $-references were expanded as environment variables in some contexts ('source', 'mainmenu', and 'defconfig') where they should have been expanded as symbol values - fixed. The reason this broke so little is that all symbols whose value come from an environment variable are currently called the same thing as that variable.
- Added the internal special symbol UNAME_RELEASE, used by DEFCONFIG_LIST. Previously get_defconfig_filename() failed to find .configs whose DEFCONFIG_LIST entry involved UNAME_RELEASE - now works.
- get_defconfig_filename() now searches relative to $srctree before looking in the current directory, just like the C implementation.
- Updated example 1 to work regardless of build directory.
- Precompiled a few regexes.

---
Convenience links:

Compound patch (original + fixes):
http://dl.dropbox.com/u/10406197/kconfiglib.patch

Latest documentation (generated with pydoc -w kconfiglib):
http://dl.dropbox.com/u/10406197/kconfiglib.html

Latest example files (ex1.py updated in v2):
http://dl.dropbox.com/u/10406197/kconfiglib-examples.tar.gz

 scripts/kconfig/Makefile       |   16 ++++---
 scripts/kconfig/kconfiglib.py  |  105 ++++++++++++++++++++++++++++++----------
 scripts/kconfig/kconfigtest.py |    2 +-
 3 files changed, 90 insertions(+), 33 deletions(-)
scripts/kconfig/Makefile +9 -7
index cfffe87..0044933 100644
@@ -41,19 +41,21 @@ scriptconfig:
 	$(Q)if [ ! -n "$(SCRIPT)" ]; then                                                                     \
 			echo 'No script argument provided; use "make scriptconfig SCRIPT=<path to script>".'; \
 	else                                                                                                  \
-			PYTHONPATH="$(obj):$$PYTHONPATH" "$(PYTHONCMD)" "$(SCRIPT)" "$(Kconfig)";             \
+			PYTHONPATH="$(srctree)/$(src):$$PYTHONPATH"                                           \
+			  "$(PYTHONCMD)" "$(SCRIPT)" $(srctree)/$(Kconfig);                                   \
 	fi
 
 iscriptconfig:
-	$(Q)PYTHONPATH="$(obj):$$PYTHONPATH" "$(PYTHONCMD)" -i -c \
-	"import kconfiglib; \
-	 import sys; \
-	 c = kconfiglib.Config(sys.argv[1]); \
-	 print \"A Config instance 'c' for the architecture ({0}) has been created.\".format(c.get_arch())" "$(Kconfig)"
+	$(Q)PYTHONPATH="$(srctree)/$(src):$$PYTHONPATH" "$(PYTHONCMD)" -i -c \
+	  "import kconfiglib; \
+	   import sys; \
+	   c = kconfiglib.Config(sys.argv[1]); \
+	   print \"A Config instance 'c' for the architecture ({0}) has been created.\".format(c.get_arch())" \
+	  $(srctree)/$(Kconfig)
 
 # Used by kconfigtest.py to prevent an 'option defconfig' .config from being loaded
 kconfiglibtestconfig: $(obj)/conf
-	$(Q)$< --defconfig=.config $(Kconfig)
+	$(Q)$< --defconfig=.config $(srctree)/$(Kconfig)
 
 # if no path is given, then use src directory to find file
 ifdef LSMOD
scripts/kconfig/kconfiglib.py +80 -25

204 lines not on this page · raw message

scripts/kconfig/kconfigtest.py +1 -1
index 9d27dca..e6961a4 100644
@@ -81,7 +81,7 @@ def get_arch_configs():
     def add_arch(ARCH, res):
         os.environ["SRCARCH"] = archdir
         os.environ["ARCH"] = ARCH
-        res.append(kconfiglib.Config())
+        res.append(kconfiglib.Config(base_dir = "."))
 
     res = []
 
Signature · 1 line
1.7.0.4