1#!/usr/bin/env python3 2 3# Copyright (c) 2019, Ulf Magnusson 4# SPDX-License-Identifier: ISC 5 6""" 7Saves a minimal configuration file that only lists symbols that differ in value 8from their defaults. Loading such a configuration file is equivalent to loading 9the "full" configuration file. 10 11Minimal configuration files are handy to start from when editing configuration 12files by hand. 13 14The default input configuration file is '.config'. A different input filename 15can be passed in the KCONFIG_CONFIG environment variable. 16 17Note: Minimal configurations can also be generated from within the menuconfig 18interface. 19""" 20import argparse 21 22import kconfiglib 23 24 25def main(): 26 parser = argparse.ArgumentParser( 27 formatter_class=argparse.RawDescriptionHelpFormatter, 28 description=__doc__) 29 30 parser.add_argument( 31 "--kconfig", 32 default="Kconfig", 33 help="Top-level Kconfig file (default: Kconfig)") 34 35 parser.add_argument( 36 "--out", 37 metavar="MINIMAL_CONFIGURATION", 38 default="defconfig", 39 help="Output filename for minimal configuration (default: defconfig)") 40 41 args = parser.parse_args() 42 43 kconf = kconfiglib.Kconfig(args.kconfig, suppress_traceback=True) 44 print(kconf.load_config()) 45 print(kconf.write_min_config(args.out)) 46 47 48if __name__ == "__main__": 49 main() 50