From f247ddf618ad29718e5efd3e69f8baf75d4d347b Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Fri, 17 Aug 2018 21:04:43 +0200 Subject: Look up the top-level Kconfig file relative to $srctree Due to an old design braino, the top-level Kconfig filename passed to Kconfig.__init__() wasn't looked up relative to $srctree, breaking out-of-tree usage for e.g. menuconfig. Fixing it required ugliness like srctree = os.environ.get("srctree", "") kconfiglib.Kconfig(os.path.join(srctree, "Kconfig")) Change the behavior of Kconfig.__init__() to look up the top-level Kconfig file relative to $srctree. This means that all Kconfig files (both the top-level file and any source'd files) now use $srctree, which makes the vast majority of scripts just work when running out-of-tree. Also remove the 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. Print a note about the new behavior whenever the top-level Kconfig file can't be opened, as this change could be breaking for some scripts. This is a slight backwards-compatiblity break, so the major version will be bumped. --- testsuite.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'testsuite.py') diff --git a/testsuite.py b/testsuite.py index a521128..cddce68 100644 --- a/testsuite.py +++ b/testsuite.py @@ -895,17 +895,17 @@ comment "advanced comment" """) - os.environ["srctree"] = "srctree value" + os.environ["srctree"] = "Kconfiglib" os.environ["CONFIG_"] = "CONFIG_ value" - c = Kconfig("Kconfiglib/tests/Krepr", warn=False) + c = Kconfig("tests/Krepr", warn=False) c.enable_warnings() c.disable_stderr_warnings() c.disable_redun_warnings() c.enable_undef_warnings() verify_repr(c, """ - + """) os.environ.pop("srctree", None) @@ -987,7 +987,7 @@ g os.environ["srctree"] = srctree # Has symbol with empty help text, so disable warnings - c = Kconfig("Kconfiglib/tests/Klocation", warn=False) + c = Kconfig("tests/Klocation", warn=False) verify_locations(c.syms["SINGLE_DEF"].nodes, "tests/Klocation:4") @@ -1018,7 +1018,7 @@ g # Test recursive 'source' detection try: - Kconfig("Kconfiglib/tests/Krecursive1") + Kconfig("tests/Krecursive1") except KconfigError: pass except: @@ -1030,7 +1030,7 @@ g # TODO: Make an exception test helper try: - Kconfig("Kconfiglib/tests/Kmissingsource") + Kconfig("tests/Kmissingsource") except KconfigError: pass except: @@ -1039,7 +1039,7 @@ g fail("'source' with missing file did not raise exception") try: - Kconfig("Kconfiglib/tests/Kmissingrsource") + Kconfig("tests/Kmissingrsource") except KconfigError: pass except: @@ -1559,7 +1559,7 @@ g "defconfig_filename gave wrong file with $srctree unset") os.environ["srctree"] = "Kconfiglib/tests" - c = Kconfig("Kconfiglib/tests/Kdefconfig_srctree") + c = Kconfig("Kdefconfig_srctree") verify(c.defconfig_filename == "Kconfiglib/tests/sub/defconfig_in_sub", "defconfig_filename gave wrong file with $srctree set") -- cgit v1.2.3