From 06befd6927aaf4c84322c0518c50980d0e0b87b7 Mon Sep 17 00:00:00 2001 From: aodongbiao Date: Thu, 9 Mar 2023 10:28:59 +0800 Subject: [PATCH 1/5] =?UTF-8?q?[rom=5Fram=5Fanalyzer]1.=20log=E4=BC=98?= =?UTF-8?q?=E5=8C=96;=202.=20=E5=8F=96=E6=B6=88=E5=AF=B9test=E7=9B=AE?= =?UTF-8?q?=E5=BD=95=E7=9A=84=E8=BF=87=E6=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: aodongbiao --- tools/rom_ram_analyzer/lite_small/README.md | 8 +++- .../rom_ram_analyzer/lite_small/src/config.py | 3 ++ .../lite_small/src/config.yaml | 2 +- tools/rom_ram_analyzer/lite_small/src/misc.py | 4 -- .../lite_small/src/rom_analysis.py | 37 +++++++++++++------ 5 files changed, 37 insertions(+), 17 deletions(-) diff --git a/tools/rom_ram_analyzer/lite_small/README.md b/tools/rom_ram_analyzer/lite_small/README.md index bde298c..9b0eb18 100644 --- a/tools/rom_ram_analyzer/lite_small/README.md +++ b/tools/rom_ram_analyzer/lite_small/README.md @@ -23,6 +23,12 @@ 1. 本工具是基于gn的template进行匹配,如果新增了自定义的template,则需要相应在代码中进行配置 1. 由于本工具是进行的静态扫描,且部分gn文件中使用了较为复杂的gn语法,因此本工具的**准确率无法达到100%,结果仅供参考** +**子系统及部件的查找过程** + +1. 先查找target声明中的subsystem_name字段和part_name字段,如果查找到,则使用target声明中的作为结果 +1. 否则到get_subsystem_component.py的运行结果(默认是会保存到sub_com_info.json文件)中查找,将该结果作为最终结果 +1. 如果上述两个地方都没有查找到,则使用UNDEFINED作为子系统名和部件名进行保存 + **建议** 因为是静态扫描,因此过于复杂的gn语法会导致扫描BUILD.gn文件时无法确定其编译产物,典型的:在for循环中嵌套target声明.因此就本工具来说,不建议使用过于复杂的gn语法. @@ -58,4 +64,4 @@ ## 后续工作 -1. 部分log的输出有待优化 +1. 对target(xxx,yyy)中,xxx/yyy为变量的情况可进一步优化 diff --git a/tools/rom_ram_analyzer/lite_small/src/config.py b/tools/rom_ram_analyzer/lite_small/src/config.py index aa9b1ed..d5ba64e 100644 --- a/tools/rom_ram_analyzer/lite_small/src/config.py +++ b/tools/rom_ram_analyzer/lite_small/src/config.py @@ -2,6 +2,7 @@ import os import sys import argparse import json +import logging from typing import * import preprocess @@ -30,6 +31,7 @@ def parse_args(): return args +logging.basicConfig(level=logging.INFO) _args = parse_args() # # global variables @@ -45,6 +47,7 @@ _sc_save = _sc_json.get("save") _target_type = configs["target_type"] _sc_output_path = _sc_json.get("filename") if _recollect_sc: + logging.info("satrt scanning subsystem_name and component via get_subsystem_comonent.py") sub_com_dict: Dict = SC.run(project_path, _sc_output_path, _sc_save) else: with open(_sc_output_path, 'r', encoding='utf-8') as f: diff --git a/tools/rom_ram_analyzer/lite_small/src/config.yaml b/tools/rom_ram_analyzer/lite_small/src/config.yaml index 254c4cd..41a9ab6 100644 --- a/tools/rom_ram_analyzer/lite_small/src/config.yaml +++ b/tools/rom_ram_analyzer/lite_small/src/config.yaml @@ -144,7 +144,7 @@ black_list: - .repo - .ccache - doc - - test + # - test - build # 排除out目录,为了避免排除其他路径下的out目录,这里详细列出了out下的所有目录 - out/gen diff --git a/tools/rom_ram_analyzer/lite_small/src/misc.py b/tools/rom_ram_analyzer/lite_small/src/misc.py index 189a78f..5a6945c 100644 --- a/tools/rom_ram_analyzer/lite_small/src/misc.py +++ b/tools/rom_ram_analyzer/lite_small/src/misc.py @@ -28,8 +28,6 @@ def hap_name_handler(paragraph: Text): def target_type_handler(paragraph: Text): tt = GnVariableParser.string_parser("target_type", paragraph).strip('"') - if not tt: - logging.info("parse 'target_type' failed, maybe it's a variable") return tt @@ -220,8 +218,6 @@ def LiteLibS2MPostHandler(unit: Dict, result_dict: Dict) -> None: new_unit["description"] = "may not exist" result_dict["lite_library"][k] = new_unit else: - logging.warning( - f"target type should be 'shared_library' or 'static_library', but got '{rt}'") new_unit["real_target_type"] = "shared_library" k = LiteLibPostHandler()(new_unit) new_unit["description"] = "may not exist" diff --git a/tools/rom_ram_analyzer/lite_small/src/rom_analysis.py b/tools/rom_ram_analyzer/lite_small/src/rom_analysis.py index 3c43e99..1da365a 100644 --- a/tools/rom_ram_analyzer/lite_small/src/rom_analysis.py +++ b/tools/rom_ram_analyzer/lite_small/src/rom_analysis.py @@ -34,6 +34,7 @@ from misc import gn_lineno_collect class RomAnalysisTool: @classmethod def collect_gn_info(cls): + logging.info("start scanning BUILD.gn") with ThreadPoolExecutor(max_workers=len(collector_config) + 1) as pool: future_list: List[Future] = list() for c in collector_config: @@ -76,11 +77,11 @@ class RomAnalysisTool: dir_list.remove(t) sub_sub_dir_list = os.listdir(os.path.join(top_dir, t)) for ssdl in sub_sub_dir_list: - if os.path.join(rela_path,sub_path) != os.path.join(t,ssdl): + if os.path.join(rela_path, sub_path) != os.path.join(t, ssdl): dir_list.append(os.path.join(t, ssdl)) if not sub_sub_dir_list: return - cls._add_rest_dir(top_dir, t, sub_sub_path, dir_list) + cls._add_rest_dir(top_dir, t, sub_sub_path, dir_list) @classmethod def _find_files(cls, product_name: str) -> Dict[str, List[str]]: @@ -125,6 +126,7 @@ class RomAnalysisTool: @classmethod def collect_product_info(cls, product_name: str): + logging.info("start scanning compile products") product_dict: Dict[str, List[str]] = cls._find_files(product_name) with open(configs[product_name]["product_infofile"], 'w', encoding='utf-8') as f: json.dump(product_dict, f, indent=4) @@ -154,9 +156,10 @@ class RomAnalysisTool: rom_size_dict["size"] += size @classmethod - def _fuzzy_match(cls, file_name: str, filter_path_keyword: Tuple[str] = ("test",)) -> Tuple[str, str, str]: + def _fuzzy_match(cls, file_name: str, filter_path_keyword: Tuple[str] = tuple()) -> Tuple[str, str, str]: """ 直接grep,利用出现次数最多的BUILD.gn去定位subsystem_name和component_name""" + logging.info(f"fuzzy match: {file_name}") _, base_name = os.path.split(file_name) if base_name.startswith("lib"): base_name = base_name[3:] @@ -168,6 +171,7 @@ class RomAnalysisTool: base_name = base_name[:base_name.index(".so")] exclude_dir = configs["black_list"] tbl = [x for x in exclude_dir if os.sep in x] + def handler(content: Text) -> List[str]: t = list(filter(lambda y: len(y) > 0, list( map(lambda x: x.strip(), content.split("\n"))))) @@ -181,14 +185,16 @@ class RomAnalysisTool: include="BUILD.gn", exclude=tuple(exclude_dir), post_handler=handler) - tmp = list() - for gr in grep_result: - for item in filter_path_keyword: - if item in gr: - continue - tmp.append(gr) - grep_result = tmp + if filter_path_keyword: + tmp = list() + for gr in grep_result: + for item in filter_path_keyword: + if item in gr: + continue + tmp.append(gr) + grep_result = tmp if not grep_result: + logging.info(f"fuzzy match failed.") return str(), str(), str() gn_dict: Dict[str, int] = collections.defaultdict(int) for g in grep_result: @@ -197,11 +203,17 @@ class RomAnalysisTool: gn_file, _ = collections.Counter(gn_dict).most_common(1)[0] for k, v in sub_com_dict.items(): if gn_file.startswith(k): - return gn_file, v.get("subsystem"), v.get("component") + s = v.get("subsystem") + c = v.get("component") + logging.info( + f"fuzzy match success: subsystem_name={s}, component_name={c}") + return gn_file, s, c + logging.info(f"fuzzy match failed.") return str(), str(), str() @classmethod def _save_as_xls(cls, result_dict: Dict, product_name: str) -> None: + logging.info("saving as xls...") header = ["subsystem_name", "component_name", "output_file", "size(Byte)"] tmp_dict = copy.deepcopy(result_dict) @@ -245,9 +257,11 @@ class RomAnalysisTool: output_name: str = configs[product_name]["output_name"] output_name = output_name.replace(".json", ".xls") excel_writer.save(output_name) + logging.info("save as xls success.") @ classmethod def analysis(cls, product_name: str, product_dict: Dict[str, List[str]]): + logging.info("start analyzing...") gn_info_file = configs["gn_info_file"] with open(gn_info_file, 'r', encoding='utf-8') as f: gn_info = json.load(f) @@ -307,6 +321,7 @@ class RomAnalysisTool: with open(configs[product_name]["output_name"], 'w', encoding='utf-8') as f: json.dump(rom_size_dict, f, indent=4) cls._save_as_xls(rom_size_dict, product_name) + logging.info("success") def main(): -- Gitee From f216677964a9352b4f04a8bf8182e9e48d4d82ca Mon Sep 17 00:00:00 2001 From: aodongbiao Date: Thu, 9 Mar 2023 11:01:49 +0800 Subject: [PATCH 2/5] =?UTF-8?q?[rom=5Fram=5Fanalyzer]bugfix:=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E6=89=AB=E6=8F=8FBUILD.gn=E6=96=87=E4=BB=B6=E6=97=B6?= =?UTF-8?q?=E5=8F=AF=E8=83=BD=E5=AD=98=E5=9C=A8=E7=9A=84=E5=89=8D=E5=90=8E?= =?UTF-8?q?=E7=BC=80=E9=87=8D=E5=A4=8D=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: aodongbiao --- tools/rom_ram_analyzer/lite_small/src/misc.py | 36 ++++++++++++------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/tools/rom_ram_analyzer/lite_small/src/misc.py b/tools/rom_ram_analyzer/lite_small/src/misc.py index 5a6945c..bc079a6 100644 --- a/tools/rom_ram_analyzer/lite_small/src/misc.py +++ b/tools/rom_ram_analyzer/lite_small/src/misc.py @@ -102,6 +102,18 @@ class BasePostHandler(ABC): return self.run(unit) +def add_prefix(content: str, prefix: str) -> str: + if content and (not content.startswith(prefix)): + return prefix+content + return content + + +def add_postfix(content: str, postfix: str) -> str: + if content and (not content.endswith(postfix)): + return content+postfix + return content + + class DefaultPostHandler(BasePostHandler): def run(self, unit: Dict[str, AnyStr]): return unit["output_name"] @@ -115,7 +127,7 @@ class HAPPostHandler(BasePostHandler): extension = _config.get("default_extension").get("app") gn_hap_name = unit.get("hap_name") if gn_hap_name: - return gn_hap_name+extension + return add_postfix(gn_hap_name, extension) return unit["output_name"]+extension @@ -132,9 +144,8 @@ class SOPostHandler(BasePostHandler): extension = _config.get("default_extension").get("shared_library") if not extension.startswith('.'): extension = '.'+extension - if output_name.startswith(prefix): - return output_name+extension - return prefix+output_name+extension + output_name = add_postfix(output_name, extension) + return add_prefix(output_name, prefix) class APostHandler(BasePostHandler): @@ -147,9 +158,8 @@ class APostHandler(BasePostHandler): extension: str = _config.get("default_extension").get("static_library") if not extension.startswith('.'): extension = '.'+extension - if output_name.startswith(prefix): - return output_name+extension - return prefix+output_name+extension + output_name = add_postfix(output_name, extension) + return add_prefix(output_name, prefix) class LiteLibPostHandler(BasePostHandler): @@ -168,11 +178,10 @@ class LiteLibPostHandler(BasePostHandler): else: prefix = str() extension = str() - if not extension.startswith('.'): + if extension and (not extension.startswith('.')): extension = '.'+extension - if output_name.startswith(prefix): - return output_name+extension - return prefix+output_name+extension + output_name = add_postfix(output_name, extension) + return add_prefix(output_name, prefix) class LiteComponentPostHandler(BasePostHandler): @@ -191,9 +200,10 @@ class LiteComponentPostHandler(BasePostHandler): unit["description"] = "virtual node" prefix = str() extension = str() - if not extension.startswith('.'): + if extension and (not extension.startswith('.')): extension = '.'+extension - return prefix+output_name+extension + output_name = add_postfix(output_name, extension) + return add_prefix(output_name, prefix) class TargetPostHandler(BasePostHandler): -- Gitee From 06f35550c719e7eb8e0efc5e8eeb4c4d1d4fd2cc Mon Sep 17 00:00:00 2001 From: aodongbiao Date: Thu, 9 Mar 2023 16:47:02 +0800 Subject: [PATCH 3/5] =?UTF-8?q?[rom=5Fram=5Fanalyzer]1.=20=E5=AE=8C?= =?UTF-8?q?=E5=96=84reademe=202.=20=E6=96=B0=E5=A2=9E=E5=AF=B9mini?= =?UTF-8?q?=E4=BA=A7=E5=93=81=E7=9A=84=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: aodongbiao --- tools/rom_ram_analyzer/lite_small/README.md | 37 ++++++- .../rom_ram_analyzer/lite_small/src/config.py | 23 ++--- .../lite_small/src/config.yaml | 97 +++++++++++++------ .../lite_small/src/rom_analysis.py | 4 +- tools/rom_ram_analyzer/standard/README.md | 4 + .../rom_ram_analyzer/standard/rom_analyzer.py | 11 ++- 6 files changed, 129 insertions(+), 47 deletions(-) diff --git a/tools/rom_ram_analyzer/lite_small/README.md b/tools/rom_ram_analyzer/lite_small/README.md index 9b0eb18..b77957c 100644 --- a/tools/rom_ram_analyzer/lite_small/README.md +++ b/tools/rom_ram_analyzer/lite_small/README.md @@ -6,7 +6,12 @@ ## 支持产品 -支持产品:ipcamera_hispark_taurus ipcamera_hispark_taurus_linux wifiiot_hispark_pegasus +理论上可以支持所有产品,只要在config.yaml中进行了配置即可,目前已配置产品包括: +1. ipcamera_hispark_taurus +1. ipcamera_hispark_taurus_linux +1. wifiiot_hispark_pegasus +1. hispark_pegasus_mini_system +1. hispark_taurus_mini_system ## 代码思路 @@ -54,6 +59,36 @@ - {product_name}_result.json:各部件的rom大小分析结果 - {product_name}_result.xls:各部件的rom大小分析结果 +## 新增对产品的支持 + +*rk3568因为主要使用的是自定义的template,所以能够在编译阶段收集更多有效信息,因此建议使用standard目录下的脚本进行分析* + +在config.yaml中进行配置即可,格式说明如下: +```yaml +ipcamera_hispark_taurus: # 产品名称,需要和命令行参数中的-p参数一致 + product_infofile: ipcamera_hispark_taurus_product.json # 保存编译产物信息的json文件 + output_name: ipcamera_hispark_taurus_result.json # 保存最终结果的文件的名字 + product_dir: # [required] + root: out/hispark_taurus/ipcamera_hispark_taurus/rootfs # 待分析的编译产物的根目录 + relative: # 针对性分析的子目录,key无所谓,value应当是root的子目录. 作者通常是使用so作为动态库文件目录的key,bin作为可执行文件目录的key,a作为静态库文件目录的key + bin: bin + so: usr/lib + etc: etc + rest: True # 是否将上面root目录下除了relative指定的目录归到etc并进行匹配 + query_order: # 匹配顺序,key应当何relative字段中的key一致,value应当在上面的target_type字段中,脚本会按照配置的顺序对文件进行匹配.对于归类为etc的产品,会匹配target_type中的所有模板类型,找到即可.因此query_order中无需配置etc项. + so: + - shared_library + - ohos_shared_library + - ohos_prebuilt_shared_library + - lite_library + - lite_component + - target + bin: + - executable + - ohos_executable + - lite_component +``` + ## 新增template 主要是在config.py中配置Processor,并在config.yaml中添加相应内容 diff --git a/tools/rom_ram_analyzer/lite_small/src/config.py b/tools/rom_ram_analyzer/lite_small/src/config.py index d5ba64e..fd8af4a 100644 --- a/tools/rom_ram_analyzer/lite_small/src/config.py +++ b/tools/rom_ram_analyzer/lite_small/src/config.py @@ -47,7 +47,8 @@ _sc_save = _sc_json.get("save") _target_type = configs["target_type"] _sc_output_path = _sc_json.get("filename") if _recollect_sc: - logging.info("satrt scanning subsystem_name and component via get_subsystem_comonent.py") + logging.info( + "satrt scanning subsystem_name and component via get_subsystem_comonent.py") sub_com_dict: Dict = SC.run(project_path, _sc_output_path, _sc_save) else: with open(_sc_output_path, 'r', encoding='utf-8') as f: @@ -208,16 +209,16 @@ collector_config: Tuple[BaseProcessor] = ( unit_post_handler=LiteComponentPostHandler(), ), DefaultProcessor(project_path=project_path, - result_dict=result_dict, - target_type=_target_type[13], - match_pattern=fr"^( *){_target_type[13]}\(.*?\, .*?\)", - sub_com_dict=sub_com_dict, - target_name_parser=TargetNameParser.second_parser, - other_info_handlers={ - }, - unit_post_handler=DefaultPostHandler(), - ud_post_handler=TargetS2MPostHandler - ) + result_dict=result_dict, + target_type=_target_type[13], + match_pattern=fr"^( *){_target_type[13]}\(.*?\, .*?\)", + sub_com_dict=sub_com_dict, + target_name_parser=TargetNameParser.second_parser, + other_info_handlers={ + }, + unit_post_handler=DefaultPostHandler(), + ud_post_handler=TargetS2MPostHandler + ) ) __all__ = ["configs", "result_dict", "collector_config", "sub_com_dict"] diff --git a/tools/rom_ram_analyzer/lite_small/src/config.yaml b/tools/rom_ram_analyzer/lite_small/src/config.yaml index 41a9ab6..17f5568 100644 --- a/tools/rom_ram_analyzer/lite_small/src/config.yaml +++ b/tools/rom_ram_analyzer/lite_small/src/config.yaml @@ -35,6 +35,33 @@ subsystem_component: filename: sub_com_info.json gn_info_file: gn_info.json +# extension and prefix of products +default_extension: + shared_library: .so + static_library: .a + app: .hap + +default_prefix: + shared_library: lib + static_library: lib +# black list for command 'grep', it should be the subdirectory of the root path of oh +black_list: + - .repo + - .ccache + - doc + # - test + - build + # 排除out目录,为了避免排除其他路径下的out目录,这里详细列出了out下的所有目录 + - out/gen + - out/hispark_pegasus + - out/hispark_taurus + - out/kernel + - out/preloader + - out/rk3568 + # 如果发现了跨形态的错误,如:检查A形态,但是发现将A形态的产品归属到B形态下了,则也可以将B形态的对应路径加在这里进行过滤 + +# product configuration + ipcamera_hispark_taurus: product_infofile: ipcamera_hispark_taurus_product.json # 编译产物的信息 output_name: ipcamera_hispark_taurus_result.json # 输出文件的名字 @@ -44,8 +71,8 @@ ipcamera_hispark_taurus: bin: bin so: usr/lib etc: etc - rest: True # 是否分析其他目录下的并归到etc(copy的文件) - query_order: + rest: True # 是否将上面root目录下除了relative指定的目录归到etc并进行匹配 + query_order: # 匹配顺序,key应当何relative字段中的key一致,value应当在上面的target_type字段中 so: - shared_library - ohos_shared_library @@ -83,7 +110,30 @@ ipcamera_hispark_taurus_linux: - executable - ohos_executable - lite_component + +hispark_taurus_mini_system: + product_infofile: hispark_taurus_mini_system_product.json + output_name: hispark_taurus_mini_system_result.json + product_dir: + root: out/hispark_taurus/hispark_taurus_mini_system/rootfs + relative: + bin: bin + so: usr/lib + etc: etc + rest: True + query_order: + so: + - shared_library + - ohos_shared_library + - ohos_prebuilt_shared_library + - lite_library + - lite_component + - target + bin: + - executable + - ohos_executable + - lite_component wifiiot_hispark_pegasus: product_infofile: wifiiot_hispark_pegasus_product.json @@ -100,9 +150,24 @@ wifiiot_hispark_pegasus: - ohos_static_library - lite_library - target - -rk3568: # rk的目前从packages/phone/system_module_info.json中分析准确度更高,因为rk基本都使用的是ohos_xxx,而L0和L1的更多的是使用的gn原生target template +hispark_pegasus_mini_system: + product_infofile: hispark_pegasus_mini_system_product.json + output_name: hispark_pegasus_mini_system_result.json + product_dir: + root: out/hispark_pegasus/hispark_pegasus_mini_system + relative: + a: libs + etc: etc + rest: False + query_order: + a: + - static_library + - ohos_static_library + - lite_library + - target + +rk3568: # rk的目前从packages/phone/system_module_info.json中分析准确度更高,因为rk基本都使用的是ohos_xxx,而lite/small的更多的是使用的gn原生target template product_infofile: rk3568_product.json output_name: rk3568_result.json product_dir: @@ -130,27 +195,3 @@ rk3568: # rk的目前从packages/phone/system_module_info.json中分析准确度 hap: - ohos_hap -# extension and prefix of products -default_extension: - shared_library: .so - static_library: .a - app: .hap - -default_prefix: - shared_library: lib - static_library: lib -# black list for command 'grep', it should be the subdirectory of the root path of oh -black_list: - - .repo - - .ccache - - doc - # - test - - build - # 排除out目录,为了避免排除其他路径下的out目录,这里详细列出了out下的所有目录 - - out/gen - - out/hispark_pegasus - - out/hispark_taurus - - out/kernel - - out/preloader - - out/rk3568 - # 如果发现了跨形态的错误,如:检查A形态,但是发现将A形态的产品归属到B形态下了,则也可以将B形态的对应路径加在这里进行过滤 diff --git a/tools/rom_ram_analyzer/lite_small/src/rom_analysis.py b/tools/rom_ram_analyzer/lite_small/src/rom_analysis.py index 1da365a..e8e7b97 100644 --- a/tools/rom_ram_analyzer/lite_small/src/rom_analysis.py +++ b/tools/rom_ram_analyzer/lite_small/src/rom_analysis.py @@ -267,9 +267,9 @@ class RomAnalysisTool: gn_info = json.load(f) query_order: Dict[str, List[str] ] = configs[product_name]["query_order"] - query_order["etc"] = configs["target_type"] + query_order["etc"] = configs["target_type"] # etc会查找所有的template rom_size_dict: Dict = dict() - # prodcut_dict: {"so":["a.so", ...]} + # prodcut_dict: {"so":["a.so", ...], "etc":["b.txt",...]} for t, l in product_dict.items(): for f in l: # 遍历所有文件 if os.path.isdir(f): diff --git a/tools/rom_ram_analyzer/standard/README.md b/tools/rom_ram_analyzer/standard/README.md index 69c6b52..6a11151 100644 --- a/tools/rom_ram_analyzer/standard/README.md +++ b/tools/rom_ram_analyzer/standard/README.md @@ -8,6 +8,10 @@ 结果以json与xls格式进行存储,其中,json格式是必输出的,xls格式需要-e参数控制。 +## 支持产品 + +主要是rk3568系列,已测试产品包括rk3568 rk3568_mini_system + ## 使用说明 前置条件: diff --git a/tools/rom_ram_analyzer/standard/rom_analyzer.py b/tools/rom_ram_analyzer/standard/rom_analyzer.py index b4f337d..30085ab 100644 --- a/tools/rom_ram_analyzer/standard/rom_analyzer.py +++ b/tools/rom_ram_analyzer/standard/rom_analyzer.py @@ -12,6 +12,8 @@ from pkgs.simple_excel_writer import SimpleExcelWriter debug = bool(sys.gettrace()) +NOTFOUND = "NOTFOUND" + class RomAnalyzer: @classmethod @@ -105,18 +107,18 @@ class RomAnalyzer: } } """ - component_name = "others" if unit.get( + component_name = NOTFOUND if unit.get( "component_name") is None else unit.get("component_name") - subsystem_name = "others" if unit.get( + subsystem_name = NOTFOUND if unit.get( "subsystem_name") is None else unit.get("subsystem_name") size = unit.get("size") relative_filepath = unit.get("relative_filepath") - if result_dict.get(subsystem_name) is None: # 子系统 + if result_dict.get(subsystem_name) is None: # 子系统 result_dict[subsystem_name] = dict() result_dict[subsystem_name]["size"] = 0 result_dict[subsystem_name]["file_count"] = 0 - if result_dict.get(subsystem_name).get(component_name) is None: # 部件 + if result_dict.get(subsystem_name).get(component_name) is None: # 部件 result_dict[subsystem_name][component_name] = dict() result_dict[subsystem_name][component_name]["size"] = 0 result_dict[subsystem_name][component_name]["file_count"] = 0 @@ -126,7 +128,6 @@ class RomAnalyzer: result_dict[subsystem_name][component_name]["file_count"] += 1 result_dict[subsystem_name][component_name][relative_filepath] = size - @classmethod def analysis(cls, system_module_info_json: Text, product_dirs: List[str], project_path: Text, product_name: Text, output_file: Text, output_execel: bool): -- Gitee From 87b14d5243c8c2fb2d685c3b7124e8c25658da73 Mon Sep 17 00:00:00 2001 From: aodongbiao Date: Thu, 9 Mar 2023 16:53:19 +0800 Subject: [PATCH 4/5] =?UTF-8?q?[rom=5Fram=5Fanalyzer]=E5=AE=8C=E5=96=84rea?= =?UTF-8?q?ddme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: aodongbiao --- tools/rom_ram_analyzer/lite_small/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/rom_ram_analyzer/lite_small/README.md b/tools/rom_ram_analyzer/lite_small/README.md index b77957c..d38c8f8 100644 --- a/tools/rom_ram_analyzer/lite_small/README.md +++ b/tools/rom_ram_analyzer/lite_small/README.md @@ -91,7 +91,7 @@ ipcamera_hispark_taurus: # 产品名称,需要和命令行参数中的-p参数 ## 新增template -主要是在config.py中配置Processor,并在config.yaml中添加相应内容 +为了提高准确率,本工具是按照gn的template类型对BUILD.gn进行扫描,因此如果BUILD.gn中新增了template,需要在代码层数进行相应的更改.主要是在config.py中配置Processor,并在config.yaml中添加相应内容 ## 如何提高准确率 -- Gitee From 8f727b061ab98a11fd9a305fc5c59cd21c593e36 Mon Sep 17 00:00:00 2001 From: aodongbiao Date: Thu, 9 Mar 2023 18:45:06 +0800 Subject: [PATCH 5/5] =?UTF-8?q?[rom=5Fram=5Fanalyzer]=E8=A7=A3=E5=86=B3?= =?UTF-8?q?=E5=91=8A=E8=AD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: aodongbiao --- tools/rom_ram_analyzer/lite_small/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/rom_ram_analyzer/lite_small/README.md b/tools/rom_ram_analyzer/lite_small/README.md index d38c8f8..859aac6 100644 --- a/tools/rom_ram_analyzer/lite_small/README.md +++ b/tools/rom_ram_analyzer/lite_small/README.md @@ -31,7 +31,7 @@ **子系统及部件的查找过程** 1. 先查找target声明中的subsystem_name字段和part_name字段,如果查找到,则使用target声明中的作为结果 -1. 否则到get_subsystem_component.py的运行结果(默认是会保存到sub_com_info.json文件)中查找,将该结果作为最终结果 +1. 否则到get_subsystem_component.py的运行结果(默认是会保存到sub_com_info.json文件)中查找 1. 如果上述两个地方都没有查找到,则使用UNDEFINED作为子系统名和部件名进行保存 **建议** @@ -67,7 +67,7 @@ ```yaml ipcamera_hispark_taurus: # 产品名称,需要和命令行参数中的-p参数一致 product_infofile: ipcamera_hispark_taurus_product.json # 保存编译产物信息的json文件 - output_name: ipcamera_hispark_taurus_result.json # 保存最终结果的文件的名字 + output_name: ipcamera_hispark_taurus_result.json # 保存结果的文件的名字 product_dir: # [required] root: out/hispark_taurus/ipcamera_hispark_taurus/rootfs # 待分析的编译产物的根目录 relative: # 针对性分析的子目录,key无所谓,value应当是root的子目录. 作者通常是使用so作为动态库文件目录的key,bin作为可执行文件目录的key,a作为静态库文件目录的key -- Gitee