forked from GeoscienceAustralia/anuga_core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_all.py
62 lines (46 loc) · 1.46 KB
/
build_all.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
import os
import time
import sys
import subprocess
buildroot = os.getcwd()
t0 = time.time()
#--------------------------------------------------
# Compiling anuga code
#--------------------------------------------------
#os.chdir('source')
#print 'Changing to', os.getcwd()
if sys.platform == 'win32':
cmd = 'python setup.py build --compiler=mingw32'
else:
cmd = 'python setup.py build'
print cmd
log_filename_1 = 'build.log'
log_filename_2 = 'build_err.log'
print("Building, see build.log...")
with open(log_filename_1, 'w') as log1:
with open(log_filename_2, 'w') as log2:
p = subprocess.Popen(cmd, stdout=log1, stderr=log2, shell=True)
# Wait for it to finish, and print something to indicate the
# process is alive, but only if the log file has grown (to
# allow continuous integration environments kill a hanging
# process accurately if it produces no output)
last_blip = time.time()
last_log_size = os.stat(log_filename_1).st_size
while p.poll() is None:
time.sleep(0.5)
if time.time() - last_blip > 10:
log_size = os.stat(log_filename_1).st_size
if log_size > last_log_size:
print(" ... build in progress")
last_blip = time.time()
last_log_size = log_size
ret = p.wait()
if ret == 0:
print("Build OK")
else:
with open(log_filename_2, 'r') as f:
print(f.read())
print("Build failed!")
sys.exit(1)
print
print 'That took %.3fs' %(time.time() - t0)