summaryrefslogtreecommitdiff
path: root/kconfiglib.py
diff options
context:
space:
mode:
authorUlf Magnusson <ulfalizer@gmail.com>2018-08-17 21:04:43 +0200
committerUlf Magnusson <ulfalizer@gmail.com>2018-08-17 21:35:42 +0200
commit8a3999bc708e8468ff79665e3cbdfccd603160e1 (patch)
treef459c8ba2328764c6791d3d705973bae6352a085 /kconfiglib.py
parentb7be018fba77db3a9ff11faf980c600d4bbb2fa8 (diff)
Fix $srctree logic for the top-level Kconfig file
Due to a major design braino, the top-level Kconfig file passed to Kconfig.__init__() wasn't looked up relative to $srctree, breaking out-of-tree usage for e.g. menuconfig. With this change, Kconfig files are consistently looked up relative to $srctree, which makes a lot more sense. Also remove note re. loading a subset of Kconfig files. Saying that the top-level file and all source'd Kconfig files are looked up relative to $srctree should make the behavior clear enough.
Diffstat (limited to 'kconfiglib.py')
-rw-r--r--kconfiglib.py20
1 files changed, 7 insertions, 13 deletions
diff --git a/kconfiglib.py b/kconfiglib.py
index ce2891f..dbfeaff 100644
--- a/kconfiglib.py
+++ b/kconfiglib.py
@@ -605,20 +605,14 @@ class Kconfig(object):
the right Kconfig is included from there (arch/$SRCARCH/Kconfig as of
writing).
+ If $srctree is set, 'filename' will be looked up relative to it.
+ $srctree is also used to look up source'd files within Kconfig files.
+ See the class documentation.
+
If you are using Kconfiglib via 'make scriptconfig', the filename of
the base base Kconfig file will be in sys.argv[1]. It's currently
always "Kconfig" in practice.
- The $srctree environment variable is used to look up Kconfig files
- referenced in Kconfig files if set. See the class documentation.
-
- Note: '(o)source' statements in Kconfig files always work relative to
- $srctree (or the current directory if $srctree is unset), even if
- 'filename' is a path with directories. This allows a subset of
- Kconfig files to be loaded without breaking references to other
- Kconfig files, e.g. by doing Kconfig("./sub/Kconfig"). sub/Kconfig
- might expect to be sourced by ./Kconfig.
-
warn (default: True):
True if warnings related to this configuration should be generated.
This can be changed later with Kconfig.enable/disable_warnings(). It
@@ -732,7 +726,7 @@ class Kconfig(object):
self.top_node.prompt = ("Main menu", self.y)
self.top_node.parent = None
self.top_node.dep = self.y
- self.top_node.filename = os.path.relpath(filename, self.srctree)
+ self.top_node.filename = filename
self.top_node.linenr = 1
# Parse the Kconfig files
@@ -746,11 +740,11 @@ class Kconfig(object):
self._filestack = []
# The current parsing location
- self._filename = os.path.relpath(filename, self.srctree)
+ self._filename = filename
self._linenr = 0
# Open the top-level Kconfig file
- self._file = self._open(filename, "r")
+ self._file = self._open(os.path.join(self.srctree, filename), "r")
try:
# Parse everything