File: check_struct_info.py

package info (click to toggle)
emscripten 3.1.69%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 121,860 kB
  • sloc: ansic: 636,110; cpp: 425,974; javascript: 78,401; python: 58,404; sh: 49,154; pascal: 5,237; makefile: 3,366; asm: 2,415; lisp: 1,869
file content (51 lines) | stat: -rwxr-xr-x 1,407 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/env python3

"""Find entries in struct_info.json that are not needd by
any JS library code and can be removed."""

import json
import os
import sys
import subprocess

script_dir = os.path.dirname(os.path.abspath(__file__))
root_dir = os.path.dirname(os.path.dirname(script_dir))

sys.path.insert(0, root_dir)

from tools import utils


def check_structs(info):
  for struct, values in info['structs'].items():
    key = 'C_STRUCTS\\.' + struct + '\\.'
    # grep --quiet ruturns 0 when there is a match
    if subprocess.run(['git', 'grep', '--quiet', key], check=False).returncode != 0:
      print(key)
    else:
      for value in values:
        if value != '__size__':
          key = 'C_STRUCTS\\.' + struct + '\\.' + value
          # grep --quiet ruturns 0 when there is a match
          if subprocess.run(['git', 'grep', '--quiet', key], check=False).returncode != 0:
            print(key)


def check_defines(info):
  for define in info['defines'].keys():
    key = r'cDefs\.' + define + r'\>'
    # grep --quiet ruturns 0 when there is a match
    if subprocess.run(['git', 'grep', '--quiet', key], check=False).returncode != 0:
      print(define)


def main():
  json_file = utils.path_from_root('src/struct_info_generated.json')
  info = json.loads(utils.read_file(json_file))
  check_structs(info)
  check_defines(info)
  return 0


if __name__ == '__main__':
  sys.exit(main())