From 4602028ba2450903b63f043377cc63ac5e5e36de Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Wed, 3 Oct 2018 07:19:43 +0200 Subject: genconfig: Allow writing a full .config without incremental build info For projects that don't use incremental build information, it's a bit wasteful to generate it just to get an updated .config file to include in Makefiles. Add a '--config-out ' option that just writes the updated .config file, for those cases. Also remove a redundant default=None argument for --sync-deps. None is the default value. --- README.rst | 17 ++++++++++------- genconfig.py | 25 ++++++++++++++++++++----- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/README.rst b/README.rst index 3c38839..44763be 100644 --- a/README.rst +++ b/README.rst @@ -121,7 +121,7 @@ Getting started 3. Generate an initial configuration with e.g. ``menuconfig`` or ``alldefconfig``. The configuration is saved as ``.config`` by default. -4. Run ``genconfig`` to generate a header file. By default, it is saved in +4. Run ``genconfig`` to generate a header file. By default, it is saved as ``config.h``. Normally, ``genconfig`` would be run automatically as part of the build. @@ -146,12 +146,15 @@ read configuration values from there. This is why ``n``-valued ``bool``/``trista values are written out as ``# CONFIG_FOO is not set`` (a Make comment) in ``.config`` (allowing them to be tested with ``ifdef`` in Make). -If you make use of this, you might want to pass ``--sync-deps`` to -``genconfig`` and include ``deps/auto.conf`` in your Makefiles instead of -including ``.config`` directly. This has the advantage that ``deps/auto.conf`` -will always be a "full" configuration file, even if ``.config`` is outdated. -Otherwise, it might be necessary to run ``old(def)config`` or ``menuconfig`` -before rebuilding with an outdated configuration. +If you make use of this, you might want to pass ``--config-out `` to +``genconfig`` and include the generated configuration file instead of including +``.config`` directly. This has the advantage that the generated configuration +file will always be a "full" configuration file, even if ``.config`` is +outdated. Otherwise, it might be necessary to run ``old(def)config`` or +``menuconfig`` before rebuilding with an outdated ``.config``. + +If you use ``--sync-deps`` to generate incremental build information, you can +include ``deps/auto.conf`` instead, which is also a full configuration file. Library documentation --------------------- diff --git a/genconfig.py b/genconfig.py index c0709e0..4fe84d6 100755 --- a/genconfig.py +++ b/genconfig.py @@ -36,7 +36,7 @@ def main(): "--header-path", metavar="HEADER_FILE", default=DEFAULT_HEADER_PATH, - help="path for the generated header file (default: {})" + help="Path for the generated header file (default: {})" .format(DEFAULT_HEADER_PATH)) parser.add_argument( @@ -44,29 +44,44 @@ def main(): dest="sync_deps_path", metavar="OUTPUT_DIR", nargs="?", - default=None, const=DEFAULT_SYNC_DEPS_PATH, - help="enable generation of build dependency information for " + help="Enable generation of build dependency information for " "incremental builds, optionally specifying the output path " "(default: {})".format(DEFAULT_SYNC_DEPS_PATH)) + parser.add_argument( + "--config-out", + dest="config_path", + metavar="CONFIG_FILE", + help="Write the configuration to the specified filename. " + "This is useful if you include .config files in Makefiles, as " + "the generated configuration file will be a full .config file " + "even if .config is outdated. The generated configuration " + "matches what olddefconfig would produce. If you use " + "--sync-deps, you can include deps/auto.conf instead. " + "--config-out is meant for cases where incremental build " + "information isn't needed.") + parser.add_argument( "kconfig_filename", metavar="KCONFIG_FILENAME", nargs="?", default="Kconfig", - help="top-level Kconfig file (default: Kconfig)") + help="Top-level Kconfig file (default: Kconfig)") args = parser.parse_args() kconf = kconfiglib.Kconfig(args.kconfig_filename) - kconf.load_config(kconfiglib.standard_config_filename()) kconf.write_autoconf(args.header_path) + if args.sync_deps_path is not None: kconf.sync_deps(args.sync_deps_path) + if args.config_path is not None: + kconf.write_config(args.config_path) + if __name__ == "__main__": main() -- cgit v1.2.3