Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

twister: Use proper warnings-to-errors command for sysbuild #4

Open
wants to merge 2 commits into
base: sb-compiler-errors
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion scripts/pylib/twister/twisterlib/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,11 +329,15 @@ def run_cmake(self, args="", filter_stages=[]):
warnings_as_errors = 'n'
gen_defines_args = ""

warning_command = 'CONFIG_COMPILER_WARNINGS_AS_ERRORS'
if self.testsuite.sysbuild:
warning_command = 'SB_' + warning_command

logger.debug("Running cmake on %s for %s" % (self.source_dir, self.platform.name))
cmake_args = [
f'-B{self.build_dir}',
f'-DTC_RUNID={self.instance.run_id}',
f'-DCONFIG_COMPILER_WARNINGS_AS_ERRORS={warnings_as_errors}',
f'-D{warning_command}={warnings_as_errors}',
f'-DEXTRA_GEN_DEFINES_ARGS={gen_defines_args}',
f'-G{self.env.generator}'
]
Expand Down
4 changes: 2 additions & 2 deletions scripts/tests/twister/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ def mock_popen(*args, **kwargs):
None, None,
[os.path.join('dummy', 'cmake'),
'-B' + os.path.join('build', 'dir'), '-DTC_RUNID=1',
'-DCONFIG_COMPILER_WARNINGS_AS_ERRORS=y',
'-DSB_CONFIG_COMPILER_WARNINGS_AS_ERRORS=y',
'-DEXTRA_GEN_DEFINES_ARGS=--edtlib-Werror', '-Gdummy_generator',
'-S' + os.path.join('source', 'dir'),
'arg1', 'arg2',
Expand All @@ -382,7 +382,7 @@ def mock_popen(*args, **kwargs):
'error', 'Cmake build failure',
[os.path.join('dummy', 'cmake'),
'-B' + os.path.join('build', 'dir'), '-DTC_RUNID=1',
'-DCONFIG_COMPILER_WARNINGS_AS_ERRORS=n',
'-DSB_CONFIG_COMPILER_WARNINGS_AS_ERRORS=n',
'-DEXTRA_GEN_DEFINES_ARGS=', '-Gdummy_generator',
'-Szephyr_base/share/sysbuild',
'-DAPP_DIR=' + os.path.join('source', 'dir'),
Expand Down
5 changes: 5 additions & 0 deletions share/sysbuild/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,9 @@ config WARN_DEPRECATED
Print a warning when the Kconfig tree is parsed if any deprecated
features are enabled.

config COMPILER_WARNINGS_AS_ERRORS
bool "Treat warnings as errors"
help
Turn on "warning as error" toolchain flags for all images if set.

rsource "images/Kconfig"
3 changes: 3 additions & 0 deletions share/sysbuild/cmake/modules/sysbuild_extensions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,9 @@ function(ExternalZephyrProject_Add)
if(DEFINED ZBUILD_APP_TYPE)
set(image_default "${CMAKE_SOURCE_DIR}/image_configurations/${ZBUILD_APP_TYPE}_image_default.cmake")
set_target_properties(${ZBUILD_APPLICATION} PROPERTIES IMAGE_CONF_SCRIPT ${image_default})
else()
set(image_default "${CMAKE_SOURCE_DIR}/image_configurations/ALL_image_default.cmake")
set_target_properties(${ZBUILD_APPLICATION} PROPERTIES IMAGE_CONF_SCRIPT ${image_default})
endif()

if(DEFINED ZBUILD_BOARD)
Expand Down
10 changes: 10 additions & 0 deletions share/sysbuild/image_configurations/ALL_image_default.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright (c) 2024 Nordic Semiconductor
#
# SPDX-License-Identifier: Apache-2.0

# This sysbuild CMake file sets the sysbuild controlled settings as properties
# on all images.

if(SB_CONFIG_COMPILER_WARNINGS_AS_ERRORS)
set_config_bool(${ZCMAKE_APPLICATION} CONFIG_COMPILER_WARNINGS_AS_ERRORS y)
endif()
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ foreach(loopkeytype ${keytypes})
set_config_bool(${ZCMAKE_APPLICATION} ${loopkeytype} n)
endif()
endforeach()

include(image_configurations/ALL_image_default.cmake)
2 changes: 2 additions & 0 deletions share/sysbuild/image_configurations/MAIN_image_default.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ if(SB_CONFIG_BOOTLOADER_MCUBOOT)
set_config_bool(${ZCMAKE_APPLICATION} CONFIG_MCUBOOT_GENERATE_UNSIGNED_IMAGE n)
endif()
endif()

include(image_configurations/ALL_image_default.cmake)
Loading