zephyr/scripts/kconfig/merge_config.py
Sebastian Bøe 12f8f76165 Introduce cmake-based rewrite of KBuild
Introducing CMake is an important step in a larger effort to make
Zephyr easy to use for application developers working on different
platforms with different development environment needs.

Simplified, this change retains Kconfig as-is, and replaces all
Makefiles with CMakeLists.txt. The DSL-like Make language that KBuild
offers is replaced by a set of CMake extentions. These extentions have
either provided simple one-to-one translations of KBuild features or
introduced new concepts that replace KBuild concepts.

This is a breaking change for existing test infrastructure and build
scripts that are maintained out-of-tree. But for FW itself, no porting
should be necessary.

For users that just want to continue their work with minimal
disruption the following should suffice:

Install CMake 3.8.2+

Port any out-of-tree Makefiles to CMake.

Learn the absolute minimum about the new command line interface:

$ cd samples/hello_world
$ mkdir build && cd build
$ cmake -DBOARD=nrf52_pca10040 ..

$ cd build
$ make

PR: zephyrproject-rtos#4692
docs: http://docs.zephyrproject.org/getting_started/getting_started.html

Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-08 20:00:22 -05:00

53 lines
2.1 KiB
Python

#!/usr/bin/env python3
import argparse
import re
def arguments_parse():
parser = argparse.ArgumentParser()
parser.add_argument('-q', dest="quiet", action='store_true')
parser.add_argument('-m', dest='runmake', action='store_false',
help='only merge the fragments, do not execute the make command')
parser.add_argument('-n', dest='alltarget', action='store_const', const='allnoconfig', default='alldefconfig',
help='use allnoconfig instead of alldefconfig')
parser.add_argument('-r', dest='warnredun', action='store_true',
help='list redundant entries when merging fragments')
parser.add_argument('-O', dest='output_dir',
help='to put generated output files', default='.')
parser.add_argument('config', nargs='+')
return parser.parse_args()
def main():
args = arguments_parse()
pattern = re.compile('^(CONFIG_[a-zA-Z0-9_]*)[= ].*')
config_values = {}
for config_file in args.config[:]:
print("Merging %s" % config_file)
with open(config_file, 'r') as file:
for line in file:
match = pattern.match(line)
if match:
config_name = match.group(1)
config_full = match.group(0)
if config_name in config_values:
if config_values[config_name] != config_full and not args.quiet:
print("Value of %s is redefined by fragment %s" % (config_name, config_file))
print("Previous value %s" % config_values[config_name])
print("new value %s" % config_full)
elif args.warnredun:
print("Value of %s is redundant by fragment %s" % (config_name, config_file))
config_values[config_name] = config_full
if args.runmake:
print("Running make not yet supported")
with open('%s/.config' % args.output_dir, 'w') as out_config:
out_config.write('\n'.join(map(lambda x: x[1], config_values.items())))
if __name__ == "__main__":
main()