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: mcuboot: remove obsolete check for west to sign #86439

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

Conversation

ckhardin
Copy link

As of c952f09 the calls to west sign were replaced with imgtool and this check is not relevant. As it stands since west is optional - it is possible to complete a signed build without west being installed if this check is removed.

Fixes: #86438

As of c952f09 the calls to west
sign were replaced with imgtool and this check is not relevant. As
it stands since west is optional - it is possible to complete a
signed build without west being installed if this check is removed.

Fixes: zephyrproject-rtos#86438
Signed-off-by: Charles Hardin <[email protected]>
Copy link

Hello @ckhardin, and thank you very much for your first pull request to the Zephyr project!
Our Continuous Integration pipeline will execute a series of checks on your Pull Request commit messages and code, and you are expected to address any failures by updating the PR. Please take a look at our commit message guidelines to find out how to format your commit messages, and at our contribution workflow to understand how to update your Pull Request. If you haven't already, please make sure to review the project's Contributor Expectations and update (by amending and force-pushing the commits) your pull request if necessary.
If you are stuck or need help please join us on Discord and ask your question there. Additionally, you can escalate the review when applicable. 😊

# This feature requires west.
message(FATAL_ERROR "Can't sign images for MCUboot: west not found. To fix, install west and ensure it's on PATH.")
endif()

foreach(file keyfile keyfile_enc)
Copy link
Collaborator

Choose a reason for hiding this comment

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

the WEST_TOPDIR parts below I would assume would be blank if west is not used

Copy link
Collaborator

Choose a reason for hiding this comment

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

nice catch.

Perhaps we should treat relative paths relative to Zephyr base ?
Though the problem with that would be that it's a breaking change for those who might depends on the path relative to west topdir.

But having a different relative to west topdir when west is present and relative to zephyr base when west is not present is even worse.

For relative files only, then perhaps the best option is to check for the file relative to ZEPHYR_BASE and if found there, then use that file.
If not found there and west is installed, then check relative to west topdir, and it found there, use that file but also print a deprecation warning that relative to west topdir will be removed in the future.

@nordicjm toughts ?

Copy link
Author

@ckhardin ckhardin Feb 28, 2025

Choose a reason for hiding this comment

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

for what it is worth - from the this cmake code - we are a custom zephyr project so we set absolute paths when we call into zephyr to avoid relative issues like the concern. So, the lack of west doesn't hurt us and the code for WEST_TOPDIR doesn't get invoked.

From cmake/modules/west.cmake

  execute_process(
    COMMAND ${WEST} topdir
    OUTPUT_VARIABLE WEST_TOPDIR
    ERROR_QUIET
    RESULT_VARIABLE west_topdir_result
    OUTPUT_STRIP_TRAILING_WHITESPACE
    WORKING_DIRECTORY ${ZEPHYR_BASE}
    )

  if(west_topdir_result)
    # west topdir is undefined.
    # That's fine; west is optional, so could be custom Zephyr project.
    set(WEST WEST-NOTFOUND CACHE INTERNAL "West")
  endif()

I would argue that if a change was desired just allow someone to set "WEST_TOPDIR" as a config output instead of calling "west topdir" and leave the rest of the logic as is. That seems to fit a lot of the style/patterns in the cmake setup so far - something like the following.

diff --git a/firmware/zephyr/cmake/modules/west.cmake b/firmware/zephyr/cmake/modules/west.cmake
index f35e7a3c..cf7a46e9 100644
--- a/firmware/zephyr/cmake/modules/west.cmake
+++ b/firmware/zephyr/cmake/modules/west.cmake
@@ -80,18 +80,20 @@ else()
   # will still work even after output is one line.
   message(STATUS "Found west (found suitable version \"${west_version}\", minimum required is \"${MIN_WEST_VERSION}\")")
 
-  execute_process(
-    COMMAND ${WEST} topdir
-    OUTPUT_VARIABLE WEST_TOPDIR
-    ERROR_QUIET
-    RESULT_VARIABLE west_topdir_result
-    OUTPUT_STRIP_TRAILING_WHITESPACE
-    WORKING_DIRECTORY ${ZEPHYR_BASE}
-    )
+  if(NOT DEFINED WEST_TOPDIR)
+    execute_process(
+      COMMAND ${WEST} topdir
+      OUTPUT_VARIABLE WEST_TOPDIR
+      ERROR_QUIET
+      RESULT_VARIABLE west_topdir_result
+      OUTPUT_STRIP_TRAILING_WHITESPACE
+      WORKING_DIRECTORY ${ZEPHYR_BASE}
+      )
 
-  if(west_topdir_result)
-    # west topdir is undefined.
-    # That's fine; west is optional, so could be custom Zephyr project.
-    set(WEST WEST-NOTFOUND CACHE INTERNAL "West")
+    if(west_topdir_result)
+      # west topdir is undefined.
+      # That's fine; west is optional, so could be custom Zephyr project.
+      set(WEST WEST-NOTFOUND CACHE INTERNAL "West")
+    endif()
   endif()
 endif()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MCUBoot image signing will fail in a docker container without west being installed
5 participants