[Kconfig] Gnerate px4board from old cmake

Added make updateconfig to update all config when default's have changed
Added cmake to px4board conversion script
This commit is contained in:
Peter van der Perk
2021-08-17 18:41:59 +02:00
committed by Daniel Agar
parent 815617e670
commit 6af0477733
111 changed files with 4017 additions and 68 deletions
+48 -46
View File
@@ -80,62 +80,64 @@ def _re_match(regex):
from kconfiglib import Kconfig, BOOL, TRISTATE, TRI_TO_STR
def main(kconfig_file, config1, config2):
if len(sys.argv) < 4:
sys.exit("usage: merge_config.py Kconfig merged_config config1 [config2 ...]")
kconf = Kconfig(kconfig_file, suppress_traceback=True)
kconf = Kconfig(sys.argv[1], suppress_traceback=True)
# Enable warnings for assignments to undefined symbols
kconf.warn_assign_undef = False
# Enable warnings for assignments to undefined symbols
kconf.warn_assign_undef = True
# (This script uses alldefconfig as the base. Other starting states could be
# set up here as well. The approach in examples/allnoconfig_simpler.py could
# provide an allnoconfig starting state for example.)
# (This script uses alldefconfig as the base. Other starting states could be
# set up here as well. The approach in examples/allnoconfig_simpler.py could
# provide an allnoconfig starting state for example.)
# Disable warnings generated for multiple assignments to the same symbol within
# a (set of) configuration files. Assigning a symbol multiple times might be
# done intentionally when merging configuration files.
kconf.warn_assign_override = False
kconf.warn_assign_redun = False
# Disable warnings generated for multiple assignments to the same symbol within
# a (set of) configuration files. Assigning a symbol multiple times might be
# done intentionally when merging configuration files.
kconf.warn_assign_override = False
kconf.warn_assign_redun = False
# Create a merged configuration by loading the fragments with replace=False.
# load_config() and write_config() returns a message to print.
print(kconf.load_config(config1, replace=False))
print(kconf.load_config(config2, replace=False))
# Create a merged configuration by loading the fragments with replace=False.
# load_config() and write_config() returns a message to print.
for config in sys.argv[3:]:
print(kconf.load_config(config, replace=False))
# Modification for PX4 unset all symbols (INT,HEX etc) from 2nd config
# Modification for PX4 unset all symbols (INT,HEX etc) from 2nd config
f = open(config2, 'r')
f = open(sys.argv[4], 'r')
unset_match = re.compile(r"# {}([^ ]+) is not set".format("CONFIG_"), re.ASCII).match
unset_match = re.compile(r"# {}([^ ]+) is not set".format("CONFIG_"), re.ASCII).match
for line in f:
match = unset_match(line)
#pprint.pprint(match)
if match is not None:
sym_name = match.group(1)
kconf.syms[sym_name].unset_value()
f.close()
for line in f:
match = unset_match(line)
pprint.pprint(match)
if match is not None:
sym_name = match.group(1)
kconf.syms[sym_name].unset_value()
f.close()
# Print warnings for symbols whose actual value doesn't match the assigned
# value
for sym in kconf.defined_syms:
# Was the symbol assigned to?
if sym.user_value is not None:
# Tristate values are represented as 0, 1, 2. Having them as
# "n", "m", "y" is more convenient here, so convert.
if sym.type in (BOOL, TRISTATE):
user_value = TRI_TO_STR[sym.user_value]
else:
user_value = sym.user_value
if user_value != sym.str_value:
print("warning: {} was assigned the value '{}' but got the "
"value '{}' -- check dependencies".format(
sym.name_and_loc, user_value, sym.str_value),
file=sys.stderr)
# Write the merged configuration
print(kconf.write_config(sys.argv[2]))
return kconf
# Print warnings for symbols whose actual value doesn't match the assigned
# value
for sym in kconf.defined_syms:
# Was the symbol assigned to?
if sym.user_value is not None:
# Tristate values are represented as 0, 1, 2. Having them as
# "n", "m", "y" is more convenient here, so convert.
if sym.type in (BOOL, TRISTATE):
user_value = TRI_TO_STR[sym.user_value]
else:
user_value = sym.user_value
if user_value != sym.str_value:
print("warning: {} was assigned the value '{}' but got the "
"value '{}' -- check dependencies".format(
sym.name_and_loc, user_value, sym.str_value),
file=sys.stderr)
if __name__ == '__main__':
if len(sys.argv) < 4:
sys.exit("usage: merge_config.py Kconfig merged_config config1 config2]")
# Write the merged configuration
print(main(sys.argv[1],sys.argv[3],sys.argv[4]).write_config(sys.argv[2]))