-
Notifications
You must be signed in to change notification settings - Fork 0
/
check
executable file
·44 lines (36 loc) · 1.16 KB
/
check
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
#!/usr/bin/env python3
import os
import subprocess
def main():
print("--- prebuild checks ---")
run(['scripts/reformat.sh', 'src'])
run(['scripts/CheckDeps.py', '-o', 'bin/archi.dot', 'scripts/archi.json', 'src'])
print("--- native build ---")
os.environ['BIN'] = 'bin/native'
run(['make', '-j', '16'])
run(['bin/native/tests.exe'])
print("--- windows build ---")
os.environ['BIN'] = 'bin/w64'
run(['scripts/w64-make', '-j', '16'])
print("--- stats ---")
print("Kloc: % 2.2f kloc" % (compute_klock("src")/1000.0))
print("Code: % 5d kb" % (os.path.getsize("bin/native/rel/game.exe")/1024))
def compute_klock(dir):
result = 0
for f in list_files(dir):
if f.endswith(".cpp") or f.endswith(".h"):
result += line_count(f)
return result
def list_files(dir):
return [os.path.join(dp, f) for dp, dn, fn in os.walk(dir) for f in fn]
def line_count(filename):
result = 0
with open(filename, "r") as file:
for line in file:
result += 1
return result
def run(cmd):
print(f"run: {cmd}")
return subprocess.run(cmd, check=True)
if __name__ == "__main__":
main()