Fix generator

This commit is contained in:
Guillaume Gomez 2019-10-30 10:22:11 +01:00 committed by Sebastian Dröge
parent b69c117908
commit da002aa98c

View file

@ -8,20 +8,11 @@ import sys
need_rebuild = False need_rebuild = False
def update_workspace(): def update_workspace():
with open('Cargo.toml', 'r') as f:
old_lines = f.readlines()
lines = old_lines[:]
with open('Cargo.toml', 'w') as f:
lines.insert(len(lines) - 2, '"gir",')
f.write(''.join(lines))
success = True
try: try:
call(['bash', '-c', 'cd gir && cargo build --release']) call(['bash', '-c', 'cd gir && cargo build --release'])
except: except:
success = False return False
with open('Cargo.toml', 'w') as f: return True
f.write(''.join(old_lines))
return success
if not isfile('./gir/src'): if not isfile('./gir/src'):
@ -54,7 +45,13 @@ print('=> Regenerating crates...')
for entry in [f for f in listdir('.') if isfile(join('.', f))]: for entry in [f for f in listdir('.') if isfile(join('.', f))]:
if entry.startswith('Gir_Gst') and entry.endswith('.toml'): if entry.startswith('Gir_Gst') and entry.endswith('.toml'):
print('==> Regenerating "{}"...'.format(entry)) print('==> Regenerating "{}"...'.format(entry))
call(['./target/release/gir', '-c', 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!') print('<== Done!')
call(['cargo', 'fmt']) call(['cargo', 'fmt'])
print('<= Done!') print('<= Done!')