Skip to content

Commit

Permalink
cmake: check sdk_version format
Browse files Browse the repository at this point in the history
Encountered situation when sdk_version string was empty
(as the result of corrupted installation).

The version should had 0.0.0 format.
Patch add check for this and descriptive failure message.

Objective is to help the user to recognize the installation failure.

Signed-off-by: Andrzej Puzdrowski <[email protected]>
  • Loading branch information
nvlsianpu authored and nashif committed Sep 19, 2019
1 parent 571741a commit 4ade5e9
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion cmake/toolchain/zephyr/host-tools.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,17 @@ string(REGEX REPLACE "-.*" "" SDK_VERSION_PRE2 ${SDK_VERSION_PRE1})
# Strip any trailing spaces/newlines from the version string
string(STRIP ${SDK_VERSION_PRE2} SDK_VERSION)
string(REGEX MATCH "([0-9]*).([0-9]*)" SDK_MAJOR_MINOR ${SDK_VERSION})
if(${REQUIRED_SDK_VER} VERSION_GREATER ${SDK_VERSION})

string(REGEX MATCH "([0-9]+)\.([0-9]+)\.([0-9]+)" SDK_MAJOR_MINOR_MICRO ${SDK_VERSION})

#at least 0.0.0
if(NOT SDK_MAJOR_MINOR_MICRO)
message(FATAL_ERROR "sdk version: ${SDK_MAJOR_MINOR_MICRO} improper format.
Expected format: x.y.z
Check whether the Zephyr SDK was installed correctly.
")

elseif(${REQUIRED_SDK_VER} VERSION_GREATER ${SDK_VERSION})
message(FATAL_ERROR "The SDK version you are using is too old, please update your SDK.
You need at least SDK version ${REQUIRED_SDK_VER}.
You have version ${SDK_VERSION} (${ZEPHYR_SDK_INSTALL_DIR}).
Expand Down

0 comments on commit 4ade5e9

Please sign in to comment.