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

cmake: Treat pristine build warnings as errors #77843

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

talih0
Copy link
Contributor

@talih0 talih0 commented Aug 31, 2024

A pristine build is needed when snippets are changed. Currently, this only triggers a warning which can easily be missed and the new target snippets won't be applied.
Make the warning an error.

A pristine build is needed when snippets/boards/shields are changed. Currently, this is treated as a warning which can be easily missed and the new settings won't be applied. Treat the warning as an error.

A pristine build is needed when snippets are changed. Currently
this only triggers a warning which can easily be missed.

Signed-off-by: Andriy Gelman <[email protected]>
@zephyrbot zephyrbot added area: Build System size: XS A PR changing only a single line of code labels Aug 31, 2024
glenn-andrews
glenn-andrews previously approved these changes Aug 31, 2024
Copy link
Collaborator

@glenn-andrews glenn-andrews left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. The more stuff that doesn't silently fail, the better.

@@ -3328,7 +3328,7 @@ function(zephyr_check_cache variable)
# without cleaning first
if(cli_argument)
if(NOT ((CACHED_${variable} STREQUAL cli_argument) OR (${variable}_DEPRECATED STREQUAL cli_argument)))
message(WARNING "The build directory must be cleaned pristinely when "
message(FATAL_ERROR "The build directory must be cleaned pristinely when "
Copy link
Collaborator

@tejlmand tejlmand Sep 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not only impacting snippets but is impacting every setting which are not allowed to be changed, including BOARD and SHIELD.

Thus I believe a broader audience should be included if we're to change the build system behavior.

Also. if this is changed to an error, then the following code, which becomes dead code with the proposed change, should be cleaned up in addition.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll have a look at cleaning up the following code. Also changed the title to take into account your feedback.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another, and perhaps better alternative, is to change from WARNING to AUTHOR_WARNING.

That will allow developers to error on warnings by calling cmake with: -Werror=dev, while still keeping it a warning for others.

Copy link
Contributor Author

@talih0 talih0 Sep 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way, an error is already thrown by West when compiling for a different target board without a pristine build:

image

But it will create a warning when run with cmake directly. Shouldn't we be consistent between cmake and west?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure why west build decided to error out early on board, but zephyr_check_cache is a common available Zephyr CMake extension function which can used elsewhere, even by downstream projects / modules.

@glenn-andrews glenn-andrews dismissed their stale review September 2, 2024 15:08

Didn't think through the implications properly.

@talih0 talih0 changed the title cmake: treat snippet warning as error cmake: Treat pristine build warnings as errors Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Build System size: XS A PR changing only a single line of code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants