-
Notifications
You must be signed in to change notification settings - Fork 1
/
generator.py
executable file
·58 lines (50 loc) · 1.69 KB
/
generator.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
#!/usr/bin/env python3
from os import listdir
from os.path import isfile, join
from subprocess import call
import sys
need_rebuild = False
def update_workspace():
try:
call(['bash', '-c', 'cd gir && cargo build --release'])
except:
return False
return True
if not isfile('./gir/src'):
need_rebuild = True
print('=> Initializing gir submodule...')
call(['bash', '-c', 'git submodule update --init'])
print('<= Done!')
question = 'Do you want to update gir submodule? [y/N] '
if sys.version_info[0] < 3:
line = raw_input(question)
else:
line = input(question)
line = line.strip()
if line.lower() == 'y':
need_rebuild = True
print('=> Updating gir submodule...')
call(['bash', '-c', 'cd gir && git reset --hard HEAD && git pull -f origin master'])
print('<= Done!')
if need_rebuild is True or not os.path.isfile('./gir/target/release/gir'):
print('=> Building gir...')
if update_workspace() is True:
print('<= Done!')
else:
print('<= Failed...')
sys.exit(1)
print('=> Regenerating crates...')
for entry in [f for f in listdir('.') if isfile(join('.', f))]:
if entry.startswith('Gir_Gst') and entry.endswith('.toml'):
print('==> Regenerating "{}"...'.format(entry))
try:
call(['./gir/target/release/gir', '-c', entry])
except Exception as err:
print('The following error occurred: {}'.format(err))
line = input('Do you want to continue? [y/N] ').strip().lower()
if line != 'y':
sys.exit(1)
print('<== Done!')
call(['cargo', 'fmt'])
print('<= Done!')
print("Don't forget to check if everything has been correctly generated!")