Skip to content

Commit d0f082d

Browse files
ulfalizercarlescufi
authored andcommitted
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 <[email protected]>
1 parent 9dc4eed commit d0f082d

File tree

5 files changed

+29
-21
lines changed

5 files changed

+29
-21
lines changed

scripts/dts/gen_defines.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,12 @@ def main():
7474

7575
write_flash(edt)
7676

77-
print("Devicetree configuration written to " + args.conf_out)
78-
7977
conf_file.close()
8078
header_file.close()
8179

80+
print(f"Devicetree header saved to '{args.header_out}'")
81+
82+
8283
def parse_args():
8384
# Returns parsed command-line arguments
8485

scripts/kconfig/guiconfig.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22

33
# Copyright (c) 2019, Nordic Semiconductor ASA and Ulf Magnusson
44
# SPDX-License-Identifier: ISC

scripts/kconfig/kconfig.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def main():
8282

8383
# Write the merged configuration and the C header
8484
print(kconf.write_config(args.config_out))
85-
kconf.write_autoconf(args.header_out)
85+
print(kconf.write_autoconf(args.header_out))
8686

8787
# Write the list of parsed Kconfig files to a file
8888
write_kconfig_filenames(kconf, args.kconfig_list_out)

scripts/kconfig/kconfiglib.py

+23-16
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ def my_other_fn(kconf, name, arg_1, arg_2, ...):
554554
from os.path import dirname, exists, expandvars, islink, join, realpath
555555

556556

557-
VERSION = (13, 7, 1)
557+
VERSION = (14, 1, 0)
558558

559559

560560
# File layout:
@@ -1444,12 +1444,18 @@ def write_autoconf(self, filename=None, header=None):
14441444
KCONFIG_AUTOHEADER_HEADER had when the Kconfig instance was created
14451445
will be used if it was set, and no header otherwise. See the
14461446
Kconfig.header_header attribute.
1447+
1448+
Returns a string with a message saying that the header got saved, or
1449+
that there were no changes to it. This is meant to reduce boilerplate
1450+
in tools, which can do e.g. print(kconf.write_autoconf()).
14471451
"""
14481452
if filename is None:
14491453
filename = os.getenv("KCONFIG_AUTOHEADER",
14501454
"include/generated/autoconf.h")
14511455

1452-
self._write_if_changed(filename, self._autoconf_contents(header))
1456+
if self._write_if_changed(filename, self._autoconf_contents(header)):
1457+
return "Kconfig header saved to '{}'".format(filename)
1458+
return "No change to Kconfig header in '{}'".format(filename)
14531459

14541460
def _autoconf_contents(self, header):
14551461
# write_autoconf() helper. Returns the contents to write as a string,
@@ -1564,7 +1570,7 @@ def write_config(self, filename=None, header=None, save_old=True,
15641570

15651571
contents = self._config_contents(header)
15661572
if self._contents_eq(filename, contents):
1567-
return "No change to '{}'".format(filename)
1573+
return "No change to configuration in '{}'".format(filename)
15681574

15691575
if save_old:
15701576
_save_old(filename)
@@ -1677,18 +1683,14 @@ def write_min_config(self, filename, header=None):
16771683
be used if it was set, and no header otherwise. See the
16781684
Kconfig.config_header attribute.
16791685
1680-
Returns a string with a message saying which file got saved. This is
1681-
meant to reduce boilerplate in tools, which can do e.g.
1686+
Returns a string with a message saying the minimal configuration got
1687+
saved, or that there were no changes to it. This is meant to reduce
1688+
boilerplate in tools, which can do e.g.
16821689
print(kconf.write_min_config()).
16831690
"""
1684-
contents = self._min_config_contents(header)
1685-
if self._contents_eq(filename, contents):
1686-
return "No change to '{}'".format(filename)
1687-
1688-
with self._open(filename, "w") as f:
1689-
f.write(contents)
1690-
1691-
return "Minimal configuration saved to '{}'".format(filename)
1691+
if self._write_if_changed(filename, self._min_config_contents(header)):
1692+
return "Minimal configuration saved to '{}'".format(filename)
1693+
return "No change to minimal configuration in '{}'".format(filename)
16921694

16931695
def _min_config_contents(self, header):
16941696
# write_min_config() helper. Returns the contents to write as a string,
@@ -2264,10 +2266,15 @@ def _write_if_changed(self, filename, contents):
22642266
# differs, but it breaks stuff like write_config("/dev/null"), which is
22652267
# used out there to force evaluation-related warnings to be generated.
22662268
# This simple version is pretty failsafe and portable.
2269+
#
2270+
# Returns True if the file has changed and is updated, and False
2271+
# otherwise.
22672272

2268-
if not self._contents_eq(filename, contents):
2269-
with self._open(filename, "w") as f:
2270-
f.write(contents)
2273+
if self._contents_eq(filename, contents):
2274+
return False
2275+
with self._open(filename, "w") as f:
2276+
f.write(contents)
2277+
return True
22712278

22722279
def _contents_eq(self, filename, contents):
22732280
# Returns True if the contents of 'filename' is 'contents' (a string),

scripts/kconfig/menuconfig.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22

33
# Copyright (c) 2018-2019, Nordic Semiconductor ASA and Ulf Magnusson
44
# SPDX-License-Identifier: ISC

0 commit comments

Comments
 (0)