Skip to content

Commit

Permalink
scripts: footprint: Fix size_report on freestanding apps
Browse files Browse the repository at this point in the history
os.path.commonpath() throws a ValueError exception when paths in the
list provided share nothing in common (like for example two Windows
paths on different drive letters). Handle that special case properly
instead of letting the exception propagate up.

Fixes zephyrproject-rtos#51549.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
  • Loading branch information
carlescufi authored and nashif committed May 30, 2023
1 parent b6c80d1 commit 462dc97
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions scripts/footprint/size_report
Original file line number Diff line number Diff line change
Expand Up @@ -520,8 +520,10 @@ def find_common_path_prefix(symbol_dict):
for file in symbol['mapped_files']:
paths.append(file)

return os.path.commonpath(paths)

try:
return os.path.commonpath(paths)
except ValueError:
return None

class TreeNode(NodeMixin):
"""
Expand Down Expand Up @@ -560,7 +562,7 @@ def generate_any_tree(symbol_dict, total_size, path_prefix):
root = TreeNode('Root', "root")
node_no_paths = TreeNode('(no paths)', ":", parent=root)

if Path(path_prefix) == Path(args.zephyrbase):
if path_prefix and Path(path_prefix) == Path(args.zephyrbase):
# All source files are under ZEPHYR_BASE so there is
# no need for another level.
node_zephyr_base = root
Expand Down

0 comments on commit 462dc97

Please sign in to comment.