summaryrefslogtreecommitdiff
path: root/genconfig.py
AgeCommit message (Collapse)Author
2026-02-02drop support for Python 2.x as it is very much EOLBenjamin Cabé
A follow-up to b96a5ad562deffa697d966c29546650aae645f48 where we stopped having CI run tests on Python 2.x. This actually drops the few remaining Python 2.x compatibility bits as Python 2.x has EOL'd a long time ago. Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org> Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-01-24Use 'python3' instead of 'python' in hashbangsUlf Magnusson
It's not obligatory for distributions to have a 'python' binary these days, but 'python3' is likely to be available: https://www.python.org/dev/peps/pep-0394/#for-python-runtime-distributors. Change all hashbangs to point to 'python3'. This will break running $ ./script.py on *nix systems that don't have a 'python3' executable. Changing it to $ python script.py is pretty painless at least. This change won't break Python 2 when installing via 'pip', because entry_points creates bounce scripts with their own hashbangs. The major version will be increased, in case someone looks at the major version but doesn't install via 'pip'. Fixes: #89
2019-12-14Make genconfig and standard_kconfig() consistentUlf Magnusson
Tweak messages and variable names to match.
2019-12-14Add Kconfig.__init__() helper flag for suppressing tracebacksUlf Magnusson
Tools that don't use standard_kconfig() currently generate spammy tracebacks for e.g. syntax errors. Add a suppress_traceback flag to Kconfig.__init__() for catching "expected" exceptions and printing them to stderr and exiting with status 1. Use it to make all tools consistently hide tracebacks.
2019-11-20genconfig: Add tip re. defining multi-line variables in makefilesUlf Magnusson
Handy for KCONFIG_{CONFIG,AUTOHEADER}_HEADER.
2019-11-17Support giving the header path in KCONFIG_AUTOHEADERUlf Magnusson
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.
2019-11-17Make header strings customizable via the environmentUlf Magnusson
If no header string is specified in write_(min_)config() or write_autoconf(), use the values of the environment variables KCONFIG_CONFIG_HEADER and KCONFIG_AUTOHEADER_HEADER, respectively, if set. KCONFIG_AUTOHEADER_HEADER is consistent with KCONFIG_AUTOHEADER (the header path), which will be added soon. Using environment variables avoids having to add separate flags to each tool that writes configuration files or headers. Like for $prefix and $CONFIG_, store the values of the environment variables when the Kconfig instance is created, and expose them via Kconfig.config_header and Kconfig.header_header. This if flexible and avoids gotchas when working with multiple Kconfig instances. Also remove the old default header and make the default no header. Less advertising, but it felt a bit silly to add workarounds to keep it. Came up in https://github.com/ulfalizer/Kconfiglib/pull/80.
2019-06-07genconfig: Code ordering nitUlf Magnusson
Match the order the flags are defined.
2019-06-07genconfig: Support generating lists of files and environment vars.Ulf Magnusson
This can be useful to avoid needless reconfiguration, by checking if any Kconfig file or environment variable has changed value before running genconfig.
2019-06-03Have load_config() and write_(min_)config() return messagesUlf Magnusson
Hardcoding load_config() and write_(min_)config() to write any message to stdout is awkward, because it means that the message can't be easily reused when stdout is the wrong place to write it to (e.g. in menuconfig/guiconfig). This gets extra bad now that there's also the "No change to ..." message. Modify load_config() and write_(min_)config() to return the message as a string instead, and have them always return a message, instead of just when 'filename' is None and verbose=True. This makes things flexible and straightforward. Use the new behavior in menuconfig.py and guiconfig.py. They now show "No change to ..." when saving a file doesn't modify it. Tools that want to write messages to stdout should now do print(kconf.load_config()) / print(kconf.write_config()). There's no clean way to preserve perfect backwards compatibility here, but keep accepting the 'verbose' argument and print a deprecation warning if a value is ever passed for it. That way, scripts will keep running, though possibly with less output on stdout. This changes the meaning of the load_config() return value as well, though I suspect it was only ever used by the menuconfig/guiconfig interfaces. The new behavior applies for kconfiglib.VERSION >= (12, 0, 0).
2019-05-31Leave unchanged output files untouchedUlf Magnusson
Before writing a configuration file or header file, compare the old contents of the file against the new contents. If there's no change, skip the write, to avoid updating the file modification time. This might avoid triggering redundant rebuilds depending on how the build system is set up, and could allow for a simpler setup.
2019-03-22Whitespace consistency nitUlf Magnusson
2019-03-22Convert some comments to module docstrings in utilitiesUlf Magnusson
This makes running pydoc(3) on the utilities helpful. Reuse the module docstring for the --help text for utilities that use argparse. Also fix some copy-paste errors in the all*config.py descriptions and clean up the language a bit. Piggyback removal of an optimization in allmodconfig.py that's pretty irrelevant now.
2019-03-06Use a consistent style in small utilitiesUlf Magnusson
Also remove some no longer used imports.
2019-03-06genconfig: Get rid of DESCRIPTION variableUlf Magnusson
Used in a single place.
2019-01-15Update copyright years for 2019Ulf Magnusson
2018-12-08genconfig: Do not generate *.old files for --config-outUlf Magnusson
Configuration files generated by --config-out would usually be an internal detail of the build system, so it's probably not helpful to generate *.old files for them. Pass save_old=False to write_config() to skip it.
2018-12-08Make {load,write}_config(filename=None) implement the standard behaviorUlf Magnusson
Make the previously obligatory 'filename' argument to load_config() and write_config() default to None, and have that implement the behavior you'd usually want: read/write either KCONFIG_CONFIG or ".config" if unset, and read the 'option defconfig_list' configuration file if KCONFIG_CONFIG/".config" doesn't exist. For load_config(), filename=None also allows the configuration file to be missing without raising an error. load_config() returns True if a local configuration file was loaded, which is useful to check in the menuconfig (if no local configuration file exists, we always want to prompt for saving the configuration when exiting). Also add a 'verbose' argument (default True) to load_config() and read_config() that makes them print which files were read/written in filename=None mode. Also generalize olddefconfig.py and oldconfig.py to not require there to already be a local configuration file. This was a bit silly for olddefconfig.py in particular. Remove the examples/defconfig.py script. It's a duplicate of olddefconfig.py.
2018-10-06Update genconfig usage descriptionUlf Magnusson
Didn't mention --config-out.
2018-10-03genconfig: Allow writing a full .config without incremental build infoUlf Magnusson
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 <filename>' 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.
2018-06-22genconfig: Remove unused sys importUlf Magnusson
2018-06-06genconfig: Fix weird wording in descriptionUlf Magnusson
2018-06-06Add license tags to scriptsUlf Magnusson
Everything's ISC.
2018-06-05Turn syncconfig.py into genconfig.py and generate headerUlf Magnusson
There should be a script available that generates the output header for the build. It usually makes sense to generate both the header and any incremental build information at the same time (automatically during build), so roll them both into the same script.