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. --- kconfiglib.py | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) (limited to 'kconfiglib.py') 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