kconfig/devicetree: Print path to headers when configuring
Change the output during CMake configure from Devicetree configuration written to .../devicetree.conf Parsing /home/ulf/z/z/Kconfig Loaded configuration '.../frdm_kw41z_defconfig' Merged configuration '.../prj.conf' Configuration saved to '.../.config' to Devicetree header saved to '.../devicetree_unfixed.h' Parsing /home/ulf/z/z/Kconfig Loaded configuration '.../frdm_kw41z_defconfig' Merged configuration '.../prj.conf' Configuration saved to '.../.config' Kconfig header saved to '.../autoconf.h' devicetree_unfixed.h is more useful to be aware of than devicetree.conf (still hoping we can get rid of it at some point), and seeing the Kconfig header clarifies things to. "Saved" instead of "written" for consistency. Maybe it could say "Kconfig configuration" instead of "configuration" too, though it gets a bit spammy in other contexts where the message shows up. Updates Kconfiglib (and menuconfig/guiconfig, just to sync) to upstream revision 061e71f7d7, to get this commit in, which is used to print the header path: Return a message from Kconfig.write_autoconf() Like for Kconfig.write_config() and Kconfig.write_min_config(), return a string from Kconfig.write_autoconf() with a message saying that the header got saved, or that there were no changes to it. Can be handy in tools. Also make the "no change" message for the various files more specific, by mentioning what type of file it is (configuration, header, etc.) Return True/False from Kconfig._write_if_changed() to indicate if the file was updated. This also allows it to be reused in Kconfig.write_min_config(). Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
This commit is contained in:
parent
9dc4eed622
commit
d0f082dd3b
|
@ -74,11 +74,12 @@ def main():
|
|||
|
||||
write_flash(edt)
|
||||
|
||||
print("Devicetree configuration written to " + args.conf_out)
|
||||
|
||||
conf_file.close()
|
||||
header_file.close()
|
||||
|
||||
print(f"Devicetree header saved to '{args.header_out}'")
|
||||
|
||||
|
||||
def parse_args():
|
||||
# Returns parsed command-line arguments
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Copyright (c) 2019, Nordic Semiconductor ASA and Ulf Magnusson
|
||||
# SPDX-License-Identifier: ISC
|
||||
|
|
|
@ -82,7 +82,7 @@ def main():
|
|||
|
||||
# Write the merged configuration and the C header
|
||||
print(kconf.write_config(args.config_out))
|
||||
kconf.write_autoconf(args.header_out)
|
||||
print(kconf.write_autoconf(args.header_out))
|
||||
|
||||
# Write the list of parsed Kconfig files to a file
|
||||
write_kconfig_filenames(kconf, args.kconfig_list_out)
|
||||
|
|
|
@ -554,7 +554,7 @@ from glob import iglob
|
|||
from os.path import dirname, exists, expandvars, islink, join, realpath
|
||||
|
||||
|
||||
VERSION = (13, 7, 1)
|
||||
VERSION = (14, 1, 0)
|
||||
|
||||
|
||||
# File layout:
|
||||
|
@ -1444,12 +1444,18 @@ class Kconfig(object):
|
|||
KCONFIG_AUTOHEADER_HEADER had when the Kconfig instance was created
|
||||
will be used if it was set, and no header otherwise. See the
|
||||
Kconfig.header_header attribute.
|
||||
|
||||
Returns a string with a message saying that the header got saved, or
|
||||
that there were no changes to it. This is meant to reduce boilerplate
|
||||
in tools, which can do e.g. print(kconf.write_autoconf()).
|
||||
"""
|
||||
if filename is None:
|
||||
filename = os.getenv("KCONFIG_AUTOHEADER",
|
||||
"include/generated/autoconf.h")
|
||||
|
||||
self._write_if_changed(filename, self._autoconf_contents(header))
|
||||
if self._write_if_changed(filename, self._autoconf_contents(header)):
|
||||
return "Kconfig header saved to '{}'".format(filename)
|
||||
return "No change to Kconfig header in '{}'".format(filename)
|
||||
|
||||
def _autoconf_contents(self, header):
|
||||
# write_autoconf() helper. Returns the contents to write as a string,
|
||||
|
@ -1564,7 +1570,7 @@ class Kconfig(object):
|
|||
|
||||
contents = self._config_contents(header)
|
||||
if self._contents_eq(filename, contents):
|
||||
return "No change to '{}'".format(filename)
|
||||
return "No change to configuration in '{}'".format(filename)
|
||||
|
||||
if save_old:
|
||||
_save_old(filename)
|
||||
|
@ -1677,18 +1683,14 @@ class Kconfig(object):
|
|||
be used if it was set, and no header otherwise. See the
|
||||
Kconfig.config_header attribute.
|
||||
|
||||
Returns a string with a message saying which file got saved. This is
|
||||
meant to reduce boilerplate in tools, which can do e.g.
|
||||
Returns a string with a message saying the minimal configuration got
|
||||
saved, or that there were no changes to it. This is meant to reduce
|
||||
boilerplate in tools, which can do e.g.
|
||||
print(kconf.write_min_config()).
|
||||
"""
|
||||
contents = self._min_config_contents(header)
|
||||
if self._contents_eq(filename, contents):
|
||||
return "No change to '{}'".format(filename)
|
||||
|
||||
with self._open(filename, "w") as f:
|
||||
f.write(contents)
|
||||
|
||||
return "Minimal configuration saved to '{}'".format(filename)
|
||||
if self._write_if_changed(filename, self._min_config_contents(header)):
|
||||
return "Minimal configuration saved to '{}'".format(filename)
|
||||
return "No change to minimal configuration in '{}'".format(filename)
|
||||
|
||||
def _min_config_contents(self, header):
|
||||
# write_min_config() helper. Returns the contents to write as a string,
|
||||
|
@ -2264,10 +2266,15 @@ class Kconfig(object):
|
|||
# differs, but it breaks stuff like write_config("/dev/null"), which is
|
||||
# used out there to force evaluation-related warnings to be generated.
|
||||
# This simple version is pretty failsafe and portable.
|
||||
#
|
||||
# Returns True if the file has changed and is updated, and False
|
||||
# otherwise.
|
||||
|
||||
if not self._contents_eq(filename, contents):
|
||||
with self._open(filename, "w") as f:
|
||||
f.write(contents)
|
||||
if self._contents_eq(filename, contents):
|
||||
return False
|
||||
with self._open(filename, "w") as f:
|
||||
f.write(contents)
|
||||
return True
|
||||
|
||||
def _contents_eq(self, filename, contents):
|
||||
# Returns True if the contents of 'filename' is 'contents' (a string),
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Copyright (c) 2018-2019, Nordic Semiconductor ASA and Ulf Magnusson
|
||||
# SPDX-License-Identifier: ISC
|
||||
|
|
Loading…
Reference in a new issue