From c2414bdf64c03470061d280a7d1b5ea97bab3185 Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Sat, 14 Dec 2019 17:15:57 +0100 Subject: Add a member function version of load_allconfig() There was no great reason for this function to be a global function to begin with. Having it as a member function simplifies callers. load_allconfig() is a bit special in that it fails with sys.exit(), which is helpful for tools, but that probably doesn't influence where it belongs. Keep the global function for backwards compatibility. A deprecation warning might be added at some point. --- alldefconfig.py | 2 +- allmodconfig.py | 2 +- allnoconfig.py | 2 +- allyesconfig.py | 2 +- kconfiglib.py | 44 +++++++++++++++++++++++++------------------- 5 files changed, 29 insertions(+), 23 deletions(-) diff --git a/alldefconfig.py b/alldefconfig.py index fab8385..b83919c 100755 --- a/alldefconfig.py +++ b/alldefconfig.py @@ -19,7 +19,7 @@ import kconfiglib def main(): kconf = kconfiglib.standard_kconfig(__doc__) - kconfiglib.load_allconfig(kconf, "alldef.config") + kconf.load_allconfig("alldef.config") print(kconf.write_config()) diff --git a/allmodconfig.py b/allmodconfig.py index 7525805..b5c5d33 100755 --- a/allmodconfig.py +++ b/allmodconfig.py @@ -37,7 +37,7 @@ def main(): kconf.warn = True - kconfiglib.load_allconfig(kconf, "allmod.config") + kconf.load_allconfig("allmod.config") print(kconf.write_config()) diff --git a/allnoconfig.py b/allnoconfig.py index 3d5ca4a..7016d8d 100755 --- a/allnoconfig.py +++ b/allnoconfig.py @@ -36,7 +36,7 @@ def main(): sym.set_value(2 if sym.is_allnoconfig_y else 0) kconf.warn = True - kconfiglib.load_allconfig(kconf, "allno.config") + kconf.load_allconfig("allno.config") print(kconf.write_config()) diff --git a/allyesconfig.py b/allyesconfig.py index 4967605..d51d362 100755 --- a/allyesconfig.py +++ b/allyesconfig.py @@ -47,7 +47,7 @@ def main(): kconf.warn = True - kconfiglib.load_allconfig(kconf, "allyes.config") + kconf.load_allconfig("allyes.config") print(kconf.write_config()) diff --git a/kconfiglib.py b/kconfiglib.py index 700ce7a..6199e8b 100644 --- a/kconfiglib.py +++ b/kconfiglib.py @@ -1363,6 +1363,28 @@ class Kconfig(object): elif self.warn_assign_override: self._warn(msg, filename, linenr) + def load_allconfig(self, filename): + """ + Helper for all*config. Loads (merges) the configuration file specified + by KCONFIG_ALLCONFIG, if any. See Documentation/kbuild/kconfig.txt in + the Linux kernel. + + Disables warnings for duplicated assignments within configuration files + for the duration of the call + (kconf.warn_assign_override/warn_assign_redun = False), and restores + the previous warning settings at the end. The KCONFIG_ALLCONFIG + configuration file is expected to override symbols. + + Exits with sys.exit() (which raises a SystemExit exception) and prints + an error to stderr if KCONFIG_ALLCONFIG is set but the configuration + file can't be opened. + + filename: + Command-specific configuration filename - "allyes.config", + "allno.config", etc. + """ + load_allconfig(self, filename) + def write_autoconf(self, filename=None, header=None): r""" Writes out symbol values as a C header file, matching the format used @@ -6184,25 +6206,9 @@ def standard_config_filename(): def load_allconfig(kconf, filename): """ - Helper for all*config. Loads (merges) the configuration file specified by - KCONFIG_ALLCONFIG, if any. See Documentation/kbuild/kconfig.txt in the - Linux kernel. - - Disables warnings for duplicated assignments within configuration files for - the duration of the call (kconf.warn_assign_override/warn_assign_redun = False), - and restores the previous warning settings at the end. The - KCONFIG_ALLCONFIG configuration file is expected to override symbols. - - Exits with sys.exit() (which raises a SystemExit exception) and prints an - error to stderr if KCONFIG_ALLCONFIG is set but the configuration file - can't be opened. - - kconf: - Kconfig instance to load the configuration in. - - filename: - Command-specific configuration filename - "allyes.config", - "allno.config", etc. + Use Kconfig.load_allconfig() instead, which was added in Kconfiglib 13.4.0. + Supported for backwards compatibility. Might be removed at some point after + a long period of deprecation warnings. """ allconfig = os.getenv("KCONFIG_ALLCONFIG") if allconfig is None: -- cgit v1.2.3