diff --git a/tools/rom_ram_analyzer/lite_small/__init__.py b/tools/rom_ram_analyzer/lite_small/__init__.py index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..dba10663d6002d939e496189e557bcbc8d2cc385 100644 --- a/tools/rom_ram_analyzer/lite_small/__init__.py +++ b/tools/rom_ram_analyzer/lite_small/__init__.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This file is only for indication this folder is a python package. \ No newline at end of file diff --git a/tools/rom_ram_analyzer/lite_small/pkgs/__init__.py b/tools/rom_ram_analyzer/lite_small/pkgs/__init__.py index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..583ec11ef1ce6d5887efb49e650bed0da67dbe94 100644 --- a/tools/rom_ram_analyzer/lite_small/pkgs/__init__.py +++ b/tools/rom_ram_analyzer/lite_small/pkgs/__init__.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This file only indicates that the directory it resides is a python package \ No newline at end of file diff --git a/tools/rom_ram_analyzer/lite_small/pkgs/basic_tool.py b/tools/rom_ram_analyzer/lite_small/pkgs/basic_tool.py index b04afab5ba43bf6ab2f8468345d4011aa9d6a163..512ed597072bdb0476d7bac3e065f480f567dfbe 100644 --- a/tools/rom_ram_analyzer/lite_small/pkgs/basic_tool.py +++ b/tools/rom_ram_analyzer/lite_small/pkgs/basic_tool.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Copyright (c) 2022 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/tools/rom_ram_analyzer/lite_small/pkgs/gn_common_tool.py b/tools/rom_ram_analyzer/lite_small/pkgs/gn_common_tool.py index 66ebb212c3068dff707d410d84543dec23e0bdd6..d12eb4b68b2a4959faa2d2d4aa3cca2520a50943 100644 --- a/tools/rom_ram_analyzer/lite_small/pkgs/gn_common_tool.py +++ b/tools/rom_ram_analyzer/lite_small/pkgs/gn_common_tool.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Copyright (c) 2022 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); @@ -11,8 +12,8 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -# +# This file contains some Classes for gn's BUILD.gn import os import logging diff --git a/tools/rom_ram_analyzer/lite_small/pkgs/simple_excel_writer.py b/tools/rom_ram_analyzer/lite_small/pkgs/simple_excel_writer.py index 94a9496fc81cb6bf2ca7de759f4d13eddb19c1a7..da6f3c6e1b9a1ce513e8a8867614c4acc9a2ec92 100644 --- a/tools/rom_ram_analyzer/lite_small/pkgs/simple_excel_writer.py +++ b/tools/rom_ram_analyzer/lite_small/pkgs/simple_excel_writer.py @@ -1,3 +1,21 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This file contains a SimpleExcelWriter, which is a implemented based on xlwt for easy use. + + import xlwt from xlwt import Worksheet, Pattern as PTRN, Alignment as ALGT, Font as FT, XFStyle as XFSL import typing diff --git a/tools/rom_ram_analyzer/lite_small/pkgs/simple_yaml_tool.py b/tools/rom_ram_analyzer/lite_small/pkgs/simple_yaml_tool.py index 5edf61253bde45592ec8017e08e1fd2d0a1d0bec..32cb530bc6026ed2c44a9662170fb378dcb15cf2 100644 --- a/tools/rom_ram_analyzer/lite_small/pkgs/simple_yaml_tool.py +++ b/tools/rom_ram_analyzer/lite_small/pkgs/simple_yaml_tool.py @@ -1,3 +1,20 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This file contains a SimpleYamlTool, which is a implemented based on the package named yaml for easy use. + import yaml from typing import * from yaml.loader import SafeLoader diff --git a/tools/rom_ram_analyzer/lite_small/src/__init__.py b/tools/rom_ram_analyzer/lite_small/src/__init__.py index 341988ca1a71b67e2a0026761e587dc5e9afb919..aafe597613969e63776ad0916750e70381e11c6e 100644 --- a/tools/rom_ram_analyzer/lite_small/src/__init__.py +++ b/tools/rom_ram_analyzer/lite_small/src/__init__.py @@ -1 +1,18 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This file only indicates that the directory it resides is a python package + VERSION = 1.0 diff --git a/tools/rom_ram_analyzer/lite_small/src/config.py b/tools/rom_ram_analyzer/lite_small/src/config.py index fd8af4a4ecade080be6fb2890ba223b01e85c35b..a557af603fa1d3cc3fe226734cfd12bb30bfbf7b 100644 --- a/tools/rom_ram_analyzer/lite_small/src/config.py +++ b/tools/rom_ram_analyzer/lite_small/src/config.py @@ -1,3 +1,22 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This file is a configuration for scaning the BUILD.gn to collection compile +# products. + + import os import sys import argparse diff --git a/tools/rom_ram_analyzer/lite_small/src/config.yaml b/tools/rom_ram_analyzer/lite_small/src/config.yaml index 17f5568fb9a3b3d09b06f3739327ff7c51b36738..f3394b2bc210a5392e27ec0fd0cc0c805c82d9a0 100644 --- a/tools/rom_ram_analyzer/lite_small/src/config.yaml +++ b/tools/rom_ram_analyzer/lite_small/src/config.yaml @@ -167,9 +167,9 @@ hispark_pegasus_mini_system: - 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 +rk3568_mini_system: # rk的目前从packages/phone/system_module_info.json中分析准确度更高,因为rk基本都使用的是ohos_xxx,而lite/small的更多的是使用的gn原生target template + product_infofile: rk3568_mini_system_product.json + output_name: rk3568_mini_system_result.json product_dir: root: out/rk3568/packages/phone/system relative: diff --git a/tools/rom_ram_analyzer/lite_small/src/get_subsystem_component.py b/tools/rom_ram_analyzer/lite_small/src/get_subsystem_component.py index 3ed38473a4da4b46c15bc8526f823722ff47ec60..2dbd476722d5b6360650840a19e67e196a472c8e 100644 --- a/tools/rom_ram_analyzer/lite_small/src/get_subsystem_component.py +++ b/tools/rom_ram_analyzer/lite_small/src/get_subsystem_component.py @@ -1,4 +1,20 @@ -#! /usr/bin/python +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This file is for get the mapping relationship of subsystem_name/component_name +# and their directory. The code is from Yude Chen. import argparse import os @@ -25,7 +41,7 @@ def get_subsystem_components(ohos_path: str): if not os.path.exists(subsystem_path): g_subsystem_path_error.append(subsystem_path) continue - cmd = 'find ' + subsystem_path + ' -name bundle.json' + cmd = 'find {} -name bundle.json'.format(subsystem_path) bundle_json_list = os.popen(cmd).readlines() # get components component_list = [] @@ -41,7 +57,7 @@ def get_subsystem_components(ohos_path: str): g_component_abs_path.append(destpath) else: component_item[bundle_json["component"]["name"] - ] = "Unknow. Please check " + bundle_path + ] = "Unknow. Please check {}".format(bundle_path) g_component_path_empty.append(bundle_path) component_list.append(component_item) subsystem_item[subsystem_name] = component_list @@ -65,7 +81,7 @@ def export_to_json(subsystem_item: dict, output_filename: str): subsystem_item, indent=4, separators=(', ', ': ')) with open(output_filename, 'w') as f: f.write(subsystem_item_json) - logging.info("output path: " + output_filename) + logging.info("output path: {}".format(output_filename)) def parse_args(): @@ -77,7 +93,7 @@ def parse_args(): ohos_path = os.path.abspath(args.project) if not is_project(ohos_path): - logging.error("'" + ohos_path + "' is not a valid project path.") + logging.error("'{}' is not a valid project path.".format(ohos_path)) exit(1) output_path = r'.' @@ -93,7 +109,7 @@ def is_project(path: str) -> bool: @note: 通过是否含有 .repo/manifests 目录粗略判断。 ''' p = os.path.normpath(path) - return os.path.exists(p + '/.repo/manifests') + return os.path.exists('{}/.repo/manifests'.format(p)) def print_warning_info(): @@ -126,6 +142,7 @@ __all__ = ["SC"] if __name__ == '__main__': ohos_path, output_path = parse_args() - info = get_subsystem_components_modified(ohos_path) - export_to_json(info, output_path) - print_warning_info() + # info = get_subsystem_components_modified(ohos_path) + # export_to_json(info, output_path) + # print_warning_info() + SC.run(ohos_path, output_path) diff --git a/tools/rom_ram_analyzer/lite_small/src/misc.py b/tools/rom_ram_analyzer/lite_small/src/misc.py index bc079a6cce32ae54cdf4428c93311c9a37c11892..79af85b24908635072d1c8dd9cf9cfd0d933a2de 100644 --- a/tools/rom_ram_analyzer/lite_small/src/misc.py +++ b/tools/rom_ram_analyzer/lite_small/src/misc.py @@ -1,3 +1,21 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This file is for get the mapping relationship of subsystem_name/component_name +# and their directory. The code is from Yude Chen. + import logging import copy import os diff --git a/tools/rom_ram_analyzer/lite_small/src/preprocess.py b/tools/rom_ram_analyzer/lite_small/src/preprocess.py index 19b9ae9b7dac22c0490e5ff2014593ab7f4041c9..6f8ce5e287cc42292e4a0daf6a0392687f834f1b 100644 --- a/tools/rom_ram_analyzer/lite_small/src/preprocess.py +++ b/tools/rom_ram_analyzer/lite_small/src/preprocess.py @@ -1,3 +1,20 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This file is writting for do some preprocess work + import sys import os # 将上级目录加入到库的搜索路径 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 e8e7b972b16e9009adbdcd61b216cf6a9410f2fc..e9255398266c667e124ad3e9a604b02dcf360a8e 100644 --- a/tools/rom_ram_analyzer/lite_small/src/rom_analysis.py +++ b/tools/rom_ram_analyzer/lite_small/src/rom_analysis.py @@ -1,3 +1,20 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This file is for rom analyzation of lite/small devices. + import sys import argparse import json diff --git a/tools/rom_ram_analyzer/lite_small/src/template_processor.py b/tools/rom_ram_analyzer/lite_small/src/template_processor.py index 8e3a9e4ce1ad28fb6f73656418adaaf786dab645..64d19a479026cee67490d21c976d7d6ad75c5d16 100644 --- a/tools/rom_ram_analyzer/lite_small/src/template_processor.py +++ b/tools/rom_ram_analyzer/lite_small/src/template_processor.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Copyright (c) 2022 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); @@ -11,7 +12,9 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -# + +# This file contains some template processor to collection information +# from some gn's template in BUILD.gn from typing import * from abc import ABC, abstractmethod diff --git a/tools/rom_ram_analyzer/standard/__init__.py b/tools/rom_ram_analyzer/standard/__init__.py index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..dba10663d6002d939e496189e557bcbc8d2cc385 100644 --- a/tools/rom_ram_analyzer/standard/__init__.py +++ b/tools/rom_ram_analyzer/standard/__init__.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This file is only for indication this folder is a python package. \ No newline at end of file diff --git a/tools/rom_ram_analyzer/standard/ram_analyzer.py b/tools/rom_ram_analyzer/standard/ram_analyzer.py index c3863af14f5b04f55a4e108fd1ad6c445bd097da..a68d77f4a4e5d9957404f0dc3d9d173a0aff9b1e 100644 --- a/tools/rom_ram_analyzer/standard/ram_analyzer.py +++ b/tools/rom_ram_analyzer/standard/ram_analyzer.py @@ -1,3 +1,21 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This file is to implement the rom analyzation of standard device. +# + import argparse import copy import glob diff --git a/tools/rom_ram_analyzer/standard/rom_analyzer.py b/tools/rom_ram_analyzer/standard/rom_analyzer.py index 30085ab740e3d02c1e92d273a6a1a8ef71bf94b0..35504fa7879d5fa989c8f6b367d7555da45d44c1 100644 --- a/tools/rom_ram_analyzer/standard/rom_analyzer.py +++ b/tools/rom_ram_analyzer/standard/rom_analyzer.py @@ -1,3 +1,20 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This file contains a RomAnalyzer for rom analyzation of standard device. + import argparse import json import os