From a3fde5908abf0ff8d0f9a7b4da88de8890837952 Mon Sep 17 00:00:00 2001 From: kangchongtao Date: Tue, 12 Aug 2025 11:32:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0arkui=20=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E5=A4=B4=E6=96=87=E4=BB=B6=E4=BD=BF=E7=94=A8=E4=B8=AA=E6=95=B0?= =?UTF-8?q?=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: kangchongtao Change-Id: I91ea0ec291d09ff82bda68a525e9c621e3972eee Signed-off-by: kangchongtao --- tools/arkui_tools/arkui_hfile_counts.py | 54 +++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 tools/arkui_tools/arkui_hfile_counts.py diff --git a/tools/arkui_tools/arkui_hfile_counts.py b/tools/arkui_tools/arkui_hfile_counts.py new file mode 100644 index 0000000..e8765d4 --- /dev/null +++ b/tools/arkui_tools/arkui_hfile_counts.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python3 +import subprocess +import re +from collections import defaultdict + +def run_ninja_command(): + try: + # Execute the ninja command + cmd = '../../prebuilts/build-tools/linux-x86/bin/ninja -w dupbuild=warn -t deps > ninja_deps.txt' + subprocess.run(cmd, shell=True, check=True) + print("Successfully generated ninja_deps.txt") + except subprocess.CalledProcessError as e: + print(f"Error running ninja command: {e}") + exit(1) + +def analyze_deps_file(): + pattern = re.compile(r'.*\.h$') # Match .h files + keywords = ['arkui/ace_engine', 'arkui/framework/core'] + count_dict = defaultdict(int) + + try: + with open('ninja_deps.txt', 'r') as f: + for line in f: + line = line.strip() + if pattern.search(line): + if any(keyword in line for keyword in keywords): + count_dict[line] += 1 + except FileNotFoundError: + print("Error: ninja_deps.txt not found") + exit(1) + + return count_dict + +def write_results(count_dict, output_file='arkui_hfile_counts.txt'): + with open(output_file, 'w') as f: + for filename, count in sorted(count_dict.items(), key=lambda x: x[1], reverse=True): + f.write(f"{filename}: {count}\n") + print(f"Results written to {output_file}") + +def main(): + # Step 1: Run the ninja command + run_ninja_command() + + # Step 2: Analyze the generated file + counts = analyze_deps_file() + + # Step 3: Write results to output file + write_results(counts) + + # Print summary + print(f"Found {len(counts)} matching .h files") + +if __name__ == "__main__": + main() \ No newline at end of file -- Gitee