-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcheck_sources.py
executable file
·60 lines (46 loc) · 1.63 KB
/
check_sources.py
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
#!/usr/bin/env python3
""" Access checker script.
This script checks that WiredTiger sources comply with modularity rules
described in MODULARITY.md.
"""
import sys, os
# layercparse is a library written and maintained by the WiredTiger team.
import layercparse as lcp
import wt_defs
def main():
# lcp.setLogLevel(lcp.LogLevel.WARNING)
lcp.Log.module_name_mismatch.enabled = False
rootPath = os.path.realpath(sys.argv[1])
lcp.setRootPath(rootPath)
lcp.setModules(wt_defs.modules)
files = lcp.get_files() # list of all source files
for file in wt_defs.extraFiles:
files.insert(0, os.path.join(os.path.realpath(rootPath), file))
_globals = lcp.Codebase()
# print(" ===== Scan")
for macro in wt_defs.extraMacros:
_globals.addMacro(**macro)
_globals.scanFiles(files)
# _globals.scanFiles(files, twopass=True, multithread=False)
# print(" ===== Globals:")
# pprint(_globals, width=120, compact=False)
# print(" =====")
# print(" ===== Access check:")
# print(" ===== Check")
lcp.AccessCheck(_globals).checkAccess()
# AccessCheck(_globals).checkAccess(multithread=False)
# import cProfile as p
# pr = p.Profile()
# pr.runctx('AccessCheck(_globals).checkAccess(multithread=False)', globals=globals(), locals=locals())
# pr.create_stats()
# pr.dump_stats("q")
return not lcp.workspace.errors
if __name__ == "__main__":
try:
sys.exit(main())
except (KeyboardInterrupt, BrokenPipeError):
print("\nInterrupted")
sys.exit(1)
except OSError as e:
print(f"\n{e.strerror}: {e.filename}")
sys.exit(1)