blob: bae30e7d0832eb7d943fb0ade1f717474561cc46 (
plain) (
blame)
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
|
import os
import subprocess
import sys
def main():
cmd = sys.argv[1:]
h_file = None
try:
index = cmd.index('-o')
h_file = cmd[index+1]
cmd[index+1] = os.path.dirname(h_file)
except (ValueError, IndexError):
pass
p = subprocess.Popen(cmd, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()
if p.returncode:
if out:
sys.stderr.write('stdout:\n{}\n'.format(out))
if err:
sys.stderr.write('stderr:\n{}\n'.format(err))
sys.exit(p.returncode)
if h_file and h_file.endswith(('.fbs.h', '.fbs64.h')):
cpp_file = '{}.cpp'.format(h_file[:-2])
with open(cpp_file, 'w') as f:
f.write('#include "{}"\n'.format(os.path.basename(h_file)))
sys.exit(0)
if __name__ == '__main__':
main()
|