diff options
| author | Ulf Magnusson <ulfalizer@gmail.com> | 2019-11-17 05:39:37 +0100 |
|---|---|---|
| committer | Ulf Magnusson <ulfalizer@gmail.com> | 2019-11-17 06:03:00 +0100 |
| commit | bb3be6ee9793f23c275d318f58cb6cf21391b371 (patch) | |
| tree | 1cbcf07fb72f1bfdc7cd4ffde62937de77738a1f /kconfiglib.py | |
| parent | de45874719772a40f1d8d244e2f5a6c6036415ac (diff) | |
Support giving the header path in KCONFIG_AUTOHEADER
This environment variable is used by the C tools. Use it when
filename=None is passed to write_autoconf(), and default to
include/generated/autoconf.h for compatibility.
Also update genconfig.py to use KCONFIG_AUTOHEADER if set when no
--header-path is passed. If KCONFIG_AUTOHEADER isn't set, keep
defaulting to 'config.h' for backwards compatibility. It's probably a
saner default for tools as well.
Diffstat (limited to 'kconfiglib.py')
| -rw-r--r-- | kconfiglib.py | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/kconfiglib.py b/kconfiglib.py index 079c363..7fe3f2e 100644 --- a/kconfiglib.py +++ b/kconfiglib.py @@ -1363,7 +1363,7 @@ class Kconfig(object): elif self.warn_assign_override: self._warn(msg, filename, linenr) - def write_autoconf(self, filename, header=None): + def write_autoconf(self, filename=None, header=None): r""" Writes out symbol values as a C header file, matching the format used by include/generated/autoconf.h in the kernel. @@ -1377,8 +1377,12 @@ class Kconfig(object): like the modification time and possibly triggering redundant work in build tools. - filename: - Self-explanatory. + filename (default: None): + Path to write header to. + + If None (the default), the path in the environment variable + KCONFIG_AUTOHEADER is used if set, and "include/generated/autoconf.h" + otherwise. This is compatible with the C tools. header (default: None): Text inserted verbatim at the beginning of the file. You would @@ -1390,6 +1394,10 @@ class Kconfig(object): will be used if it was set, and no header otherwise. See the Kconfig.header_header attribute. """ + if filename is None: + filename = os.getenv("KCONFIG_AUTOHEADER", + "include/generated/autoconf.h") + self._write_if_changed(filename, self._autoconf_contents(header)) def _autoconf_contents(self, header): @@ -1458,9 +1466,9 @@ class Kconfig(object): (OSError/IOError). KconfigError is never raised here. filename (default: None): - Filename to save configuration to (a string). + Path to write configuration to (a string). - If None (the default), the filename in the environment variable + If None (the default), the path in the environment variable KCONFIG_CONFIG is used if set, and ".config" otherwise. See standard_config_filename(). @@ -1606,7 +1614,7 @@ class Kconfig(object): (OSError/IOError). KconfigError is never raised here. filename: - Self-explanatory. + Path to write minimal configuration to. header (default: None): Text inserted verbatim at the beginning of the file. You would |
