Skip to content

Commit

Permalink
fix: correct checking of ncs versions
Browse files Browse the repository at this point in the history
Second time is a charm :)
  • Loading branch information
MarkoSagadin committed Dec 18, 2024
1 parent 8ef15f6 commit bc3c921
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

## [Unreleased]

### Fixed

- A bug where `east install toolchain` command wouldn't correctly detect supported versions
from `nrfutil-toolchain-manager`.

## [0.25.0] - 2024-11-28

### Changed
Expand Down
11 changes: 8 additions & 3 deletions src/east/east_context.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import importlib.metadata
import inspect
import json
import os
import signal
import subprocess
Expand Down Expand Up @@ -437,9 +438,13 @@ def pre_workspace_command_check(
return

# Check if toolchain for detected ncs version is supported
result = self.run_manager("search --show-all", silent=True, return_output=True)
result = self.run_manager(
"search --show-all --json", silent=True, return_output=True
)

supported_ncs_versions = json.loads(result["output"])["data"]["ncs_versions"]

if self.detected_ncs_version == result["output"]:
if self.detected_ncs_version in supported_ncs_versions:
# Supported but not installed, should we exit program or silently pass?
if ignore_uninstalled_ncs:
return
Expand All @@ -454,7 +459,7 @@ def pre_workspace_command_check(

# Exit program, this is usually happens, if we want to install the toolchain.
self.print(
ncs_version_not_supported_msg(self, result["output"]), highlight=False
ncs_version_not_supported_msg(self, supported_ncs_versions), highlight=False
)
self.exit()

Expand Down
6 changes: 3 additions & 3 deletions src/east/helper_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,7 @@ def no_toolchain_msg(east):

def ncs_version_not_supported_msg(east, supported_versions):
"""Return message that informs user that detected NCS version is not supported."""
vers = "\n".join(
[f"[bold yellow]•[/] {ver}" for ver in supported_versions.strip().split("\n")]
)
vers = "\n".join([f"[bold yellow]•[/] {ver}" for ver in supported_versions])

return (
f"[bold]East[/] detected [bold]{east.detected_ncs_version}[/] [bold cyan]NCS[/]"
Expand Down Expand Up @@ -411,6 +409,7 @@ def get_jlink_param(runner_yaml_content, jlink_param):
except (KeyError, StopIteration):
return None


def find_app_build_dir(build_dir):
"""Find the build directory of the app."""
try:
Expand Down Expand Up @@ -447,6 +446,7 @@ def get_device_in_runner_yaml(build_dir):

return device


def get_jlink_speed_in_runner_yaml(build_dir):
"""Returns speed flag for JLink runner from runners.yaml.
Expand Down

0 comments on commit bc3c921

Please sign in to comment.