scripts: size_report: add tree node for WORKSPACE
Add a tree node to group files under WORKSPACE so that they won't be shown with full path. The WORKSPACE is usually the same as WEST_TOPDIR unless ZEPHYR_WORKSPACE is defined during build. Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This commit is contained in:
parent
c3e8c4e6dc
commit
d475f9865b
2 changed files with 40 additions and 9 deletions
|
@ -4,6 +4,12 @@ set(flag_for_ram_report ram)
|
||||||
set(flag_for_rom_report rom)
|
set(flag_for_rom_report rom)
|
||||||
set(report_depth 99)
|
set(report_depth 99)
|
||||||
|
|
||||||
|
if(DEFINED ZEPHYR_WORKSPACE)
|
||||||
|
set(workspace_arg "--workspace=${ZEPHYR_WORKSPACE}")
|
||||||
|
elseif(DEFINED WEST_TOPDIR)
|
||||||
|
set(workspace_arg "--workspace=${WEST_TOPDIR}")
|
||||||
|
endif()
|
||||||
|
|
||||||
foreach(report ram_report rom_report)
|
foreach(report ram_report rom_report)
|
||||||
add_custom_target(
|
add_custom_target(
|
||||||
${report}
|
${report}
|
||||||
|
@ -12,6 +18,7 @@ foreach(report ram_report rom_report)
|
||||||
-k ${ZEPHYR_BINARY_DIR}/${KERNEL_ELF_NAME}
|
-k ${ZEPHYR_BINARY_DIR}/${KERNEL_ELF_NAME}
|
||||||
-z ${ZEPHYR_BASE}
|
-z ${ZEPHYR_BASE}
|
||||||
-o ${CMAKE_BINARY_DIR}
|
-o ${CMAKE_BINARY_DIR}
|
||||||
|
${workspace_arg}
|
||||||
--json ${CMAKE_BINARY_DIR}/${flag_for_${report}}.json
|
--json ${CMAKE_BINARY_DIR}/${flag_for_${report}}.json
|
||||||
-d ${report_depth}
|
-d ${report_depth}
|
||||||
${flag_for_${report}}
|
${flag_for_${report}}
|
||||||
|
|
|
@ -565,12 +565,18 @@ def generate_any_tree(symbol_dict, total_size, path_prefix):
|
||||||
# no need for another level.
|
# no need for another level.
|
||||||
node_zephyr_base = root
|
node_zephyr_base = root
|
||||||
node_output_dir = root
|
node_output_dir = root
|
||||||
|
node_workspace = root
|
||||||
node_others = root
|
node_others = root
|
||||||
else:
|
else:
|
||||||
node_zephyr_base = TreeNode('ZEPHYR_BASE', args.zephyrbase)
|
node_zephyr_base = TreeNode('ZEPHYR_BASE', args.zephyrbase)
|
||||||
node_output_dir = TreeNode('OUTPUT_DIR', args.output)
|
node_output_dir = TreeNode('OUTPUT_DIR', args.output)
|
||||||
node_others = TreeNode("/", "/")
|
node_others = TreeNode("/", "/")
|
||||||
|
|
||||||
|
if args.workspace:
|
||||||
|
node_workspace = TreeNode('WORKSPACE', args.workspace)
|
||||||
|
else:
|
||||||
|
node_workspace = node_others
|
||||||
|
|
||||||
# A set of helper function for building a simple tree with a path-like
|
# A set of helper function for building a simple tree with a path-like
|
||||||
# hierarchy.
|
# hierarchy.
|
||||||
def _insert_one_elem(root, path, size):
|
def _insert_one_elem(root, path, size):
|
||||||
|
@ -593,8 +599,16 @@ def generate_any_tree(symbol_dict, total_size, path_prefix):
|
||||||
parent = node
|
parent = node
|
||||||
node = TreeNode(name=str(part), identifier=cur, size=size, parent=parent)
|
node = TreeNode(name=str(part), identifier=cur, size=size, parent=parent)
|
||||||
|
|
||||||
zbase = Path(args.zephyrbase)
|
# Mapping paths to tree nodes
|
||||||
outd = Path(args.output)
|
path_node_map = [
|
||||||
|
[Path(args.zephyrbase), node_zephyr_base],
|
||||||
|
[Path(args.output), node_output_dir],
|
||||||
|
]
|
||||||
|
|
||||||
|
if args.workspace:
|
||||||
|
path_node_map.append(
|
||||||
|
[Path(args.workspace), node_workspace]
|
||||||
|
)
|
||||||
|
|
||||||
for name, sym in symbol_dict.items():
|
for name, sym in symbol_dict.items():
|
||||||
for symbol in sym:
|
for symbol in sym:
|
||||||
|
@ -602,13 +616,16 @@ def generate_any_tree(symbol_dict, total_size, path_prefix):
|
||||||
for file in symbol['mapped_files']:
|
for file in symbol['mapped_files']:
|
||||||
path = Path(file, name)
|
path = Path(file, name)
|
||||||
if path.is_absolute():
|
if path.is_absolute():
|
||||||
if zbase in path.parents:
|
has_node = False
|
||||||
path = path.relative_to(zbase)
|
|
||||||
dest_node = node_zephyr_base
|
for one_path in path_node_map:
|
||||||
elif outd in path.parents:
|
if one_path[0] in path.parents:
|
||||||
path = path.relative_to(outd)
|
path = path.relative_to(one_path[0])
|
||||||
dest_node = node_output_dir
|
dest_node = one_path[1]
|
||||||
else:
|
has_node = True
|
||||||
|
break
|
||||||
|
|
||||||
|
if not has_node:
|
||||||
dest_node = node_others
|
dest_node = node_others
|
||||||
else:
|
else:
|
||||||
dest_node = node_no_paths
|
dest_node = node_no_paths
|
||||||
|
@ -632,6 +649,11 @@ def generate_any_tree(symbol_dict, total_size, path_prefix):
|
||||||
# Only include "others" node if there is something.
|
# Only include "others" node if there is something.
|
||||||
children.append(node_others)
|
children.append(node_others)
|
||||||
|
|
||||||
|
if args.workspace:
|
||||||
|
node_workspace.size = sum_node_children_size(node_workspace)
|
||||||
|
if node_workspace.height != 0:
|
||||||
|
children.append(node_workspace)
|
||||||
|
|
||||||
root.children = children
|
root.children = children
|
||||||
|
|
||||||
# Root node doesn't have sum of symbol size. So sum them up.
|
# Root node doesn't have sum of symbol size. So sum them up.
|
||||||
|
@ -691,6 +713,8 @@ def parse_args():
|
||||||
help="Zephyr base path")
|
help="Zephyr base path")
|
||||||
parser.add_argument("-o", "--output", required=True,
|
parser.add_argument("-o", "--output", required=True,
|
||||||
help="Output path")
|
help="Output path")
|
||||||
|
parser.add_argument("-w", "--workspace", default=None,
|
||||||
|
help="Workspace path (Usually the same as WEST_TOPDIR)")
|
||||||
parser.add_argument("target", choices=['rom', 'ram'])
|
parser.add_argument("target", choices=['rom', 'ram'])
|
||||||
parser.add_argument("-d", "--depth", dest="depth",
|
parser.add_argument("-d", "--depth", dest="depth",
|
||||||
type=int, default=None,
|
type=int, default=None,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue