cmake: kconfig: Fix rerunning cmake after Kconfig warnings
Commit b3d165f
("scripts: kconfig: Handle warnings generated
during evaluation") made it common for kconfig.py to fail after writing
zephyr/.config. This confuses the configuration fragment checksum logic
in cmake/kconfig.cmake, because it expects the saved checksum file to
exist if zephyr/.config exists.
The end result is a CMake error when rerunning the configuration after
non-whitelisted Kconfig warnings.
Fix it by only writing zephyr/.config (and zephyr/include/autoconf.h) in
kconfig.py if there are no warnings-turned-errors.
Also check if the saved checksum file exists in kconfig.cmake before
trying to open it. Normally this shouldn't happen though.
Move the writing of the checksum file to before writing zephyr/.config
as well. That way, zephyr/.config only gets written if the other
operations succeed.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
This commit is contained in:
parent
11aa0b8006
commit
5402662dd9
|
@ -103,25 +103,30 @@ endforeach()
|
|||
# Create a new .config if it does not exists, or if the checksum of
|
||||
# the dependencies has changed
|
||||
set(merge_config_files_checksum_file ${PROJECT_BINARY_DIR}/.cmake.dotconfig.checksum)
|
||||
set(CREATE_NEW_DOTCONFIG "")
|
||||
if(NOT EXISTS ${DOTCONFIG})
|
||||
set(CREATE_NEW_DOTCONFIG 1)
|
||||
else()
|
||||
set(CREATE_NEW_DOTCONFIG 1)
|
||||
# Check if the checksum file exists too before trying to open it, though it
|
||||
# should under normal circumstances
|
||||
if(EXISTS ${DOTCONFIG} AND EXISTS ${merge_config_file_checksum_file})
|
||||
# Read out what the checksum was previously
|
||||
file(READ
|
||||
${merge_config_files_checksum_file}
|
||||
merge_config_files_checksum_prev
|
||||
)
|
||||
set(CREATE_NEW_DOTCONFIG 1)
|
||||
if(
|
||||
${merge_config_files_checksum} STREQUAL
|
||||
${merge_config_files_checksum_prev}
|
||||
)
|
||||
# Checksum is the same as before
|
||||
set(CREATE_NEW_DOTCONFIG 0)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CREATE_NEW_DOTCONFIG)
|
||||
file(WRITE
|
||||
${merge_config_files_checksum_file}
|
||||
${merge_config_files_checksum}
|
||||
)
|
||||
|
||||
set(merge_fragments ${merge_config_files})
|
||||
else()
|
||||
set(merge_fragments ${DOTCONFIG})
|
||||
|
@ -144,13 +149,6 @@ if(NOT "${ret}" STREQUAL "0")
|
|||
message(FATAL_ERROR "command failed with return code: ${ret}")
|
||||
endif()
|
||||
|
||||
if(CREATE_NEW_DOTCONFIG)
|
||||
file(WRITE
|
||||
${merge_config_files_checksum_file}
|
||||
${merge_config_files_checksum}
|
||||
)
|
||||
endif()
|
||||
|
||||
# Force CMAKE configure when the configuration files changes.
|
||||
foreach(merge_config_input ${merge_config_files} ${DOTCONFIG})
|
||||
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${merge_config_input})
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
# Modified from: https://github.com/ulfalizer/Kconfiglib/blob/master/examples/merge_config.py
|
||||
import argparse
|
||||
import os
|
||||
import sys
|
||||
import textwrap
|
||||
|
||||
|
@ -58,13 +59,6 @@ def main():
|
|||
kconf.load_config(config, replace=False)
|
||||
|
||||
|
||||
# Write the merged configuration and the C header. This will evaluate all
|
||||
# symbols, which might generate additional warnings, so do it before
|
||||
# checking for warnings.
|
||||
kconf.write_config(args.dotconfig)
|
||||
kconf.write_autoconf(args.autoconf)
|
||||
|
||||
|
||||
# Print warnings for symbols whose actual value doesn't match the assigned
|
||||
# value
|
||||
for sym in kconf.defined_syms:
|
||||
|
@ -78,6 +72,14 @@ def main():
|
|||
if choice.user_selection:
|
||||
verify_assigned_choice_value(choice)
|
||||
|
||||
# Hack: Force all symbols to be evaluated, to catch warnings generated
|
||||
# during evaluation. Wait till the end to write the actual output files, so
|
||||
# that we don't generate any output if there are warnings-turned-errors.
|
||||
#
|
||||
# Kconfiglib caches calculated symbol values internally, so this is still
|
||||
# fast.
|
||||
kconf.write_config(os.devnull)
|
||||
|
||||
# We could roll this into the loop below, but it's nice to always print all
|
||||
# warnings, even if one of them turns out to be fatal
|
||||
for warning in kconf.warnings:
|
||||
|
@ -100,6 +102,11 @@ def main():
|
|||
.format(warning, sys.argv[0]))
|
||||
|
||||
|
||||
# Write the merged configuration and the C header
|
||||
kconf.write_config(args.dotconfig)
|
||||
kconf.write_autoconf(args.autoconf)
|
||||
|
||||
|
||||
# Message printed when a promptless symbol is assigned (and doesn't get the
|
||||
# assigned value)
|
||||
PROMPTLESS_HINT = """
|
||||
|
|
Loading…
Reference in a new issue