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 /genconfig.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 'genconfig.py')
| -rwxr-xr-x | genconfig.py | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/genconfig.py b/genconfig.py index 96124c5..b202a5b 100755 --- a/genconfig.py +++ b/genconfig.py @@ -35,7 +35,6 @@ import sys import kconfiglib -DEFAULT_HEADER_PATH = "config.h" DEFAULT_SYNC_DEPS_PATH = "deps/" @@ -47,9 +46,11 @@ def main(): parser.add_argument( "--header-path", metavar="HEADER_FILE", - default=DEFAULT_HEADER_PATH, - help="Path for the generated header file (default: {})" - .format(DEFAULT_HEADER_PATH)) + help=""" +Path to write the generated header file to. If not specified, the path in the +environment variable KCONFIG_AUTOHEADER is used if it is set, and 'config.h' +otherwise. +""") parser.add_argument( "--config-out", @@ -107,7 +108,17 @@ only supported for backwards compatibility). kconf = kconfiglib.Kconfig(args.kconfig_filename) kconf.load_config() - kconf.write_autoconf(args.header_path) + if args.header_path is None: + if "KCONFIG_AUTOHEADER" in os.environ: + kconf.write_autoconf() + else: + # Kconfiglib defaults to include/generated/autoconf.h to be + # compatible with the C tools. 'config.h' is used here instead for + # backwards compatibility. It's probably a saner default for tools + # as well. + kconf.write_autoconf("config.h") + else: + kconf.write_autoconf(args.header_path) if args.config_out is not None: kconf.write_config(args.config_out, save_old=False) |
