This repository has been archived by the owner on Apr 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
/
LLVMGCCBuilder.py
321 lines (289 loc) · 15.6 KB
/
LLVMGCCBuilder.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
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
import buildbot
from buildbot.steps.source import SVN
from buildbot.steps.shell import Configure, WarningCountingShellCommand
from buildbot.steps.shell import ShellCommand, SetProperty
from buildbot.process.properties import WithProperties
from zorg.buildbot.commands.LitTestCommand import LitTestCommand
from Util import getConfigArgs
def getLLVMGCCBuildFactory(jobs='%(jobs)s', update=True, clean=True,
gxxincludedir=None,
triple=None, build=None, host=None, target=None,
useTwoStage=True, stage1_config='Release+Asserts',
stage2_config='Release+Asserts', make='make',
extra_configure_args=[], extra_languages=None,
verbose=False, env = {}, defaultBranch='trunk',
timeout=20, package_dst=None):
if build or host or target:
if not build or not host or not target:
raise ValueError,"Must specify all of 'build', 'host', 'target' if used."
if triple:
raise ValueError,"Cannot specify 'triple' and 'build', 'host', 'target' options."
elif triple:
build = host = target = triple
# Prepare environmental variables. Set here all env we want everywhere.
merged_env = {
'TERM' : 'dumb' # Make sure Clang doesn't use color escape sequences.
}
if env is not None:
merged_env.update(env) # Overwrite pre-set items with the given ones, so user can set anything.
f = buildbot.process.factory.BuildFactory()
# Determine the build directory.
f.addStep(buildbot.steps.shell.SetProperty(name="get_builddir",
command=["pwd"],
property = "builddir",
description = "set build dir",
workdir = ".",
env = merged_env))
# Get the sources.
if update:
f.addStep(SVN(name='svn-llvm',
mode='update', baseURL='http://llvm.org/svn/llvm-project/llvm/',
defaultBranch = defaultBranch,
workdir = "llvm.src"))
f.addStep(SVN(name='svn-llvm-gcc',
mode='update', baseURL='http://llvm.org/svn/llvm-project/llvm-gcc-4.2/',
defaultBranch = defaultBranch,
workdir = "llvm-gcc.src"))
# Clean up llvm (stage 1).
if clean:
f.addStep(ShellCommand(name="rm-llvm.obj.stage1",
command=["rm", "-rf", "llvm.obj"],
haltOnFailure = True,
description = ["rm build dir",
"llvm",
"(stage 1)"],
workdir = ".",
env = merged_env))
# Configure llvm (stage 1).
base_llvm_configure_args = [WithProperties("%(builddir)s/llvm.src/configure")]
if build:
base_llvm_configure_args.append('--build=' + build)
base_llvm_configure_args.append('--host=' + host)
base_llvm_configure_args.append('--target=' + target)
stage_configure_args = getConfigArgs(stage1_config)
f.addStep(Configure(name='configure.llvm.stage1',
command=base_llvm_configure_args +
stage_configure_args +
["--without-llvmgcc",
"--without-llvmgxx"],
description = [ "configure",
"llvm",
"(stage 1)",
stage1_config ],
workdir = "llvm.obj",
env = merged_env))
# Build llvm (stage 1).
base_llvm_make_args = ['nice', '-n', '10',
make, WithProperties("-j%s" % jobs)]
if verbose:
base_llvm_make_args.append('VERBOSE=1')
f.addStep(WarningCountingShellCommand(name = "compile.llvm.stage1",
command = base_llvm_make_args,
haltOnFailure = True,
description = ["compile",
"llvm",
"(stage 1)",
stage1_config],
workdir = "llvm.obj",
env = merged_env,
timeout = timeout * 60))
# Run LLVM tests (stage 1).
f.addStep(LitTestCommand(name = 'test.llvm.stage1',
command = [make, "check-lit", "VERBOSE=1"],
description = ["testing", "llvm"],
descriptionDone = ["test", "llvm"],
workdir = 'llvm.obj',
env = merged_env))
# Clean up llvm-gcc.
if clean:
f.addStep(ShellCommand(name="rm-llvm-gcc.obj.stage1",
command=["rm", "-rf", "llvm-gcc.obj"],
haltOnFailure = True,
description = ["rm build dir",
"llvm-gcc"],
workdir = ".",
env = merged_env))
# Configure llvm-gcc.
base_llvmgcc_configure_args = ["../llvm-gcc.src/configure"]
llvmgcc_languages = "--enable-languages=c,c++"
if extra_languages:
llvmgcc_languages = llvmgcc_languages + "," + extra_languages
base_llvmgcc_configure_args.append(llvmgcc_languages)
if gxxincludedir:
base_llvmgcc_configure_args.append('--with-gxx-include-dir=' + gxxincludedir)
base_llvmgcc_configure_args.extend(extra_configure_args)
if build:
base_llvmgcc_configure_args.append('--build=' + build)
base_llvmgcc_configure_args.append('--host=' + host)
base_llvmgcc_configure_args.append('--target=' + target)
f.addStep(Configure(name='configure.llvm-gcc.stage1',
command=(base_llvmgcc_configure_args +
["--program-prefix=llvm-",
WithProperties("--prefix=%(builddir)s/llvm-gcc.install"),
WithProperties("--enable-llvm=%(builddir)s/llvm.obj")]),
haltOnFailure = True,
description = ["configure",
"llvm-gcc",
"(stage 1)"],
workdir = "llvm-gcc.obj",
env = merged_env))
# Build llvm-gcc.
f.addStep(WarningCountingShellCommand(name="compile.llvm-gcc.stage1",
command=['nice', '-n', '10',
make, WithProperties("-j%s" % jobs)],
haltOnFailure = True,
description = ["compile",
"llvm-gcc"],
workdir = "llvm-gcc.obj",
env = merged_env,
timeout = timeout * 60))
# Clean up llvm-gcc install.
if clean:
f.addStep(ShellCommand(name="rm-llvm-gcc.install.stage1",
command=["rm", "-rf", "llvm-gcc.install"],
haltOnFailure = True,
description = ["rm install dir",
"llvm-gcc"],
workdir = ".",
env = merged_env))
# Install llvm-gcc.
f.addStep(WarningCountingShellCommand(name="install.llvm-gcc.stage1",
command=['nice', '-n', '10',
make, 'install'],
haltOnFailure = True,
description = ["install",
"llvm-gcc"],
workdir = "llvm-gcc.obj",
env = merged_env))
# We are done if not doing a two-stage build.
if not useTwoStage:
return f
# Clean up llvm (stage 2).
if clean:
f.addStep(ShellCommand(name="rm-llvm.obj.stage2",
command=["rm", "-rf", "llvm.obj.2"],
haltOnFailure = True,
description = ["rm build dir",
"llvm",
"(stage 2)"],
workdir = ".",
env = merged_env))
# Configure llvm (stage 2).
stage_configure_args = getConfigArgs(stage2_config)
local_env = dict(merged_env)
local_env['CC'] = WithProperties("%(builddir)s/llvm-gcc.install/bin/llvm-gcc")
local_env['CXX'] = WithProperties("%(builddir)s/llvm-gcc.install/bin/llvm-g++")
f.addStep(Configure(name="configure.llvm.stage2",
command=base_llvm_configure_args +
stage_configure_args +
[WithProperties("--with-llvmgcc=%(builddir)s/llvm-gcc.install/bin/llvm-gcc"),
WithProperties("--with-llvmgxx=%(builddir)s/llvm-gcc.install/bin/llvm-g++")],
haltOnFailure = True,
description = ["configure",
"llvm",
"(stage 2)",
stage2_config],
workdir = "llvm.obj.2",
env = local_env))
# Build LLVM (stage 2).
f.addStep(WarningCountingShellCommand(name = "compile.llvm.stage2",
command = base_llvm_make_args,
haltOnFailure = True,
description = ["compile",
"llvm",
"(stage 2)",
stage2_config],
workdir = "llvm.obj.2",
env = merged_env,
timeout = timeout * 60))
# Run LLVM tests (stage 2).
f.addStep(LitTestCommand(name = 'test.llvm.stage2',
command = [make, "check-lit", "VERBOSE=1"],
description = ["testing", "llvm", "(stage 2)"],
descriptionDone = ["test", "llvm", "(stage 2)"],
workdir = 'llvm.obj.2',
env = merged_env))
# Clean up llvm-gcc (stage 2).
if clean:
f.addStep(ShellCommand(name="rm-llvm-gcc.obj.stage2",
command=["rm", "-rf", "llvm-gcc.obj.2"],
haltOnFailure = True,
description = ["rm build dir",
"llvm-gcc",
"(stage 2)"],
workdir = ".",
env = merged_env))
# Configure llvm-gcc (stage 2).
local_env = dict(merged_env)
local_env['CC'] = WithProperties("%(builddir)s/llvm-gcc.install/bin/llvm-gcc")
local_env['CXX'] = WithProperties("%(builddir)s/llvm-gcc.install/bin/llvm-g++")
f.addStep(Configure(name = 'configure.llvm-gcc.stage2',
command=base_llvmgcc_configure_args + [
"--program-prefix=llvm.2-",
WithProperties("--prefix=%(builddir)s/llvm-gcc.install.2"),
WithProperties("--enable-llvm=%(builddir)s/llvm.obj.2")],
haltOnFailure = True,
description = ["configure",
"llvm-gcc",
"(stage 2)"],
workdir = "llvm-gcc.obj.2",
env = local_env))
# Build llvm-gcc (stage 2).
f.addStep(WarningCountingShellCommand(name="compile.llvm-gcc.stage2",
command=['nice', '-n', '10',
make, WithProperties("-j%s" % jobs)],
haltOnFailure = True,
description = ["compile",
"llvm-gcc",
"(stage 2)"],
workdir = "llvm-gcc.obj.2",
env = merged_env,
timeout = timeout * 60))
# Clean up llvm-gcc install (stage 2).
if clean:
f.addStep(ShellCommand(name="rm-llvm-gcc.install.stage2",
command=["rm", "-rf", "llvm-gcc.install.2"],
haltOnFailure = True,
description = ["rm install dir",
"llvm-gcc",
"(stage 2)"],
workdir = ".",
env = merged_env))
# Install llvm-gcc.
f.addStep(WarningCountingShellCommand(name="install.llvm-gcc.stage2",
command = ['nice', '-n', '10',
make, 'install'],
haltOnFailure = True,
description = ["install",
"llvm-gcc",
"(stage 2)"],
workdir = "llvm-gcc.obj.2",
env = merged_env))
if package_dst:
addPackageStep(f, package_dst, obj_path = 'llvm-gcc.install.2', env = merged_env)
return f
import os
def addPackageStep(f, package_dst,
obj_path,
info_string = '%(phase_id)s',
env = {}):
# Package and upload.
name = WithProperties(
os.path.join("%(builddir)s", obj_path,
"llvm-gcc-%s.tar.gz" % info_string))
f.addStep(ShellCommand(name = 'pkg.tar',
description = "tar root",
command = ["tar", "zcvf", name, "./"],
workdir = obj_path,
env = env,
warnOnFailure = True,
flunkOnFailure = False,
haltOnFailure = False))
f.addStep(ShellCommand(name = 'pkg.upload',
description = "upload root",
command = ["scp", name, package_dst],
workdir = ".",
env = env,
warnOnFailure = True,
flunkOnFailure = False,
haltOnFailure = False))