mirror of
https://github.com/openharmony/developtools_integration_verification.git
synced 2026-07-25 14:15:39 -04:00
修改project_path获取方式,通过命令行传入
Signed-off-by: aodongbiao <aodongbiao@huawei.com>
This commit is contained in:
@@ -19,10 +19,18 @@
|
||||
|
||||
## 使用
|
||||
|
||||
1. 修改config.yaml
|
||||
- project_path:oh项目根路径
|
||||
- output_file:保存结果的文件的名字[optional]
|
||||
2. `python3 rom_analysis.py --product_name {your_product_name} [--recollect_gn bool]`运行代码,其中recollect_gn表示是需要重新扫描BUILD.gn还是直接使用已有结果.eg: `python3 rom_analysis.py --product_name ipcamera_hispark_taurus`
|
||||
前置条件:
|
||||
|
||||
1. 获取整个rom_ram_analyzer目录
|
||||
1. 对系统进行编译
|
||||
1. linux平台
|
||||
1. python3.8及以后
|
||||
1. 安装requirements
|
||||
```txt
|
||||
xlwt==1.3.0
|
||||
```
|
||||
|
||||
1. `python3 rom_analysis.py --product_name {your_product_name} --oh_path {root_path_of_oh} [--recollect_gn bool]`运行代码,其中recollect_gn表示是需要重新扫描BUILD.gn还是直接使用已有结果.eg: `python3 rom_analysis.py --product_name ipcamera_hispark_taurus`
|
||||
3. 运行完毕会产生4个json文件及一个xls文件,如果是默认配置,各文件描述如下:
|
||||
- gn_info.json:BUILD.gn的分析结果
|
||||
- sub_com_info.json:从bundle.json中进行分析获得的各部件及其对应根目录的信息
|
||||
|
||||
@@ -17,11 +17,29 @@ from info_handlers import extension_handler, hap_name_handler, target_type_handl
|
||||
只给rom_analysis.py使用
|
||||
"""
|
||||
|
||||
def parse_args():
|
||||
parser = argparse.ArgumentParser(
|
||||
description="analysis rom size of L0 and L1 product")
|
||||
parser.add_argument("-p", "--product_name", type=str, default="ipcamera_hispark_taurus_linux",
|
||||
help="product name. eg: -p ipcamera_hispark_taurus")
|
||||
parser.add_argument("-o", "--oh_path", type=str,
|
||||
default=".", help="root path of openharmony")
|
||||
parser.add_argument("-r", "--recollect_gn", type=bool,
|
||||
default=True, help="if recollect gn info or not")
|
||||
args = parser.parse_args()
|
||||
return args
|
||||
|
||||
|
||||
_args = parse_args()
|
||||
|
||||
# # global variables
|
||||
configs = SimpleYamlTool.read_yaml("config.yaml")
|
||||
result_dict: Dict[str, Any] = dict()
|
||||
|
||||
project_path = BasicTool.abspath(configs.get("project_path"))
|
||||
# project_path = BasicTool.abspath(configs.get("project_path"))
|
||||
project_path = _args.oh_path
|
||||
product_name = _args.product_name
|
||||
recollect_gn = _args.recollect_gn
|
||||
_sc_json: Dict[Text, Text] = configs.get("subsystem_component_json")
|
||||
_sc_save = _sc_json.get("save")
|
||||
_target_type = configs["target_type"]
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
# limitations under the License.
|
||||
|
||||
# root:
|
||||
project_path: ~/oh
|
||||
# project_path: ~/oh
|
||||
# 从bundle.json中取出的component和subsystem_name的信息
|
||||
# used by get_subsystem_component.py config.py
|
||||
subsystem_component_json:
|
||||
|
||||
@@ -5,10 +5,6 @@ import preprocess
|
||||
from pkgs.basic_tool import BasicTool
|
||||
from pkgs.simple_yaml_tool import SimpleYamlTool
|
||||
|
||||
config = SimpleYamlTool.read_yaml("config.yaml")
|
||||
project_path = config.get("project_path")
|
||||
black_list = map(lambda x: os.path.join(
|
||||
project_path, x), config.get("black_list"))
|
||||
|
||||
def gn_lineno_collect(match_pattern: str, project_path: str) -> DefaultDict[str, List[int]]:
|
||||
"""
|
||||
@@ -17,6 +13,10 @@ def gn_lineno_collect(match_pattern: str, project_path: str) -> DefaultDict[str,
|
||||
:param project_path: 项目路径(搜索路径)
|
||||
:return: {gn_file: [line_no_1, line_no_2, ..]}
|
||||
"""
|
||||
config = SimpleYamlTool.read_yaml("config.yaml")
|
||||
# project_path = config.get("project_path")
|
||||
black_list = map(lambda x: os.path.join(
|
||||
project_path, x), config.get("black_list"))
|
||||
|
||||
def handler(content: Text) -> List[str]:
|
||||
return list(filter(lambda y: len(y) > 0, list(map(lambda x: x.strip(), content.split("\n")))))
|
||||
|
||||
@@ -15,5 +15,5 @@ def hap_name_handler(paragraph: Text):
|
||||
def target_type_handler(paragraph: Text):
|
||||
tt = GnVariableParser.string_parser("target_type", paragraph).strip('"')
|
||||
if not tt:
|
||||
logging.warning("parse 'target_type' failed, maybe it's a variable")
|
||||
logging.info("parse 'target_type' failed, maybe it's a variable")
|
||||
return tt
|
||||
|
||||
@@ -13,7 +13,7 @@ from threading import RLock
|
||||
import collections
|
||||
|
||||
from gn_lineno_collector import gn_lineno_collect
|
||||
from config import result_dict, collector_config, configs, project_path, sub_com_dict
|
||||
from config import result_dict, collector_config, configs, project_path, sub_com_dict, product_name, recollect_gn
|
||||
# from gn_info_collect import GnInfoCollector
|
||||
from pkgs.basic_tool import BasicTool
|
||||
from pkgs.gn_common_tool import GnCommonTool
|
||||
@@ -31,15 +31,15 @@ from pkgs.simple_excel_writer import SimpleExcelWriter
|
||||
"""
|
||||
|
||||
|
||||
def parse_args():
|
||||
parser = argparse.ArgumentParser(
|
||||
description="analysis rom size of L0 and L1 product")
|
||||
parser.add_argument("-p", "--product_name", type=str, default="ipcamera_hispark_taurus_linux",
|
||||
help="product name. eg: -p ipcamera_hispark_taurus")
|
||||
parser.add_argument("-r", "--recollect_gn", type=bool,
|
||||
default=True, help="if recollect gn info or not")
|
||||
args = parser.parse_args()
|
||||
return args
|
||||
# def parse_args():
|
||||
# parser = argparse.ArgumentParser(
|
||||
# description="analysis rom size of L0 and L1 product")
|
||||
# parser.add_argument("-p", "--product_name", type=str, default="ipcamera_hispark_taurus_linux",
|
||||
# help="product name. eg: -p ipcamera_hispark_taurus")
|
||||
# parser.add_argument("-r", "--recollect_gn", type=bool,
|
||||
# default=True, help="if recollect gn info or not")
|
||||
# args = parser.parse_args()
|
||||
# return args
|
||||
|
||||
|
||||
class RomAnalysisTool:
|
||||
@@ -270,10 +270,7 @@ class RomAnalysisTool:
|
||||
|
||||
|
||||
def main():
|
||||
args = parse_args()
|
||||
product_name = args.product_name
|
||||
re_collect_gn_info = args.recollect_gn
|
||||
if re_collect_gn_info:
|
||||
if recollect_gn:
|
||||
RomAnalysisTool.collect_gn_info()
|
||||
product_dict: Dict[str, List[str]
|
||||
] = RomAnalysisTool.collect_product_info(product_name)
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
1. 获取整个rom_ram_analyzer目录
|
||||
1. 对系统进行编译
|
||||
1. linux平台
|
||||
1. rom分析在linux平台,ram分析在windows平台
|
||||
1. python3.8及以后
|
||||
1. 安装requirements
|
||||
```txt
|
||||
|
||||
Reference in New Issue
Block a user