This repository was archived by the owner on Jul 23, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathanalyze_coverage.py
More file actions
127 lines (102 loc) · 3.98 KB
/
analyze_coverage.py
File metadata and controls
127 lines (102 loc) · 3.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/usr/bin/env python3
# Copyright (C) 2025 UnionTech Software Technology Co., Ltd.
# SPDX-License-Identifier: Apache-2.0 OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
import os
import glob
def normalize_name(name):
"""标准化名称,处理下划线"""
return name.replace('_', '')
def get_qwlroots_wrapped():
"""获取qwlroots已封装的类型"""
wrapped = {}
# types目录
types_files = glob.glob("src/types/qw*.h")
wrapped['types'] = set()
for f in types_files:
name = os.path.basename(f).removeprefix('qw').removesuffix('.h') # 去掉qw前缀和.h后缀
wrapped['types'].add(normalize_name(name))
# util目录
util_files = glob.glob("src/util/qw*.h")
wrapped['util'] = set()
for f in util_files:
name = os.path.basename(f).removeprefix('qw').removesuffix('.h')
wrapped['util'].add(normalize_name(name))
# render目录
render_files = glob.glob("src/render/qw*.h")
wrapped['render'] = set()
for f in render_files:
name = os.path.basename(f).removeprefix('qw').removesuffix('.h')
wrapped['render'].add(normalize_name(name))
# interfaces目录
interface_files = glob.glob("src/interfaces/qw*.h")
wrapped['interfaces'] = set()
for f in interface_files:
name = os.path.basename(f).removeprefix('qw').removesuffix('.h')
wrapped['interfaces'].add(normalize_name(name))
return wrapped
def get_wlroots_available():
"""获取wlroots可用的类型"""
available = {}
# types目录
types_files = glob.glob("wlroots/include/wlr/types/wlr_*.h")
available['types'] = set()
for f in types_files:
name = os.path.basename(f)[4:-2] # 去掉wlr_前缀和.h后缀
available['types'].add(normalize_name(name))
# util目录
util_files = glob.glob("wlroots/include/wlr/util/*.h")
available['util'] = set()
for f in util_files:
name = os.path.basename(f)[:-2]
available['util'].add(normalize_name(name))
# render目录
render_files = glob.glob("wlroots/include/wlr/render/*.h")
available['render'] = set()
for f in render_files:
name = os.path.basename(f)[:-2]
if name.startswith('wlr_'):
name = name[4:] # 去掉wlr_前缀
available['render'].add(normalize_name(name))
# interfaces目录
interface_files = glob.glob("wlroots/include/wlr/interfaces/*.h")
available['interfaces'] = set()
for f in interface_files:
name = os.path.basename(f)[:-2]
if name.startswith('wlr_'):
name = name[4:] # 去掉wlr_前缀
available['interfaces'].add(normalize_name(name))
return available
def analyze_coverage():
wrapped = get_qwlroots_wrapped()
available = get_wlroots_available()
print("# qwlroots 封装覆盖率分析 (基于 wlroots 0.19.0)")
print()
total_wrapped = 0
total_available = 0
for category in ['types', 'util', 'render', 'interfaces']:
wrapped_set = wrapped.get(category, set())
available_set = available.get(category, set())
missing = available_set - wrapped_set
print(f"## {category.title()} 目录")
print(f"- 已封装: {len(wrapped_set)}")
print(f"- 可用总数: {len(available_set)}")
if len(available_set) > 0:
print(f"- 覆盖率: {len(wrapped_set)/len(available_set)*100:.1f}%")
else:
print(f"- 覆盖率: N/A")
if missing:
print(f"- 未封装的类型:")
for item in sorted(missing):
print(f" - {item}")
else:
print("- ✅ 所有类型都已封装")
print()
total_wrapped += len(wrapped_set)
total_available += len(available_set)
print(f"## 总体覆盖率")
print(f"- 总已封装: {total_wrapped}")
print(f"- 总可用: {total_available}")
if total_available > 0:
print(f"- 总覆盖率: {total_wrapped/total_available*100:.1f}%")
if __name__ == "__main__":
analyze_coverage()