Skip to content

Commit 4554c9a

Browse files
committed
[nrf noup] cmake: Kconfig: strict mode
fail building uppon ineffective Kconfigs Signed-off-by: Mateusz Michalek <mateusz.michalek@nordicsemi.no>
1 parent a8d9f5e commit 4554c9a

51 files changed

Lines changed: 304 additions & 93 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cmake/modules/kconfig.cmake

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/kconfig/include/config)
2020

2121
set_ifndef(KCONFIG_NAMESPACE "CONFIG")
2222

23+
set_ifndef(KCONFIG_STRICT_USER_CONFIG ON)
24+
2325
set_ifndef(KCONFIG_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/Kconfig)
2426
set(KCONFIG_BOARD_DIR ${KCONFIG_BINARY_DIR}/boards)
2527
file(MAKE_DIRECTORY ${KCONFIG_BINARY_DIR})
@@ -328,6 +330,21 @@ foreach(f ${merge_config_files})
328330
endforeach()
329331
set(merge_config_files ${merge_config_files_with_absolute_paths})
330332

333+
# User-provided configuration fragments (prj.conf, sysbuild.conf, CLI, etc.)
334+
# used for strict assignment checking. Board/shield defaults are excluded.
335+
set(KCONFIG_USER_CONFIG_FILES "")
336+
foreach(user_conf IN LISTS CONF_FILE_AS_LIST EXTRA_CONF_FILE_AS_LIST config_files)
337+
if(IS_ABSOLUTE ${user_conf})
338+
set(user_conf_path ${user_conf})
339+
else()
340+
set(user_conf_path ${APPLICATION_CONFIG_DIR}/${user_conf})
341+
endif()
342+
list(APPEND KCONFIG_USER_CONFIG_FILES ${user_conf_path})
343+
endforeach()
344+
if(EXTRA_KCONFIG_OPTIONS_FILE)
345+
list(APPEND KCONFIG_USER_CONFIG_FILES ${EXTRA_KCONFIG_OPTIONS_FILE})
346+
endif()
347+
331348
foreach(f ${merge_config_files})
332349
if(NOT EXISTS ${f} OR IS_DIRECTORY ${f})
333350
message(FATAL_ERROR "File not found: ${f}")
@@ -397,6 +414,28 @@ if(DEFINED FORCED_CONF_FILE)
397414
list(APPEND input_configs_flags --forced-input-configs)
398415
endif()
399416

417+
set(kconfig_strict_args)
418+
set(kconfig_strict_user_config_files "")
419+
zephyr_get(KCONFIG_STRICT_USER_CONFIG SYSBUILD GLOBAL)
420+
if(KCONFIG_STRICT_USER_CONFIG)
421+
list(APPEND kconfig_strict_user_config_files ${KCONFIG_USER_CONFIG_FILES})
422+
elseif(EXTRA_KCONFIG_OPTIONS_FILE AND EXISTS ${EXTRA_KCONFIG_OPTIONS_FILE})
423+
file(READ ${EXTRA_KCONFIG_OPTIONS_FILE} extra_kconfig_options_content)
424+
string(STRIP "${extra_kconfig_options_content}" extra_kconfig_options_content)
425+
if(extra_kconfig_options_content)
426+
set(KCONFIG_STRICT_USER_CONFIG ON)
427+
list(APPEND kconfig_strict_user_config_files ${EXTRA_KCONFIG_OPTIONS_FILE})
428+
endif()
429+
endif()
430+
if(KCONFIG_STRICT_USER_CONFIG)
431+
list(APPEND kconfig_strict_args --strict-user-configs)
432+
foreach(user_conf ${kconfig_strict_user_config_files})
433+
if(EXISTS ${user_conf})
434+
list(APPEND kconfig_strict_args --user-config-files ${user_conf})
435+
endif()
436+
endforeach()
437+
endif()
438+
400439
cmake_path(GET AUTOCONF_H PARENT_PATH autoconf_h_path)
401440
if(NOT EXISTS ${autoconf_h_path})
402441
file(MAKE_DIRECTORY ${autoconf_h_path})
@@ -410,6 +449,7 @@ execute_process(
410449
${ZEPHYR_BASE}/scripts/kconfig/kconfig.py
411450
--zephyr-base=${ZEPHYR_BASE}
412451
${input_configs_flags}
452+
${kconfig_strict_args}
413453
${KCONFIG_ROOT}
414454
${DOTCONFIG}
415455
${AUTOCONF_H}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
CONFIG_ARM_SCMI_SHELL=y
1+
CONFIG_ARM_SCMI_SHELL=n
22
CONFIG_BOOT_BANNER=n

samples/net/ethernet/gptp/boards/native_sim.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
CONFIG_ETH_NATIVE_TAP_PTP_CLOCK=y
33

44
#CONFIG_ETH_NATIVE_TAP_RANDOM_MAC=y
5-
CONFIG_ETH_NATIVE_TAP_MAC_ADDR="00:00:5e:00:53:2a"
5+
# CONFIG_ETH_NATIVE_TAP_MAC_ADDR is not set
66

77
# Assume 1 ms accuracy for native_sim simulated clock
88
CONFIG_NET_GPTP_CLOCK_ACCURACY_1MS=y

samples/net/ocpp/prj.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ CONFIG_PICOLIBC=y
3333
CONFIG_NET_ARP=y
3434
CONFIG_NET_UDP=y
3535
CONFIG_NET_DHCPV4=y
36-
CONFIG_NET_DHCPV4_OPTION_CALLBACKS=y
36+
CONFIG_NET_DHCPV4_OPTION_CALLBACKS=n
3737
CONFIG_TEST_RANDOM_GENERATOR=y
3838

3939
CONFIG_NET_TX_STACK_SIZE=2048

samples/net/ptp/boards/native_sim.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
CONFIG_ETH_NATIVE_TAP_PTP_CLOCK=y
33

44
#CONFIG_ETH_NATIVE_TAP_RANDOM_MAC=y
5-
CONFIG_ETH_NATIVE_TAP_MAC_ADDR="00:00:5e:00:53:2a"
5+
# CONFIG_ETH_NATIVE_TAP_MAC_ADDR is not set
66

77
# Assume 1 ms accuracy for native_sim simulated clock
88
CONFIG_PTP_CLOCK_ACCURACY_1MS=y

samples/net/sockets/coap_server/prj.conf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ CONFIG_NET_MGMT_EVENT_INFO=y
4141
# IPv6 Support
4242
CONFIG_NET_IPV6=y
4343
CONFIG_NET_CONFIG_NEED_IPV6=y
44-
CONFIG_NET_CONFIG_MY_IPV6_ADDR="2001:db8::1"
45-
CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=5
44+
# CONFIG_NET_CONFIG_MY_IPV6_ADDR is not set
45+
# CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT is not set
4646

4747
#IPv4 Support
4848
CONFIG_NET_IPV4=n
4949
CONFIG_NET_CONFIG_NEED_IPV4=n
50-
CONFIG_NET_CONFIG_MY_IPV4_ADDR="192.0.2.1"
50+
# CONFIG_NET_CONFIG_MY_IPV4_ADDR is not set
5151

5252
# Enable v4-mapped-on-v6
53-
CONFIG_NET_IPV4_MAPPING_TO_IPV6=y
53+
CONFIG_NET_IPV4_MAPPING_TO_IPV6=n

samples/net/sockets/echo_server/overlay-ws-console.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ CONFIG_EVENTFD=y
66
CONFIG_POSIX_API=y
77
CONFIG_NET_SOCKETS_POLL_MAX=32
88
CONFIG_NET_MAX_CONN=32
9-
CONFIG_NET_SOCKETS_TLS_MAX_CONTEXTS=32
9+
# CONFIG_NET_SOCKETS_TLS_MAX_CONTEXTS is not set
1010
CONFIG_ZVFS_EVENTFD_MAX=10
1111
CONFIG_ZVFS_OPEN_ADD_SIZE_NET_SAMPLE=24

samples/net/stats/prj.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ CONFIG_NET_CONFIG_MY_IPV4_ADDR="192.0.2.1"
4545

4646
# Logging
4747
CONFIG_LOG=y
48-
CONFIG_LOG_BUFFER_SIZE=4096
48+
# CONFIG_LOG_BUFFER_SIZE is not set

samples/net/syslog_net/prj.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ CONFIG_NET_BUF_RX_COUNT=32
99
CONFIG_NET_BUF_TX_COUNT=32
1010
CONFIG_NET_SOCKETS=y
1111

12-
CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=3
13-
CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=5
12+
# CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT is not set
13+
# CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT is not set
1414

1515
CONFIG_NET_LOG=y
1616
CONFIG_LOG=y

samples/net/zperf/prj.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ CONFIG_NET_CONFIG_PEER_IPV4_ADDR="192.0.2.2"
3939
CONFIG_LOG=y
4040
CONFIG_SHELL_CMDS_RESIZE=n
4141

42-
CONFIG_CACHE_MANAGEMENT=y
42+
CONFIG_CACHE_MANAGEMENT=n
4343
CONFIG_SPEED_OPTIMIZATIONS=y
4444
CONFIG_TIMESLICING=n
4545

4646
# For speed optimizations
47-
CONFIG_PICOLIBC_USE_MODULE=y
47+
CONFIG_PICOLIBC_USE_MODULE=n

0 commit comments

Comments
 (0)