-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild
executable file
·144 lines (135 loc) · 3.21 KB
/
build
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/usr/bin/env python
# This should work in Python 2.7+ and Python 3.2+.
from __future__ import print_function
import argparse
import subprocess
#####
# Build targets. Modify this section to build new executables.
targets = {
'miranda' : {
'main' : 'Miranda/miranda_proper',
'test' : [
'Miranda/test/ValueTree_Test',
'Miranda/test/Commit_Test',
'Miranda/test/CommitList_Test',
'Miranda/test/performance/check'
]
},
'saffron' : {
'main' : 'Saffron/saffron'
},
'g23' : {
'main' : 'G23/g23'
},
'ariel' : {
'main' : 'Ariel/ariel'
},
'telnet' : {
'main' : 'Utils/telnet'
},
'autobuild' : {
'main' : 'Utils/autobuild'
}
}
#####
#####
# Default values.
# Target to build, 'all' and 'clean' are special.
target = 'all'
# Should we build tests?
test = True
# Should we clean up instead of building?
clean = False
# Compiler flags.
flags = [
# Enable multithreading and increase the stack size.
'-threaded',
'-with-rtsopts="-N -K100M"',
# Enable warning messages.
'-Wall',
'-fno-warn-unused-do-bind'
]
#####
#####
# This actually performs the build/cleanup.
def build():
# Run a command.
def run(cmd):
print('## ' + cmd)
subprocess.check_call(cmd, shell = True, executable = '/bin/zsh')
# What executables should we build?
executables = []
for t in targets:
if target == 'all' or target == 'clean' or target == t:
if 'main' in targets[t]:
executables.append(targets[t]['main'])
if (test or target == 'clean') and 'test' in targets[t]:
executables.extend(targets[t]['test'])
if target == 'clean':
# Clean things made by a previous build.
for e in executables:
run("rm -f '{0}'".format(e))
run('rm -f **/*.o(N) **/*.hi(N) **/*.pyc(N) **/*.pyo(N)')
else:
# Build chosen executables.
for e in executables:
run("ghc -i.. --make {0} '{1}.hs'".format(' '.join(flags), e))
#####
#####
# Command line options.
parser = argparse.ArgumentParser()
parser.add_argument(
'target',
nargs = '?',
help = 'target to build (default all)'
)
parser.add_argument(
'--no-tests',
dest = 'no_tests',
action = 'store_true',
help = 'don\'t build tests'
)
parser.add_argument(
'--fast',
dest = 'fast',
action = 'store_true',
help = 'optimise for build speed, not code speed'
)
parser.add_argument(
'--profile',
dest = 'profile',
action = 'store_true',
help = 'compile with profiling support'
)
#####
#####
# Apply the command line options.
args = parser.parse_args()
if args.target is not None:
target = args.target
if args.no_tests:
test = False
if args.profile:
# GHC will recompile everything if previous build didn't have profiling
# enabled.
flags.extend([
'-prof',
'-auto-all',
'-caf-all',
'-rtsopts'
])
if args.fast:
flags.extend([
'-O0'
])
else:
flags.extend([
'-O2',
'-fllvm'
])
#####
try:
build()
except:
# Don't write an ugly error message, the one from the compiler is enough.
pass