Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
emscripten-core
GitHub Repository: emscripten-core/emscripten
Path: blob/main/tools/maint/check_struct_info.py
4150 views
1
#!/usr/bin/env python3
2
3
"""Find entries in struct_info.json that are not needd by
4
any JS library code and can be removed."""
5
6
import json
7
import os
8
import sys
9
import subprocess
10
11
script_dir = os.path.dirname(os.path.abspath(__file__))
12
root_dir = os.path.dirname(os.path.dirname(script_dir))
13
14
sys.path.insert(0, root_dir)
15
16
from tools import utils
17
18
19
def check_structs(info):
20
for struct, values in info['structs'].items():
21
key = 'C_STRUCTS\\.' + struct + '\\.'
22
# grep --quiet ruturns 0 when there is a match
23
if subprocess.run(['git', 'grep', '--quiet', key], check=False).returncode != 0:
24
print(key)
25
else:
26
for value in values:
27
if value != '__size__':
28
key = 'C_STRUCTS\\.' + struct + '\\.' + value
29
# grep --quiet ruturns 0 when there is a match
30
if subprocess.run(['git', 'grep', '--quiet', key], check=False).returncode != 0:
31
print(key)
32
33
34
def check_defines(info):
35
for define in info['defines']:
36
key = r'cDefs\.' + define + r'\>'
37
# grep --quiet ruturns 0 when there is a match
38
if subprocess.run(['git', 'grep', '--quiet', key], check=False).returncode != 0:
39
print(define)
40
41
42
def main():
43
json_file = utils.path_from_root('src/struct_info_generated.json')
44
info = json.loads(utils.read_file(json_file))
45
check_structs(info)
46
check_defines(info)
47
return 0
48
49
50
if __name__ == '__main__':
51
sys.exit(main())
52
53