blob: 902573616f8652df07dcbf4af2d1f8681770be50 [file] [log] [blame]
Daniel Dunbar235aa412009-07-18 07:16:15 +00001import buildbot
2import buildbot.process.factory
Renato Goline6c1b3b2015-07-01 15:52:22 +00003import copy
David Deanf8b35442012-12-11 00:35:12 +00004import os
Daniel Sandersfa222332015-12-04 14:30:39 +00005from datetime import datetime
David Deanf8b35442012-12-11 00:35:12 +00006
Reid Kleckner25a26b02015-03-09 22:30:25 +00007from buildbot.process.properties import WithProperties, Property
David Blaikie8cbf62f2013-01-12 21:32:31 +00008from buildbot.steps.shell import Configure, ShellCommand, SetProperty
Daniel Dunbar44abe742009-07-19 01:59:03 +00009from buildbot.steps.shell import WarningCountingShellCommand
David Deanf8b35442012-12-11 00:35:12 +000010from buildbot.steps.source import SVN
Daniel Dunbar44abe742009-07-19 01:59:03 +000011from buildbot.steps.transfer import FileDownload
Michael Gottesmana6b5be82013-06-28 21:57:20 +000012
Michael Gottesman960bcfa2013-08-30 05:46:15 +000013import zorg.buildbot.util.artifacts as artifacts
Michael Gottesmana6b5be82013-06-28 21:57:20 +000014import zorg.buildbot.builders.Util as builders_util
Michael Gottesmandc771a02013-08-30 05:46:22 +000015import zorg.buildbot.util.phasedbuilderutils as phasedbuilderutils
Michael Gottesmana6b5be82013-06-28 21:57:20 +000016import zorg.buildbot.commands as commands
17import zorg.buildbot.commands.BatchFileDownload as batch_file_download
18import zorg.buildbot.commands.LitTestCommand as lit_test_command
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +000019
Galina Kistanovaf4d79352011-10-20 20:46:52 +000020def getClangBuildFactory(
21 triple=None,
22 clean=True,
23 test=True,
24 package_dst=None,
25 run_cxx_tests=False,
26 examples=False,
27 valgrind=False,
28 valgrindLeakCheck=False,
Galina Kistanovaf4d79352011-10-20 20:46:52 +000029 useTwoStage=False,
30 completely_clean=False,
Galina Kistanovaf4d79352011-10-20 20:46:52 +000031 make='make',
32 jobs="%(jobs)s",
33 stage1_config='Debug+Asserts',
34 stage2_config='Release+Asserts',
35 env={}, # Environmental variables for all steps.
36 extra_configure_args=[],
Vassil Vassilev5a9b9ed2016-05-25 17:10:03 +000037 stage2_extra_configure_args=[],
Galina Kistanovaf4d79352011-10-20 20:46:52 +000038 use_pty_in_tests=False,
Peter Collingbourned49ac282011-10-25 14:38:45 +000039 trunk_revision=None,
40 force_checkout=False,
Peter Collingbourne7a95b0c2011-10-26 16:40:17 +000041 extra_clean_step=None,
David Blaikiea76da842012-08-13 22:24:46 +000042 checkout_compiler_rt=False,
Galina Kistanova2ab1e2d2016-11-22 00:23:43 +000043 checkout_lld=False,
David Blaikiea76da842012-08-13 22:24:46 +000044 run_gdb=False,
David Blaikiedad03d52012-11-16 22:37:12 +000045 run_modern_gdb=False,
Vassil Vassilev0c647ef2016-06-30 21:16:45 +000046 run_gcc=False):
Galina Kistanovaf4d79352011-10-20 20:46:52 +000047 # Prepare environmental variables. Set here all env we want everywhere.
48 merged_env = {
49 'TERM' : 'dumb' # Make sure Clang doesn't use color escape sequences.
50 }
51 if env is not None:
52 # Overwrite pre-set items with the given ones, so user can set anything.
53 merged_env.update(env)
David Blaikie2f7eb282012-08-24 18:37:00 +000054
Jonathan Roelofs62415e52015-02-28 00:03:17 +000055 llvm_srcdir = "llvm.src"
56 llvm_1_objdir = "llvm.obj"
57 llvm_1_installdir = "llvm.install.1"
58 llvm_2_objdir = "llvm.obj.2"
59 llvm_2_installdir = "llvm.install"
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +000060
Daniel Dunbar235aa412009-07-18 07:16:15 +000061 f = buildbot.process.factory.BuildFactory()
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +000062
63 # Determine the build directory.
64 f.addStep(buildbot.steps.shell.SetProperty(name="get_builddir",
65 command=["pwd"],
66 property="builddir",
67 description="set build dir",
Galina Kistanovaf4d79352011-10-20 20:46:52 +000068 workdir=".",
69 env=merged_env))
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +000070
Daniel Dunbar06b20f12010-04-08 18:29:38 +000071 # Blow away completely, if requested.
72 if completely_clean:
73 f.addStep(ShellCommand(name="rm-llvm.src",
74 command=["rm", "-rf", llvm_srcdir],
75 haltOnFailure=True,
76 description=["rm src dir", "llvm"],
Galina Kistanovaf4d79352011-10-20 20:46:52 +000077 workdir=".",
78 env=merged_env))
Daniel Dunbar06b20f12010-04-08 18:29:38 +000079
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +000080 # Checkout sources.
Peter Collingbourned49ac282011-10-25 14:38:45 +000081 if trunk_revision:
82 # The SVN build step provides no mechanism to check out a specific revision
83 # based on a property, so just run the commands directly here.
84 svn_co = ['svn', 'checkout']
85 if force_checkout:
86 svn_co += ['--force']
87 svn_co += ['--revision', WithProperties(trunk_revision)]
88
89 svn_co_llvm = svn_co + \
90 [WithProperties('http://llvm.org/svn/llvm-project/llvm/trunk@%s' %
91 trunk_revision),
92 llvm_srcdir]
93 svn_co_clang = svn_co + \
94 [WithProperties('http://llvm.org/svn/llvm-project/cfe/trunk@%s' %
95 trunk_revision),
96 '%s/tools/clang' % llvm_srcdir]
David Blaikie845ae0d2012-08-10 00:51:38 +000097 svn_co_clang_tools_extra = svn_co + \
98 [WithProperties('http://llvm.org/svn/llvm-project/clang-tools-extra/trunk@%s' %
99 trunk_revision),
100 '%s/tools/clang/tools/extra' % llvm_srcdir]
Peter Collingbourned49ac282011-10-25 14:38:45 +0000101
102 f.addStep(ShellCommand(name='svn-llvm',
103 command=svn_co_llvm,
104 haltOnFailure=True,
105 workdir='.'))
106 f.addStep(ShellCommand(name='svn-clang',
107 command=svn_co_clang,
108 haltOnFailure=True,
109 workdir='.'))
David Blaikie845ae0d2012-08-10 00:51:38 +0000110 f.addStep(ShellCommand(name='svn-clang-tools-extra',
111 command=svn_co_clang_tools_extra,
112 haltOnFailure=True,
113 workdir='.'))
Peter Collingbourned49ac282011-10-25 14:38:45 +0000114 else:
115 f.addStep(SVN(name='svn-llvm',
Daniel Dunbarf4e23eb2010-09-20 21:13:02 +0000116 mode='update',
Peter Collingbourned49ac282011-10-25 14:38:45 +0000117 baseURL='http://llvm.org/svn/llvm-project/llvm/',
Daniel Dunbarf4e23eb2010-09-20 21:13:02 +0000118 defaultBranch='trunk',
Peter Collingbourned49ac282011-10-25 14:38:45 +0000119 workdir=llvm_srcdir))
120 f.addStep(SVN(name='svn-clang',
121 mode='update',
122 baseURL='http://llvm.org/svn/llvm-project/cfe/',
123 defaultBranch='trunk',
124 workdir='%s/tools/clang' % llvm_srcdir))
David Blaikie845ae0d2012-08-10 00:51:38 +0000125 f.addStep(SVN(name='svn-clang-tools-extra',
126 mode='update',
127 baseURL='http://llvm.org/svn/llvm-project/clang-tools-extra/',
128 defaultBranch='trunk',
129 workdir='%s/tools/clang/tools/extra' % llvm_srcdir))
Peter Collingbourned49ac282011-10-25 14:38:45 +0000130 if checkout_compiler_rt:
131 f.addStep(SVN(name='svn-compiler-rt',
132 mode='update',
133 baseURL='http://llvm.org/svn/llvm-project/compiler-rt/',
134 defaultBranch='trunk',
135 workdir='%s/projects/compiler-rt' % llvm_srcdir))
Daniel Dunbarfa0e0222009-11-09 06:08:28 +0000136
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000137 # Clean up llvm (stage 1); unless in-dir.
138 if clean and llvm_srcdir != llvm_1_objdir:
139 f.addStep(ShellCommand(name="rm-llvm.obj.stage1",
140 command=["rm", "-rf", llvm_1_objdir],
141 haltOnFailure=True,
142 description=["rm build dir", "llvm"],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000143 workdir=".",
144 env=merged_env))
Andrew Trick70fa9d22011-08-25 23:38:51 +0000145
David Blaikie8cbf62f2013-01-12 21:32:31 +0000146 if not clean:
Galina Kistanovaa06e4c82016-04-14 21:41:30 +0000147 expected_makefile = 'Makefile'
David Blaikie8cbf62f2013-01-12 21:32:31 +0000148 f.addStep(SetProperty(name="Makefile_isready",
149 workdir=llvm_1_objdir,
150 command=["sh", "-c",
Richard Smith02389162014-09-26 23:53:06 +0000151 "test -e %s && echo OK || echo Missing" % expected_makefile],
David Blaikie8cbf62f2013-01-12 21:32:31 +0000152 flunkOnFailure=False,
Galina Kistanovaa06e4c82016-04-14 21:41:30 +0000153 property="exists_Makefile"))
Richard Smith02389162014-09-26 23:53:06 +0000154
Galina Kistanovaa06e4c82016-04-14 21:41:30 +0000155 cmake_triple_arg = []
156 if triple:
157 cmake_triple_arg = ['-DLLVM_HOST_TRIPLE=%s' % triple]
158 f.addStep(ShellCommand(name='cmake',
159 command=['cmake',
160 '-DLLVM_BUILD_TESTS=ON',
161 '-DCMAKE_BUILD_TYPE=%s' % stage1_config] +
162 cmake_triple_arg +
163 extra_configure_args +
164 ["../" + llvm_srcdir],
165 description='cmake stage1',
166 workdir=llvm_1_objdir,
167 env=merged_env,
168 doStepIf=lambda step: step.build.getProperty("exists_Makefile") != "OK"))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000169
170 # Make clean if using in-dir builds.
171 if clean and llvm_srcdir == llvm_1_objdir:
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000172 f.addStep(WarningCountingShellCommand(name="clean-llvm",
Daniel Dunbard20468a2009-11-24 18:27:23 +0000173 command=[make, "clean"],
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000174 haltOnFailure=True,
175 description="cleaning llvm",
176 descriptionDone="clean llvm",
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000177 workdir=llvm_1_objdir,
Peter Collingbourne7a95b0c2011-10-26 16:40:17 +0000178 doStepIf=clean,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000179 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000180
Peter Collingbourne7a95b0c2011-10-26 16:40:17 +0000181 if extra_clean_step:
182 f.addStep(extra_clean_step)
183
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000184 f.addStep(WarningCountingShellCommand(name="compile",
Daniel Dunbard20468a2009-11-24 18:27:23 +0000185 command=['nice', '-n', '10',
186 make, WithProperties("-j%s" % jobs)],
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000187 haltOnFailure=True,
David Blaikie05517332013-12-19 23:29:12 +0000188 flunkOnFailure=not run_gdb,
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000189 description=["compiling", stage1_config],
190 descriptionDone=["compile", stage1_config],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000191 workdir=llvm_1_objdir,
192 env=merged_env))
Daniel Dunbar256fed42009-11-25 21:11:08 +0000193
194 if examples:
195 f.addStep(WarningCountingShellCommand(name="compile.examples",
196 command=['nice', '-n', '10',
197 make, WithProperties("-j%s" % jobs),
198 "BUILD_EXAMPLES=1"],
199 haltOnFailure=True,
Richard Smith65e6f5d2014-09-25 18:18:35 +0000200 description=["compiling", stage1_config, "examples"],
Daniel Dunbar256fed42009-11-25 21:11:08 +0000201 descriptionDone=["compile", stage1_config, "examples"],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000202 workdir=llvm_1_objdir,
203 env=merged_env))
Daniel Dunbar256fed42009-11-25 21:11:08 +0000204
NAKAMURA Takumi1a4666b2013-01-19 03:39:07 +0000205 clangTestArgs = '-v -j %s' % jobs
Daniel Dunbarfa0e0222009-11-09 06:08:28 +0000206 if valgrind:
Daniel Dunbar89184b92010-04-18 19:09:32 +0000207 clangTestArgs += ' --vg'
Daniel Dunbara1bebce2010-03-21 01:24:00 +0000208 if valgrindLeakCheck:
209 clangTestArgs += ' --vg-leak'
Nick Lewycky8d26e472011-08-27 21:18:56 +0000210 clangTestArgs += ' --vg-arg --suppressions=%(builddir)s/llvm/tools/clang/utils/valgrind/x86_64-pc-linux-gnu_gcc-4.3.3.supp --vg-arg --suppressions=%(builddir)s/llvm/utils/valgrind/x86_64-pc-linux-gnu.supp'
Daniel Dunbarfa0e0222009-11-09 06:08:28 +0000211 extraTestDirs = ''
212 if run_cxx_tests:
213 extraTestDirs += '%(builddir)s/llvm/tools/clang/utils/C++Tests'
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000214 if test:
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000215 f.addStep(lit_test_command.LitTestCommand(name='check-all',
David Blaikie7e6f8a12012-08-31 20:46:27 +0000216 command=[make, "check-all", "VERBOSE=1",
NAKAMURA Takumi1a4666b2013-01-19 03:39:07 +0000217 WithProperties("LIT_ARGS=%s" % clangTestArgs),
David Blaikiebc684012012-12-27 20:44:19 +0000218 WithProperties("EXTRA_TESTDIRS=%s" % extraTestDirs)],
David Blaikie05517332013-12-19 23:29:12 +0000219 flunkOnFailure=not run_gdb,
David Blaikie7e6f8a12012-08-31 20:46:27 +0000220 description=["checking"],
221 descriptionDone=["checked"],
Daniel Dunbar469e8ca2010-05-19 21:26:48 +0000222 workdir=llvm_1_objdir,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000223 usePTY=use_pty_in_tests,
224 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000225
Galina Kistanovaa06e4c82016-04-14 21:41:30 +0000226 # TODO: Install llvm and clang for stage1.
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000227
David Blaikiedad03d52012-11-16 22:37:12 +0000228 if run_gdb or run_gcc or run_modern_gdb:
David Blaikiea76da842012-08-13 22:24:46 +0000229 ignores = getClangTestsIgnoresFromPath(os.path.expanduser('~/public/clang-tests'), 'clang-x86_64-darwin10')
230 install_prefix = "%%(builddir)s/%s" % llvm_1_installdir
231 if run_gdb:
232 addClangGDBTests(f, ignores, install_prefix)
David Blaikiedad03d52012-11-16 22:37:12 +0000233 if run_modern_gdb:
David Blaikie41d09c32013-01-02 21:11:09 +0000234 addModernClangGDBTests(f, jobs, install_prefix)
David Blaikiea76da842012-08-13 22:24:46 +0000235 if run_gcc:
236 addClangGCCTests(f, ignores, install_prefix)
237
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000238 if not useTwoStage:
Daniel Dunbardedf6572010-11-13 00:23:34 +0000239 if package_dst:
240 name = WithProperties(
241 "%(builddir)s/" + llvm_1_objdir +
242 "/clang-r%(got_revision)s-b%(buildnumber)s.tgz")
243 f.addStep(ShellCommand(name='pkg.tar',
244 description="tar root",
245 command=["tar", "zcvf", name, "./"],
246 workdir=llvm_1_installdir,
247 warnOnFailure=True,
248 flunkOnFailure=False,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000249 haltOnFailure=False,
250 env=merged_env))
Daniel Dunbardedf6572010-11-13 00:23:34 +0000251 f.addStep(ShellCommand(name='pkg.upload',
Andrew Trick70fa9d22011-08-25 23:38:51 +0000252 description="upload root",
Daniel Dunbardedf6572010-11-13 00:23:34 +0000253 command=["scp", name,
254 WithProperties(
255 package_dst + "/%(buildername)s")],
256 workdir=".",
257 warnOnFailure=True,
258 flunkOnFailure=False,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000259 haltOnFailure=False,
260 env=merged_env))
Daniel Dunbardedf6572010-11-13 00:23:34 +0000261
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000262 return f
263
264 # Clean up llvm (stage 2).
Richard Smith02389162014-09-26 23:53:06 +0000265 #
Galina Kistanova79900972015-11-16 17:30:42 +0000266 # We always cleanly build the stage 2. If the compiler has been
267 # changed on the stage 1, we cannot trust any of the intermediate file
268 # from the old compiler. And if the stage 1 compiler is the same, we should
269 # not build in the first place.
270 f.addStep(ShellCommand(name="rm-llvm.obj.stage2",
271 command=["rm", "-rf", llvm_2_objdir],
272 haltOnFailure=True,
273 description=["rm build dir", "llvm", "(stage 2)"],
274 workdir=".",
275 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000276
277 # Configure llvm (stage 2).
Galina Kistanovaa06e4c82016-04-14 21:41:30 +0000278 f.addStep(ShellCommand(name='cmake',
Vassil Vassilev5a9b9ed2016-05-25 17:10:03 +0000279 command=['cmake'] + stage2_extra_configure_args + [
Galina Kistanovaa06e4c82016-04-14 21:41:30 +0000280 '-DLLVM_BUILD_TESTS=ON',
281 WithProperties('-DCMAKE_C_COMPILER=%%(builddir)s/%s/bin/clang' % llvm_1_objdir), # FIXME use installdir
282 WithProperties('-DCMAKE_CXX_COMPILER=%%(builddir)s/%s/bin/clang++' % llvm_1_objdir),
283 '-DCMAKE_BUILD_TYPE=%s' % stage2_config,
Galina Kistanovaa06e4c82016-04-14 21:41:30 +0000284 "../" + llvm_srcdir],
285 description='cmake stage2',
286 workdir=llvm_2_objdir,
287 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000288
289 # Build llvm (stage 2).
290 f.addStep(WarningCountingShellCommand(name="compile.llvm.stage2",
291 command=['nice', '-n', '10',
292 make, WithProperties("-j%s" % jobs)],
293 haltOnFailure=True,
294 description=["compiling", "(stage 2)",
295 stage2_config],
296 descriptionDone=["compile", "(stage 2)",
297 stage2_config],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000298 workdir=llvm_2_objdir,
299 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000300
301 if test:
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000302 f.addStep(lit_test_command.LitTestCommand(name='check-all',
David Blaikie7e6f8a12012-08-31 20:46:27 +0000303 command=[make, "check-all", "VERBOSE=1",
NAKAMURA Takumi1a4666b2013-01-19 03:39:07 +0000304 WithProperties("LIT_ARGS=%s" % clangTestArgs),
David Blaikiebc684012012-12-27 20:44:19 +0000305 WithProperties("EXTRA_TESTDIRS=%s" % extraTestDirs)],
David Blaikie7e6f8a12012-08-31 20:46:27 +0000306 description=["checking"],
307 descriptionDone=["checked"],
Daniel Dunbar469e8ca2010-05-19 21:26:48 +0000308 workdir=llvm_2_objdir,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000309 usePTY=use_pty_in_tests,
310 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000311
Galina Kistanovaa06e4c82016-04-14 21:41:30 +0000312 # TODO: Install llvm and clang for stage2.
Daniel Dunbar3efb7822010-02-26 19:20:00 +0000313
314 if package_dst:
315 name = WithProperties(
316 "%(builddir)s/" + llvm_2_objdir +
317 "/clang-r%(got_revision)s-b%(buildnumber)s.tgz")
318 f.addStep(ShellCommand(name='pkg.tar',
319 description="tar root",
320 command=["tar", "zcvf", name, "./"],
321 workdir=llvm_2_installdir,
322 warnOnFailure=True,
323 flunkOnFailure=False,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000324 haltOnFailure=False,
325 env=merged_env))
Daniel Dunbar3efb7822010-02-26 19:20:00 +0000326 f.addStep(ShellCommand(name='pkg.upload',
Andrew Trick70fa9d22011-08-25 23:38:51 +0000327 description="upload root",
Daniel Dunbar3efb7822010-02-26 19:20:00 +0000328 command=["scp", name,
329 WithProperties(
330 package_dst + "/%(buildername)s")],
331 workdir=".",
332 warnOnFailure=True,
333 flunkOnFailure=False,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000334 haltOnFailure=False,
335 env=merged_env))
Daniel Dunbar3efb7822010-02-26 19:20:00 +0000336
Daniel Dunbar235aa412009-07-18 07:16:15 +0000337 return f
Daniel Dunbar44abe742009-07-19 01:59:03 +0000338
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000339def addSVNUpdateSteps(f,
340 checkout_clang_tools_extra,
341 checkout_compiler_rt,
Renato Golin0bd2a532016-11-20 16:14:35 +0000342 checkout_test_suite,
343 checkout_lld):
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000344 # We *must* checkout at least Clang+LLVM
345 f.addStep(SVN(name='svn-llvm',
346 mode='update', baseURL='http://llvm.org/svn/llvm-project/llvm/',
347 defaultBranch='trunk',
348 workdir='llvm'))
349 f.addStep(SVN(name='svn-clang',
350 mode='update', baseURL='http://llvm.org/svn/llvm-project/cfe/',
351 defaultBranch='trunk',
352 workdir='llvm/tools/clang'))
353
354 # Extra stuff that will be built/tested
355 if checkout_clang_tools_extra:
356 f.addStep(SVN(name='svn-clang-tools-extra',
357 mode='update', baseURL='http://llvm.org/svn/llvm-project/clang-tools-extra/',
358 defaultBranch='trunk',
359 workdir='llvm/tools/clang/tools/extra'))
360 if checkout_compiler_rt:
361 f.addStep(SVN(name='svn-compiler-rt',
362 mode='update', baseURL='http://llvm.org/svn/llvm-project/compiler-rt/',
363 defaultBranch='trunk',
364 workdir='llvm/projects/compiler-rt'))
365 if checkout_test_suite:
366 f.addStep(SVN(name='svn-lnt',
367 mode='update', baseURL='http://llvm.org/svn/llvm-project/lnt/',
368 defaultBranch='trunk',
369 workdir='test/lnt'))
370 f.addStep(SVN(name='svn-test-suite',
371 mode='update', baseURL='http://llvm.org/svn/llvm-project/test-suite/',
372 defaultBranch='trunk',
373 workdir='test/test-suite'))
Renato Golin0bd2a532016-11-20 16:14:35 +0000374 if checkout_lld:
375 f.addStep(SVN(name='svn-lld',
376 mode='update', baseURL='http://llvm.org/svn/llvm-project/lld/',
377 defaultBranch='trunk',
378 workdir='llvm/tools/lld'))
Renato Goline402f582014-09-04 19:25:24 +0000379
Daniel Sandersfa222332015-12-04 14:30:39 +0000380def addGCSUploadSteps(f, package_name, install_prefix, gcs_directory, env,
381 gcs_url_property=None):
382 """
383 Add steps to upload to the Google Cloud Storage bucket.
384
385 f - The BuildFactory to modify.
386 package_name - The name of this package for the descriptions (e.g.
387 'stage 1')
388 install_prefix - The directory the build has been installed to.
389 gcs_directory - The subdirectory of the bucket root to upload to. This
390 should match the builder name.
391 env - The environment to use. Set BOTO_CONFIG to use a configuration file
392 in a non-standard location, and BUCKET to use a different GCS bucket.
393 gcs_url_property - Property to assign the GCS url to.
394 """
395
396 gcs_url_fmt = ('gs://%(gcs_bucket)s/%(gcs_directory)s/'
397 'clang-r%(got_revision)s-t%(now)s-b%(buildnumber)s.tar.xz')
398 time_fmt = '%Y-%m-%d_%H-%M-%S'
399 gcs_url = \
400 WithProperties(
401 gcs_url_fmt,
402 gcs_bucket=lambda _: env.get('BUCKET', 'llvm-build-artifacts'),
403 gcs_directory=lambda _: gcs_directory,
404 now=lambda _: datetime.utcnow().strftime(time_fmt))
405
406 if gcs_url_property:
407 f.addStep(SetProperty(
408 name="record GCS url for " + package_name,
409 command=['echo', gcs_url],
410 property=gcs_url_property))
411
412 f.addStep(ShellCommand(name='package ' + package_name,
413 command=['tar', 'cvfJ', '../install.tar.xz', '.'],
414 description='packaging ' + package_name + '...',
415 workdir=install_prefix,
416 env=env))
417
418 f.addStep(ShellCommand(
419 name='upload ' + package_name + ' to storage bucket',
420 command=['gsutil', 'cp', '../install.tar.xz', gcs_url],
421 description=('uploading ' + package_name +
422 'to storage bucket ...'),
423 workdir=install_prefix,
424 env=env))
425
426def getClangCMakeGCSBuildFactory(
427 clean=True,
428 test=True,
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000429 cmake='cmake',
Daniel Sandersfa222332015-12-04 14:30:39 +0000430 jobs=None,
431
432 # VS tools environment variable if using MSVC. For example,
433 # %VS120COMNTOOLS% selects the 2013 toolchain.
434 vs=None,
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000435 vs_target_arch='x86',
Daniel Sandersfa222332015-12-04 14:30:39 +0000436
437 # Multi-stage compilation
438 useTwoStage=False,
439 testStage1=True,
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000440 stage1_config='Release',
441 stage2_config='Release',
Daniel Sandersfa222332015-12-04 14:30:39 +0000442
443 # Test-suite
444 runTestSuite=False,
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000445 nt_flags=[],
Daniel Sandersfa222332015-12-04 14:30:39 +0000446 submitURL=None,
447 testerName=None,
448
449 # Environmental variables for all steps.
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000450 env={},
451 extra_cmake_args=[],
Daniel Sandersfa222332015-12-04 14:30:39 +0000452
453 # Extra repositories
454 checkout_clang_tools_extra=True,
455 checkout_compiler_rt=True,
Renato Golin0bd2a532016-11-20 16:14:35 +0000456 checkout_lld=True,
Daniel Sandersfa222332015-12-04 14:30:39 +0000457
458 # Upload artifacts to Google Cloud Storage (for the llvmbisect tool)
459 stage1_upload_directory=None,
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000460
461 # Triggers
462 trigger_after_stage1=[]):
Daniel Sandersfa222332015-12-04 14:30:39 +0000463 return _getClangCMakeBuildFactory(
464 clean=clean, test=test, cmake=cmake, jobs=jobs, vs=vs,
465 vs_target_arch=vs_target_arch, useTwoStage=useTwoStage,
466 testStage1=testStage1, stage1_config=stage1_config,
467 stage2_config=stage2_config, runTestSuite=runTestSuite,
468 nt_flags=nt_flags, submitURL=submitURL, testerName=testerName,
469 env=env, extra_cmake_args=extra_cmake_args,
470 checkout_clang_tools_extra=checkout_clang_tools_extra,
471 checkout_compiler_rt=checkout_compiler_rt,
Renato Golin0bd2a532016-11-20 16:14:35 +0000472 checkout_lld=checkout_lld,
Daniel Sandersfa222332015-12-04 14:30:39 +0000473 stage1_upload_directory=stage1_upload_directory,
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000474 trigger_after_stage1=trigger_after_stage1)
Reid Kleckner25a26b02015-03-09 22:30:25 +0000475
476def getClangCMakeBuildFactory(
477 clean=True,
478 test=True,
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000479 cmake='cmake',
Reid Kleckner25a26b02015-03-09 22:30:25 +0000480 jobs=None,
481
482 # VS tools environment variable if using MSVC. For example,
483 # %VS120COMNTOOLS% selects the 2013 toolchain.
484 vs=None,
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000485 vs_target_arch='x86',
Reid Kleckner25a26b02015-03-09 22:30:25 +0000486
487 # Multi-stage compilation
488 useTwoStage=False,
489 testStage1=True,
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000490 stage1_config='Release',
491 stage2_config='Release',
Reid Kleckner25a26b02015-03-09 22:30:25 +0000492
Renato Golin61aed7f2015-06-17 19:12:50 +0000493 # Test-suite
494 runTestSuite=False,
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000495 nt_flags=[],
Renato Golin61aed7f2015-06-17 19:12:50 +0000496 submitURL=None,
497 testerName=None,
498
Reid Kleckner25a26b02015-03-09 22:30:25 +0000499 # Environmental variables for all steps.
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000500 env={},
501 extra_cmake_args=[],
Reid Kleckner25a26b02015-03-09 22:30:25 +0000502
503 # Extra repositories
504 checkout_clang_tools_extra=True,
Renato Golin0bd2a532016-11-20 16:14:35 +0000505 checkout_compiler_rt=True,
506 checkout_lld=True):
Daniel Sandersfa222332015-12-04 14:30:39 +0000507 return _getClangCMakeBuildFactory(
508 clean=clean, test=test, cmake=cmake, jobs=jobs, vs=vs,
509 vs_target_arch=vs_target_arch, useTwoStage=useTwoStage,
510 testStage1=testStage1, stage1_config=stage1_config,
511 stage2_config=stage2_config, runTestSuite=runTestSuite,
512 nt_flags=nt_flags, submitURL=submitURL, testerName=testerName,
513 env=env, extra_cmake_args=extra_cmake_args,
514 checkout_clang_tools_extra=checkout_clang_tools_extra,
Renato Golin0bd2a532016-11-20 16:14:35 +0000515 checkout_lld=checkout_lld,
Daniel Sandersfa222332015-12-04 14:30:39 +0000516 checkout_compiler_rt=checkout_compiler_rt)
517
518def _getClangCMakeBuildFactory(
519 clean=True,
520 test=True,
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000521 cmake='cmake',
Daniel Sandersfa222332015-12-04 14:30:39 +0000522 jobs=None,
523
524 # VS tools environment variable if using MSVC. For example,
525 # %VS120COMNTOOLS% selects the 2013 toolchain.
526 vs=None,
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000527 vs_target_arch='x86',
Daniel Sandersfa222332015-12-04 14:30:39 +0000528
529 # Multi-stage compilation
530 useTwoStage=False,
531 testStage1=True,
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000532 stage1_config='Release',
533 stage2_config='Release',
Daniel Sandersfa222332015-12-04 14:30:39 +0000534
535 # Test-suite
536 runTestSuite=False,
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000537 nt_flags=[],
Daniel Sandersfa222332015-12-04 14:30:39 +0000538 submitURL=None,
539 testerName=None,
540
541 # Environmental variables for all steps.
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000542 env={},
543 extra_cmake_args=[],
Daniel Sandersfa222332015-12-04 14:30:39 +0000544
545 # Extra repositories
546 checkout_clang_tools_extra=True,
547 checkout_compiler_rt=True,
Renato Golin0bd2a532016-11-20 16:14:35 +0000548 checkout_lld=True,
Daniel Sandersfa222332015-12-04 14:30:39 +0000549
550 # Upload artifacts to Google Cloud Storage (for the llvmbisect tool)
551 stage1_upload_directory=None,
552
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000553 # Triggers
554 trigger_after_stage1=[]):
Reid Kleckner25a26b02015-03-09 22:30:25 +0000555
556 ############# PREPARING
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000557 f = buildbot.process.factory.BuildFactory()
Reid Kleckner25a26b02015-03-09 22:30:25 +0000558
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000559 addSVNUpdateSteps(f,
560 checkout_clang_tools_extra=checkout_clang_tools_extra,
561 checkout_compiler_rt=checkout_compiler_rt,
Renato Golin0bd2a532016-11-20 16:14:35 +0000562 checkout_lld=checkout_lld,
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000563 checkout_test_suite=runTestSuite)
Reid Kleckner25a26b02015-03-09 22:30:25 +0000564
Renato Goline402f582014-09-04 19:25:24 +0000565 # If jobs not defined, Ninja will choose a suitable value
Renato Golincc83db32015-06-17 19:23:40 +0000566 jobs_cmd = []
567 lit_args = "'-v"
Renato Goline402f582014-09-04 19:25:24 +0000568 if jobs is not None:
Renato Golincc83db32015-06-17 19:23:40 +0000569 jobs_cmd = ["-j"+str(jobs)]
570 lit_args += " -j"+str(jobs)+"'"
Renato Goline402f582014-09-04 19:25:24 +0000571 else:
Renato Golincc83db32015-06-17 19:23:40 +0000572 lit_args += "'"
573 ninja_cmd = ['ninja'] + jobs_cmd
574 ninja_install_cmd = ['ninja', 'install'] + jobs_cmd
575 ninja_check_cmd = ['ninja', 'check-all'] + jobs_cmd
Reid Kleckner25a26b02015-03-09 22:30:25 +0000576 check_build_cmd = ["sh", "-c",
577 "test -e build.ninja && echo OK || echo Missing"]
578 if vs:
579 check_build_cmd = ["cmd", "/c", "if exist build.ninja (echo OK) " +
580 " else (echo Missing & exit 1)"]
Renato Goline402f582014-09-04 19:25:24 +0000581
582 # Global configurations
Renato Golincc83db32015-06-17 19:23:40 +0000583 stage1_build = 'stage1'
584 stage1_install = 'stage1.install'
585 stage2_build = 'stage2'
586 stage2_install = 'stage2.install'
Renato Goline402f582014-09-04 19:25:24 +0000587
Reid Kleckner25a26b02015-03-09 22:30:25 +0000588 # Set up VS environment, if appropriate.
589 if vs:
590 f.addStep(SetProperty(
591 command=builders_util.getVisualStudioEnvironment(vs, vs_target_arch),
592 extract_fn=builders_util.extractSlaveEnvironment))
593 assert not env, "Can't have custom builder env vars with VS"
594 env = Property('slave_env')
595
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000596
Renato Goline402f582014-09-04 19:25:24 +0000597 ############# CLEANING
598 if clean:
599 f.addStep(ShellCommand(name='clean stage 1',
600 command=['rm','-rf',stage1_build],
601 warnOnFailure=True,
602 description='cleaning stage 1',
603 descriptionDone='clean',
604 workdir='.',
605 env=env))
606 else:
607 f.addStep(SetProperty(name="check ninja files 1",
608 workdir=stage1_build,
Reid Kleckner25a26b02015-03-09 22:30:25 +0000609 command=check_build_cmd,
Renato Goline402f582014-09-04 19:25:24 +0000610 flunkOnFailure=False,
611 property="exists_ninja_1"))
612
613
614 ############# STAGE 1
615 f.addStep(ShellCommand(name='cmake stage 1',
616 command=[cmake, "-G", "Ninja", "../llvm",
617 "-DCMAKE_BUILD_TYPE="+stage1_config,
618 "-DLLVM_ENABLE_ASSERTIONS=True",
619 "-DLLVM_LIT_ARGS="+lit_args,
620 "-DCMAKE_INSTALL_PREFIX=../"+stage1_install]
621 + extra_cmake_args,
622 haltOnFailure=True,
623 description='cmake stage 1',
624 workdir=stage1_build,
625 doStepIf=lambda step: step.build.getProperty("exists_ninja_1") != "OK",
626 env=env))
627
628 f.addStep(WarningCountingShellCommand(name='build stage 1',
629 command=ninja_cmd,
630 haltOnFailure=True,
631 description='ninja all',
632 workdir=stage1_build,
633 env=env))
634
635 if test and testStage1:
Renato Golind1c46742015-08-06 18:05:34 +0000636 haltOnStage1Check = not useTwoStage and not runTestSuite
Renato Golincfbd5702014-09-06 19:09:16 +0000637 f.addStep(lit_test_command.LitTestCommand(name='ninja check 1',
638 command=ninja_check_cmd,
Renato Golind1c46742015-08-06 18:05:34 +0000639 haltOnFailure=haltOnStage1Check,
Renato Golincfbd5702014-09-06 19:09:16 +0000640 description=["checking stage 1"],
641 descriptionDone=["stage 1 checked"],
642 workdir=stage1_build,
643 env=env))
Renato Goline402f582014-09-04 19:25:24 +0000644
Daniel Sandersfa222332015-12-04 14:30:39 +0000645 if useTwoStage or runTestSuite or stage1_upload_directory:
Renato Golin61aed7f2015-06-17 19:12:50 +0000646 f.addStep(ShellCommand(name='install stage 1',
647 command=ninja_install_cmd,
648 description='ninja install',
649 workdir=stage1_build,
Renato Goline402f582014-09-04 19:25:24 +0000650 env=env))
Renato Goline402f582014-09-04 19:25:24 +0000651
Daniel Sandersfa222332015-12-04 14:30:39 +0000652 if stage1_upload_directory:
653 addGCSUploadSteps(f, 'stage 1', stage1_install, stage1_upload_directory,
654 env, gcs_url_property='stage1_package_gcs_url')
655
Reid Kleckner25a26b02015-03-09 22:30:25 +0000656 # Compute the cmake define flag to set the C and C++ compiler to clang. Use
657 # clang-cl if we used MSVC for stage1.
658 if not vs:
659 cc = 'clang'
660 cxx = 'clang++'
661 else:
662 cc = 'clang-cl.exe'
663 cxx = 'clang-cl.exe'
664
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000665
Renato Golin61aed7f2015-06-17 19:12:50 +0000666 ############# STAGE 2
667 if useTwoStage:
Galina Kistanova79900972015-11-16 17:30:42 +0000668 # We always cleanly build the stage 2. If the compiler has been
669 # changed on the stage 1, we cannot trust any of the intermediate file
670 # from the old compiler. And if the stage 1 compiler is the same, we
671 # should not build in the first place.
672 f.addStep(ShellCommand(name='clean stage 2',
673 command=['rm','-rf',stage2_build],
674 warnOnFailure=True,
675 description='cleaning stage 2',
676 descriptionDone='clean',
677 workdir='.',
678 env=env))
Reid Kleckner25a26b02015-03-09 22:30:25 +0000679
Renato Golin61aed7f2015-06-17 19:12:50 +0000680 # Set the compiler using the CC and CXX environment variables to work around
681 # backslash string escaping bugs somewhere between buildbot and cmake. The
682 # env.exe helper is required to run the tests, so hopefully it's already on
683 # PATH.
684 cmake_cmd2 = ['env',
685 WithProperties('CC=%(workdir)s/'+stage1_install+'/bin/'+cc),
686 WithProperties('CXX=%(workdir)s/'+stage1_install+'/bin/'+cxx),
687 cmake, "-G", "Ninja", "../llvm",
688 "-DCMAKE_BUILD_TYPE="+stage2_config,
689 "-DLLVM_ENABLE_ASSERTIONS=True",
690 "-DLLVM_LIT_ARGS="+lit_args,
691 "-DCMAKE_INSTALL_PREFIX=../"+stage2_install] + extra_cmake_args
Reid Kleckner25a26b02015-03-09 22:30:25 +0000692
Renato Golin61aed7f2015-06-17 19:12:50 +0000693 f.addStep(ShellCommand(name='cmake stage 2',
694 command=cmake_cmd2,
695 haltOnFailure=True,
696 description='cmake stage 2',
697 workdir=stage2_build,
698 doStepIf=lambda step: step.build.getProperty("exists_ninja_2") != "OK",
699 env=env))
700
701 f.addStep(WarningCountingShellCommand(name='build stage 2',
702 command=ninja_cmd,
703 haltOnFailure=True,
704 description='ninja all',
705 workdir=stage2_build,
706 env=env))
707
708 if test:
709 f.addStep(lit_test_command.LitTestCommand(name='ninja check 2',
710 command=ninja_check_cmd,
711 haltOnFailure=not runTestSuite,
712 description=["checking stage 2"],
713 descriptionDone=["stage 2 checked"],
714 workdir=stage2_build,
715 env=env))
716
717 ############# TEST SUITE
718 ## Test-Suite (stage 2 if built, stage 1 otherwise)
719 if runTestSuite:
720 compiler_path = stage1_install
721 if useTwoStage:
722 compiler_path=stage2_install
723 f.addStep(ShellCommand(name='install stage 2',
724 command=ninja_install_cmd,
725 description='ninja install 2',
Renato Golincfbd5702014-09-06 19:09:16 +0000726 workdir=stage2_build,
727 env=env))
Renato Goline402f582014-09-04 19:25:24 +0000728
Renato Golin61aed7f2015-06-17 19:12:50 +0000729 # Get generated python, lnt
730 python = WithProperties('%(workdir)s/test/sandbox/bin/python')
731 lnt = WithProperties('%(workdir)s/test/sandbox/bin/lnt')
732 lnt_setup = WithProperties('%(workdir)s/test/lnt/setup.py')
733
734 # Paths
735 sandbox = WithProperties('%(workdir)s/test/sandbox')
736 test_suite_dir = WithProperties('%(workdir)s/test/test-suite')
737
738 # Get latest built Clang (stage1 or stage2)
739 cc = WithProperties('%(workdir)s/'+compiler_path+'/bin/'+cc)
740 cxx = WithProperties('%(workdir)s/'+compiler_path+'/bin/'+cxx)
741
Renato Golin593e0d62016-09-21 17:24:56 +0000742 # LNT Command line (don't pass -jN. Users need to pass both --threads
743 # and --build-threads in nt_flags to get the same effect)
Renato Golin61aed7f2015-06-17 19:12:50 +0000744 test_suite_cmd = [python, lnt, 'runtest', 'nt',
Renato Golin61aed7f2015-06-17 19:12:50 +0000745 '--no-timestamp',
746 '--sandbox', sandbox,
747 '--test-suite', test_suite_dir,
748 '--cc', cc,
749 '--cxx', cxx]
750 # Append any option provided by the user
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000751 test_suite_cmd.extend(nt_flags)
Renato Golin61aed7f2015-06-17 19:12:50 +0000752 # Only submit if a URL has been specified
753 if submitURL is not None:
754 if not isinstance(submitURL, list):
755 submitURL = [submitURL]
756 for url in submitURL:
757 test_suite_cmd.extend(['--submit', url])
758 if testerName:
759 test_suite_cmd.extend(['--no-machdep-info', testerName])
760 # CC and CXX are needed as env for build-tools
Renato Goline6c1b3b2015-07-01 15:52:22 +0000761 test_suite_env = copy.deepcopy(env)
Renato Golin61aed7f2015-06-17 19:12:50 +0000762 test_suite_env['CC'] = cc
763 test_suite_env['CXX'] = cxx
764
765 # Steps to prepare, build and run LNT
766 f.addStep(ShellCommand(name='clean sandbox',
767 command=['rm', '-rf', 'sandbox'],
768 haltOnFailure=True,
769 description='removing sandbox directory',
770 workdir='test',
771 env=env))
772 f.addStep(ShellCommand(name='recreate sandbox',
773 command=['virtualenv', 'sandbox'],
774 haltOnFailure=True,
775 description='recreating sandbox',
776 workdir='test',
777 env=env))
778 f.addStep(ShellCommand(name='setup lit',
779 command=[python, lnt_setup, 'develop'],
780 haltOnFailure=True,
781 description='setting up LNT in sandbox',
782 workdir='test/sandbox',
783 env=env))
784 f.addStep(commands.LitTestCommand.LitTestCommand(
785 name='test-suite',
786 command=test_suite_cmd,
787 haltOnFailure=True,
788 description=['running the test suite'],
789 workdir='test/sandbox',
790 logfiles={'configure.log' : 'build/configure.log',
791 'build-tools.log' : 'build/build-tools.log',
792 'test.log' : 'build/test.log',
793 'report.json' : 'build/report.json'},
794 env=test_suite_env))
795
Renato Goline402f582014-09-04 19:25:24 +0000796 return f
797
Daniel Dunbarc51a59e2010-09-23 14:57:45 +0000798def getClangMSVCBuildFactory(update=True, clean=True, vcDrive='c', jobs=1, cmake=r"cmake"):
Daniel Dunbar44abe742009-07-19 01:59:03 +0000799 f = buildbot.process.factory.BuildFactory()
800
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000801 if update:
Daniel Dunbar44abe742009-07-19 01:59:03 +0000802 f.addStep(SVN(name='svn-llvm',
803 mode='update', baseURL='http://llvm.org/svn/llvm-project/llvm/',
804 defaultBranch='trunk',
805 workdir='llvm'))
Daniel Dunbar44abe742009-07-19 01:59:03 +0000806 f.addStep(SVN(name='svn-clang',
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000807 mode='update', baseURL='http://llvm.org/svn/llvm-project/cfe/',
Daniel Dunbar44abe742009-07-19 01:59:03 +0000808 defaultBranch='trunk',
809 workdir='llvm/tools/clang'))
David Blaikie845ae0d2012-08-10 00:51:38 +0000810 f.addStep(SVN(name='svn-clang-tools-extra',
811 mode='update', baseURL='http://llvm.org/svn/llvm-project/clang-tools-extra/',
812 defaultBranch='trunk',
813 workdir='llvm/tools/clang/tools/extra'))
Daniel Dunbar44abe742009-07-19 01:59:03 +0000814
815 # Full & fast clean.
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000816 if clean:
Daniel Dunbar44abe742009-07-19 01:59:03 +0000817 f.addStep(ShellCommand(name='clean-1',
818 command=['del','/s/q','build'],
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000819 warnOnFailure=True,
Daniel Dunbar44abe742009-07-19 01:59:03 +0000820 description='cleaning',
821 descriptionDone='clean',
822 workdir='llvm'))
823 f.addStep(ShellCommand(name='clean-2',
824 command=['rmdir','/s/q','build'],
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000825 warnOnFailure=True,
Daniel Dunbar44abe742009-07-19 01:59:03 +0000826 description='cleaning',
827 descriptionDone='clean',
828 workdir='llvm'))
829
830 # Create the project files.
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000831
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000832 # Use batch files instead of ShellCommand directly, Windows quoting is
833 # borked. FIXME: See buildbot ticket #595 and buildbot ticket #377.
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000834 f.addStep(batch_file_download.BatchFileDownload(name='cmakegen',
Daniel Dunbar06b20f12010-04-08 18:29:38 +0000835 command=[cmake,
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000836 "-DLLVM_TARGETS_TO_BUILD:=X86",
Daniel Dunbar1ddedce2010-09-24 19:57:34 +0000837 "-DLLVM_INCLUDE_EXAMPLES:=OFF",
838 "-DLLVM_INCLUDE_TESTS:=OFF",
839 "-DLLVM_TARGETS_TO_BUILD:=X86",
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000840 "-G",
841 "Visual Studio 9 2008",
842 ".."],
843 workdir="llvm\\build"))
Daniel Dunbar44abe742009-07-19 01:59:03 +0000844 f.addStep(ShellCommand(name='cmake',
845 command=['cmakegen.bat'],
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000846 haltOnFailure=True,
Daniel Dunbar44abe742009-07-19 01:59:03 +0000847 description='cmake gen',
848 workdir='llvm\\build'))
849
850 # Build it.
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000851 f.addStep(batch_file_download.BatchFileDownload(name='vcbuild',
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000852 command=[vcDrive + r""":\Program Files\Microsoft Visual Studio 9.0\VC\VCPackages\vcbuild.exe""",
853 "/M%d" % jobs,
854 "LLVM.sln",
855 "Debug|Win32"],
856 workdir="llvm\\build"))
Daniel Dunbar44abe742009-07-19 01:59:03 +0000857 f.addStep(WarningCountingShellCommand(name='vcbuild',
858 command=['vcbuild.bat'],
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000859 haltOnFailure=True,
Daniel Dunbar44abe742009-07-19 01:59:03 +0000860 description='vcbuild',
861 workdir='llvm\\build',
862 warningPattern=" warning C.*:"))
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000863
864 # Build clang-test project.
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000865 f.addStep(batch_file_download.BatchFileDownload(name='vcbuild_test',
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000866 command=[vcDrive + r""":\Program Files\Microsoft Visual Studio 9.0\VC\VCPackages\vcbuild.exe""",
867 "clang-test.vcproj",
868 "Debug|Win32"],
869 workdir="llvm\\build\\tools\\clang\\test"))
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000870 f.addStep(lit_test_command.LitTestCommand(name='test-clang',
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000871 command=["vcbuild_test.bat"],
872 workdir="llvm\\build\\tools\\clang\\test"))
873
Daniel Dunbar44abe742009-07-19 01:59:03 +0000874 return f
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000875
Daniel Dunbar7363d032011-02-27 03:22:35 +0000876def addClangGCCTests(f, ignores={}, install_prefix="%(builddir)s/llvm.install",
877 languages = ('gcc', 'g++', 'objc', 'obj-c++')):
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000878 make_vars = [WithProperties(
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000879 'CC_UNDER_TEST=%s/bin/clang' % install_prefix),
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000880 WithProperties(
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000881 'CXX_UNDER_TEST=%s/bin/clang++' % install_prefix)]
David Blaikie05517332013-12-19 23:29:12 +0000882 f.addStep(SVN(name='svn-clang-gcc-tests', mode='update',
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000883 baseURL='http://llvm.org/svn/llvm-project/clang-tests/',
884 defaultBranch='trunk', workdir='clang-tests'))
885 gcc_dg_ignores = ignores.get('gcc-4_2-testsuite', {})
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000886 for lang in languages:
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000887 f.addStep(commands.SuppressionDejaGNUCommand.SuppressionDejaGNUCommand(
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000888 name='test-gcc-4_2-testsuite-%s' % lang,
889 command=["make", "-k", "check-%s" % lang] + make_vars,
890 description="gcc-4_2-testsuite (%s)" % lang,
891 workdir='clang-tests/gcc-4_2-testsuite',
David Dean2bd0c3a2011-10-18 16:36:28 +0000892 logfiles={ 'dg.sum' : 'obj/%s/%s.sum' % (lang, lang),
893 '%s.log' % lang : 'obj/%s/%s.log' % (lang, lang)},
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000894 ignore=gcc_dg_ignores.get(lang, [])))
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000895
Daniel Dunbar7363d032011-02-27 03:22:35 +0000896def addClangGDBTests(f, ignores={}, install_prefix="%(builddir)s/llvm.install"):
897 make_vars = [WithProperties(
898 'CC_UNDER_TEST=%s/bin/clang' % install_prefix),
899 WithProperties(
900 'CXX_UNDER_TEST=%s/bin/clang++' % install_prefix)]
David Blaikie05517332013-12-19 23:29:12 +0000901 f.addStep(SVN(name='svn-clang-gdb-tests', mode='update',
Daniel Dunbar7363d032011-02-27 03:22:35 +0000902 baseURL='http://llvm.org/svn/llvm-project/clang-tests/',
903 defaultBranch='trunk', workdir='clang-tests'))
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000904 f.addStep(commands.SuppressionDejaGNUCommand.SuppressionDejaGNUCommand(
Daniel Dunbar7363d032011-02-27 03:22:35 +0000905 name='test-gdb-1472-testsuite',
906 command=["make", "-k", "check"] + make_vars,
907 description="gdb-1472-testsuite",
908 workdir='clang-tests/gdb-1472-testsuite',
David Blaikie7ec695f2012-10-09 22:17:09 +0000909 logfiles={ 'dg.sum' : 'obj/filtered.gdb.sum',
David Blaikie624f4392012-11-05 22:34:35 +0000910 'gdb.log' : 'obj/gdb.log' }))
Daniel Dunbar7363d032011-02-27 03:22:35 +0000911
David Blaikie41d09c32013-01-02 21:11:09 +0000912def addModernClangGDBTests(f, jobs, install_prefix):
David Blaikie1bc5c372012-12-05 05:29:12 +0000913 make_vars = [WithProperties('RUNTESTFLAGS=CC_FOR_TARGET=\'{0}/bin/clang\' '
914 'CXX_FOR_TARGET=\'{0}/bin/clang++\' '
David Blaikie759bb752013-04-18 23:13:11 +0000915 'CFLAGS_FOR_TARGET=\'-w -fno-limit-debug-info\''
David Blaikief89877b2013-01-29 23:46:26 +0000916 .format(install_prefix))]
David Blaikie05517332013-12-19 23:29:12 +0000917 f.addStep(SVN(name='svn-clang-modern-gdb-tests', mode='update',
David Blaikief3f300b2012-11-17 01:13:41 +0000918 svnurl='http://llvm.org/svn/llvm-project/clang-tests-external/trunk/gdb/7.5',
David Blaikiedad03d52012-11-16 22:37:12 +0000919 workdir='clang-tests/src'))
David Blaikieb83bfdf2012-12-05 04:33:42 +0000920 f.addStep(Configure(command='../src/configure',
David Blaikief3f300b2012-11-17 01:13:41 +0000921 workdir='clang-tests/build/'))
David Blaikieb83bfdf2012-12-05 04:33:42 +0000922 f.addStep(WarningCountingShellCommand(name='gdb-75-build',
923 command=['make', WithProperties('-j%s' % jobs)],
924 haltOnFailure=True,
925 workdir='clang-tests/build'))
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000926 f.addStep(commands.DejaGNUCommand.DejaGNUCommand(
David Blaikiedad03d52012-11-16 22:37:12 +0000927 name='gdb-75-check',
David Blaikieb83bfdf2012-12-05 04:33:42 +0000928 command=['make', '-k', WithProperties('-j%s' % jobs), 'check'] + make_vars,
David Blaikiedad03d52012-11-16 22:37:12 +0000929 workdir='clang-tests/build',
David Blaikie1bc5c372012-12-05 05:29:12 +0000930 logfiles={'dg.sum':'gdb/testsuite/gdb.sum',
931 'gdb.log':'gdb/testsuite/gdb.log'}))
David Blaikiedad03d52012-11-16 22:37:12 +0000932
933
934
Daniel Dunbar7363d032011-02-27 03:22:35 +0000935# FIXME: Deprecated.
936addClangTests = addClangGCCTests
937
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000938def getClangTestsIgnoresFromPath(path, key):
939 def readList(path):
940 if not os.path.exists(path):
941 return []
942
943 f = open(path)
944 lines = [ln.strip() for ln in f]
945 f.close()
946 return lines
947
948 ignores = {}
949
950 gcc_dg_ignores = {}
951 for lang in ('gcc', 'g++', 'objc', 'obj-c++'):
952 lang_path = os.path.join(path, 'gcc-4_2-testsuite', 'expected_results',
953 key, lang)
954 gcc_dg_ignores[lang] = (
955 readList(os.path.join(lang_path, 'FAIL.txt')) +
956 readList(os.path.join(lang_path, 'UNRESOLVED.txt')) +
957 readList(os.path.join(lang_path, 'XPASS.txt')))
958 ignores['gcc-4_2-testsuite' ] = gcc_dg_ignores
959
Daniel Dunbar7363d032011-02-27 03:22:35 +0000960 ignores_path = os.path.join(path, 'gdb-1472-testsuite', 'expected_results',
961 key)
962 gdb_dg_ignores = (
963 readList(os.path.join(ignores_path, 'FAIL.txt')) +
964 readList(os.path.join(ignores_path, 'UNRESOLVED.txt')) +
965 readList(os.path.join(ignores_path, 'XPASS.txt')))
966 ignores['gdb-1472-testsuite' ] = gdb_dg_ignores
967
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000968 return ignores
David Deanf8b35442012-12-11 00:35:12 +0000969