Skip to content

Commit 0399469

Browse files
martinjaegersylvioalves
authored andcommitted
west: tools.py: fix espressif monitor command for sysbuild
Runing `west espressif monitor` failed when the app was built with `--sysbuild`. Using domain.build_dir to get path for app built with sysbuild now. Function get_build_dir (copied from zephyr repo) is removed because it is not needed here. Signed-off-by: Martin Jäger <[email protected]>
1 parent 85c44ce commit 0399469

File tree

2 files changed

+10
-52
lines changed

2 files changed

+10
-52
lines changed

tools/idf_monitor/idf_monitor_base/output_helpers.py

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -41,27 +41,6 @@
4141
ANSI_NORMAL = '\033[0m'
4242

4343

44-
def get_build_dir(args, die_if_none=True):
45-
# Get the build directory for the given argument list and environment.
46-
47-
guess = config.get('build', 'guess-dir', fallback='never')
48-
guess = guess == 'runners'
49-
dir = find_build_dir(None, guess)
50-
51-
if dir and is_zephyr_build(dir):
52-
return dir
53-
elif die_if_none:
54-
msg = 'could not find build directory and '
55-
if dir:
56-
msg = msg + 'neither {} nor {} are zephyr build directories.'
57-
else:
58-
msg = msg + ('{} is not a build directory and the default build '
59-
'directory cannot be determined. ')
60-
log.die(msg.format(os.getcwd(), dir))
61-
else:
62-
return None
63-
64-
6544
def color_print(message, color, newline='\n'): # type: (str, str, Optional[str]) -> None
6645
""" Print a message to stderr with colored highlighting """
6746
sys.stderr.write('%s%s%s%s' % (color, message, ANSI_NORMAL, newline))
@@ -82,13 +61,14 @@ def red_print(message, newline='\n'): # type: (str, Optional[str]) -> None
8261
def lookup_pc_address(pc_addr, toolchain_prefix, elf_file): # type: (str, str, str) -> Optional[str]
8362
# cmd = ['%saddr2line' % toolchain_prefix, '-pfiaC', '-e', elf_file, pc_addr]
8463

85-
# build dir differs when sysbuild is used
86-
build_dir = get_build_dir(None)
64+
build_dir = find_build_dir(None, True)
8765
domain = load_domains(build_dir).get_default_domain()
88-
if domain.name == 'app':
89-
cache = CMakeCache.from_build_dir(build_dir)
90-
else:
91-
cache = CMakeCache.from_build_dir(Path(build_dir) / domain.name)
66+
67+
# build dir differs when sysbuild is used
68+
if domain.build_dir:
69+
build_dir = domain.build_dir
70+
71+
cache = CMakeCache.from_build_dir(build_dir)
9272

9373
# Zephyr: set toolchain from environment path
9474
toolchain_path = cache['CMAKE_ADDR2LINE']

west/tools.py

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -65,27 +65,6 @@ def get_esp_serial_port(module_path):
6565
return None
6666

6767

68-
def get_build_dir(path, die_if_none=True):
69-
# Get the build directory for the given argument list and environment.
70-
71-
guess = config.get('build', 'guess-dir', fallback='never')
72-
guess = guess == 'runners'
73-
dir = find_build_dir(path, guess)
74-
75-
if dir and is_zephyr_build(dir):
76-
return dir
77-
elif die_if_none:
78-
msg = 'could not find build directory and '
79-
if dir:
80-
msg = msg + 'neither {} nor {} are zephyr build directories.'
81-
else:
82-
msg = msg + ('{} is not a build directory and the default build '
83-
'directory cannot be determined. ')
84-
log.die(msg.format(os.getcwd(), dir))
85-
else:
86-
return None
87-
88-
8968
def parse_runners_yaml():
9069
def runners_yaml_path(build_dir):
9170
ret = Path(build_dir) / 'zephyr' / 'runners.yaml'
@@ -111,13 +90,12 @@ def load_runners_yaml(path):
11190
global build_elf_path
11291
global baud_rate
11392

114-
build_dir = get_build_dir(None)
93+
build_dir = find_build_dir(None, True)
11594
domain = load_domains(build_dir).get_default_domain()
11695

11796
# build dir differs when sysbuild is used
118-
if domain.name != 'app':
119-
build_dir = Path(build_dir) / domain.name
120-
build_dir = get_build_dir(build_dir)
97+
if domain.build_dir:
98+
build_dir = domain.build_dir
12199

122100
yaml_path = runners_yaml_path(build_dir)
123101
runners_yaml = load_runners_yaml(yaml_path)

0 commit comments

Comments
 (0)