blob: 1da290f545df990c2e990e10b42cf55a8b5f111c [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
Galina Kistanova49cbd602017-04-14 23:46:03 +000019from zorg.buildbot.conditions.FileConditions import FileDoesNotExist
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +000020
Galina Kistanovaf4d79352011-10-20 20:46:52 +000021def getClangBuildFactory(
22 triple=None,
23 clean=True,
24 test=True,
25 package_dst=None,
26 run_cxx_tests=False,
27 examples=False,
28 valgrind=False,
29 valgrindLeakCheck=False,
Galina Kistanovaf4d79352011-10-20 20:46:52 +000030 useTwoStage=False,
31 completely_clean=False,
Galina Kistanovaf4d79352011-10-20 20:46:52 +000032 make='make',
33 jobs="%(jobs)s",
34 stage1_config='Debug+Asserts',
35 stage2_config='Release+Asserts',
36 env={}, # Environmental variables for all steps.
37 extra_configure_args=[],
Vassil Vassilev5a9b9ed2016-05-25 17:10:03 +000038 stage2_extra_configure_args=[],
Galina Kistanovaf4d79352011-10-20 20:46:52 +000039 use_pty_in_tests=False,
Peter Collingbourned49ac282011-10-25 14:38:45 +000040 trunk_revision=None,
41 force_checkout=False,
Peter Collingbourne7a95b0c2011-10-26 16:40:17 +000042 extra_clean_step=None,
David Blaikiea76da842012-08-13 22:24:46 +000043 checkout_compiler_rt=False,
Galina Kistanova2ab1e2d2016-11-22 00:23:43 +000044 checkout_lld=False,
David Blaikiea76da842012-08-13 22:24:46 +000045 run_gdb=False,
David Blaikiedad03d52012-11-16 22:37:12 +000046 run_modern_gdb=False,
Vassil Vassilev0c647ef2016-06-30 21:16:45 +000047 run_gcc=False):
Galina Kistanovaf4d79352011-10-20 20:46:52 +000048 # Prepare environmental variables. Set here all env we want everywhere.
49 merged_env = {
50 'TERM' : 'dumb' # Make sure Clang doesn't use color escape sequences.
51 }
52 if env is not None:
53 # Overwrite pre-set items with the given ones, so user can set anything.
54 merged_env.update(env)
David Blaikie2f7eb282012-08-24 18:37:00 +000055
Jonathan Roelofs62415e52015-02-28 00:03:17 +000056 llvm_srcdir = "llvm.src"
57 llvm_1_objdir = "llvm.obj"
58 llvm_1_installdir = "llvm.install.1"
59 llvm_2_objdir = "llvm.obj.2"
60 llvm_2_installdir = "llvm.install"
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +000061
Daniel Dunbar235aa412009-07-18 07:16:15 +000062 f = buildbot.process.factory.BuildFactory()
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +000063
64 # Determine the build directory.
65 f.addStep(buildbot.steps.shell.SetProperty(name="get_builddir",
66 command=["pwd"],
67 property="builddir",
68 description="set build dir",
Galina Kistanovaf4d79352011-10-20 20:46:52 +000069 workdir=".",
70 env=merged_env))
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +000071
Daniel Dunbar06b20f12010-04-08 18:29:38 +000072 # Blow away completely, if requested.
73 if completely_clean:
74 f.addStep(ShellCommand(name="rm-llvm.src",
75 command=["rm", "-rf", llvm_srcdir],
76 haltOnFailure=True,
77 description=["rm src dir", "llvm"],
Galina Kistanovaf4d79352011-10-20 20:46:52 +000078 workdir=".",
79 env=merged_env))
Daniel Dunbar06b20f12010-04-08 18:29:38 +000080
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +000081 # Checkout sources.
Peter Collingbourned49ac282011-10-25 14:38:45 +000082 if trunk_revision:
83 # The SVN build step provides no mechanism to check out a specific revision
84 # based on a property, so just run the commands directly here.
85 svn_co = ['svn', 'checkout']
86 if force_checkout:
87 svn_co += ['--force']
88 svn_co += ['--revision', WithProperties(trunk_revision)]
89
90 svn_co_llvm = svn_co + \
91 [WithProperties('http://llvm.org/svn/llvm-project/llvm/trunk@%s' %
92 trunk_revision),
93 llvm_srcdir]
94 svn_co_clang = svn_co + \
95 [WithProperties('http://llvm.org/svn/llvm-project/cfe/trunk@%s' %
96 trunk_revision),
97 '%s/tools/clang' % llvm_srcdir]
David Blaikie845ae0d2012-08-10 00:51:38 +000098 svn_co_clang_tools_extra = svn_co + \
99 [WithProperties('http://llvm.org/svn/llvm-project/clang-tools-extra/trunk@%s' %
100 trunk_revision),
101 '%s/tools/clang/tools/extra' % llvm_srcdir]
Peter Collingbourned49ac282011-10-25 14:38:45 +0000102
103 f.addStep(ShellCommand(name='svn-llvm',
104 command=svn_co_llvm,
105 haltOnFailure=True,
106 workdir='.'))
107 f.addStep(ShellCommand(name='svn-clang',
108 command=svn_co_clang,
109 haltOnFailure=True,
110 workdir='.'))
David Blaikie845ae0d2012-08-10 00:51:38 +0000111 f.addStep(ShellCommand(name='svn-clang-tools-extra',
112 command=svn_co_clang_tools_extra,
113 haltOnFailure=True,
114 workdir='.'))
Peter Collingbourned49ac282011-10-25 14:38:45 +0000115 else:
116 f.addStep(SVN(name='svn-llvm',
Daniel Dunbarf4e23eb2010-09-20 21:13:02 +0000117 mode='update',
Peter Collingbourned49ac282011-10-25 14:38:45 +0000118 baseURL='http://llvm.org/svn/llvm-project/llvm/',
Daniel Dunbarf4e23eb2010-09-20 21:13:02 +0000119 defaultBranch='trunk',
Peter Collingbourned49ac282011-10-25 14:38:45 +0000120 workdir=llvm_srcdir))
121 f.addStep(SVN(name='svn-clang',
122 mode='update',
123 baseURL='http://llvm.org/svn/llvm-project/cfe/',
124 defaultBranch='trunk',
125 workdir='%s/tools/clang' % llvm_srcdir))
David Blaikie845ae0d2012-08-10 00:51:38 +0000126 f.addStep(SVN(name='svn-clang-tools-extra',
127 mode='update',
128 baseURL='http://llvm.org/svn/llvm-project/clang-tools-extra/',
129 defaultBranch='trunk',
130 workdir='%s/tools/clang/tools/extra' % llvm_srcdir))
Peter Collingbourned49ac282011-10-25 14:38:45 +0000131 if checkout_compiler_rt:
132 f.addStep(SVN(name='svn-compiler-rt',
133 mode='update',
134 baseURL='http://llvm.org/svn/llvm-project/compiler-rt/',
135 defaultBranch='trunk',
136 workdir='%s/projects/compiler-rt' % llvm_srcdir))
Daniel Dunbarfa0e0222009-11-09 06:08:28 +0000137
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000138 # Clean up llvm (stage 1); unless in-dir.
139 if clean and llvm_srcdir != llvm_1_objdir:
140 f.addStep(ShellCommand(name="rm-llvm.obj.stage1",
141 command=["rm", "-rf", llvm_1_objdir],
142 haltOnFailure=True,
143 description=["rm build dir", "llvm"],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000144 workdir=".",
145 env=merged_env))
Andrew Trick70fa9d22011-08-25 23:38:51 +0000146
David Blaikie8cbf62f2013-01-12 21:32:31 +0000147 if not clean:
Galina Kistanovaa06e4c82016-04-14 21:41:30 +0000148 expected_makefile = 'Makefile'
David Blaikie8cbf62f2013-01-12 21:32:31 +0000149 f.addStep(SetProperty(name="Makefile_isready",
150 workdir=llvm_1_objdir,
151 command=["sh", "-c",
Richard Smith02389162014-09-26 23:53:06 +0000152 "test -e %s && echo OK || echo Missing" % expected_makefile],
David Blaikie8cbf62f2013-01-12 21:32:31 +0000153 flunkOnFailure=False,
Galina Kistanovaa06e4c82016-04-14 21:41:30 +0000154 property="exists_Makefile"))
Richard Smith02389162014-09-26 23:53:06 +0000155
Galina Kistanovaa06e4c82016-04-14 21:41:30 +0000156 cmake_triple_arg = []
157 if triple:
158 cmake_triple_arg = ['-DLLVM_HOST_TRIPLE=%s' % triple]
159 f.addStep(ShellCommand(name='cmake',
160 command=['cmake',
161 '-DLLVM_BUILD_TESTS=ON',
162 '-DCMAKE_BUILD_TYPE=%s' % stage1_config] +
163 cmake_triple_arg +
164 extra_configure_args +
165 ["../" + llvm_srcdir],
166 description='cmake stage1',
167 workdir=llvm_1_objdir,
168 env=merged_env,
169 doStepIf=lambda step: step.build.getProperty("exists_Makefile") != "OK"))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000170
171 # Make clean if using in-dir builds.
172 if clean and llvm_srcdir == llvm_1_objdir:
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000173 f.addStep(WarningCountingShellCommand(name="clean-llvm",
Daniel Dunbard20468a2009-11-24 18:27:23 +0000174 command=[make, "clean"],
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000175 haltOnFailure=True,
176 description="cleaning llvm",
177 descriptionDone="clean llvm",
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000178 workdir=llvm_1_objdir,
Peter Collingbourne7a95b0c2011-10-26 16:40:17 +0000179 doStepIf=clean,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000180 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000181
Peter Collingbourne7a95b0c2011-10-26 16:40:17 +0000182 if extra_clean_step:
183 f.addStep(extra_clean_step)
184
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000185 f.addStep(WarningCountingShellCommand(name="compile",
Daniel Dunbard20468a2009-11-24 18:27:23 +0000186 command=['nice', '-n', '10',
187 make, WithProperties("-j%s" % jobs)],
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000188 haltOnFailure=True,
David Blaikie05517332013-12-19 23:29:12 +0000189 flunkOnFailure=not run_gdb,
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000190 description=["compiling", stage1_config],
191 descriptionDone=["compile", stage1_config],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000192 workdir=llvm_1_objdir,
193 env=merged_env))
Daniel Dunbar256fed42009-11-25 21:11:08 +0000194
195 if examples:
196 f.addStep(WarningCountingShellCommand(name="compile.examples",
197 command=['nice', '-n', '10',
198 make, WithProperties("-j%s" % jobs),
199 "BUILD_EXAMPLES=1"],
200 haltOnFailure=True,
Richard Smith65e6f5d2014-09-25 18:18:35 +0000201 description=["compiling", stage1_config, "examples"],
Daniel Dunbar256fed42009-11-25 21:11:08 +0000202 descriptionDone=["compile", stage1_config, "examples"],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000203 workdir=llvm_1_objdir,
204 env=merged_env))
Daniel Dunbar256fed42009-11-25 21:11:08 +0000205
NAKAMURA Takumi1a4666b2013-01-19 03:39:07 +0000206 clangTestArgs = '-v -j %s' % jobs
Daniel Dunbarfa0e0222009-11-09 06:08:28 +0000207 if valgrind:
Daniel Dunbar89184b92010-04-18 19:09:32 +0000208 clangTestArgs += ' --vg'
Daniel Dunbara1bebce2010-03-21 01:24:00 +0000209 if valgrindLeakCheck:
210 clangTestArgs += ' --vg-leak'
Nick Lewycky8d26e472011-08-27 21:18:56 +0000211 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 +0000212 extraTestDirs = ''
213 if run_cxx_tests:
214 extraTestDirs += '%(builddir)s/llvm/tools/clang/utils/C++Tests'
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000215 if test:
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000216 f.addStep(lit_test_command.LitTestCommand(name='check-all',
David Blaikie7e6f8a12012-08-31 20:46:27 +0000217 command=[make, "check-all", "VERBOSE=1",
NAKAMURA Takumi1a4666b2013-01-19 03:39:07 +0000218 WithProperties("LIT_ARGS=%s" % clangTestArgs),
David Blaikiebc684012012-12-27 20:44:19 +0000219 WithProperties("EXTRA_TESTDIRS=%s" % extraTestDirs)],
David Blaikie05517332013-12-19 23:29:12 +0000220 flunkOnFailure=not run_gdb,
David Blaikie7e6f8a12012-08-31 20:46:27 +0000221 description=["checking"],
222 descriptionDone=["checked"],
Daniel Dunbar469e8ca2010-05-19 21:26:48 +0000223 workdir=llvm_1_objdir,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000224 usePTY=use_pty_in_tests,
225 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000226
Galina Kistanovaa06e4c82016-04-14 21:41:30 +0000227 # TODO: Install llvm and clang for stage1.
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000228
David Blaikiedad03d52012-11-16 22:37:12 +0000229 if run_gdb or run_gcc or run_modern_gdb:
David Blaikiea76da842012-08-13 22:24:46 +0000230 ignores = getClangTestsIgnoresFromPath(os.path.expanduser('~/public/clang-tests'), 'clang-x86_64-darwin10')
231 install_prefix = "%%(builddir)s/%s" % llvm_1_installdir
232 if run_gdb:
233 addClangGDBTests(f, ignores, install_prefix)
David Blaikiedad03d52012-11-16 22:37:12 +0000234 if run_modern_gdb:
David Blaikie41d09c32013-01-02 21:11:09 +0000235 addModernClangGDBTests(f, jobs, install_prefix)
David Blaikiea76da842012-08-13 22:24:46 +0000236 if run_gcc:
237 addClangGCCTests(f, ignores, install_prefix)
238
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000239 if not useTwoStage:
Daniel Dunbardedf6572010-11-13 00:23:34 +0000240 if package_dst:
241 name = WithProperties(
242 "%(builddir)s/" + llvm_1_objdir +
243 "/clang-r%(got_revision)s-b%(buildnumber)s.tgz")
244 f.addStep(ShellCommand(name='pkg.tar',
245 description="tar root",
246 command=["tar", "zcvf", name, "./"],
247 workdir=llvm_1_installdir,
248 warnOnFailure=True,
249 flunkOnFailure=False,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000250 haltOnFailure=False,
251 env=merged_env))
Daniel Dunbardedf6572010-11-13 00:23:34 +0000252 f.addStep(ShellCommand(name='pkg.upload',
Andrew Trick70fa9d22011-08-25 23:38:51 +0000253 description="upload root",
Daniel Dunbardedf6572010-11-13 00:23:34 +0000254 command=["scp", name,
255 WithProperties(
256 package_dst + "/%(buildername)s")],
257 workdir=".",
258 warnOnFailure=True,
259 flunkOnFailure=False,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000260 haltOnFailure=False,
261 env=merged_env))
Daniel Dunbardedf6572010-11-13 00:23:34 +0000262
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000263 return f
264
265 # Clean up llvm (stage 2).
Richard Smith02389162014-09-26 23:53:06 +0000266 #
Galina Kistanova79900972015-11-16 17:30:42 +0000267 # We always cleanly build the stage 2. If the compiler has been
268 # changed on the stage 1, we cannot trust any of the intermediate file
269 # from the old compiler. And if the stage 1 compiler is the same, we should
270 # not build in the first place.
271 f.addStep(ShellCommand(name="rm-llvm.obj.stage2",
272 command=["rm", "-rf", llvm_2_objdir],
273 haltOnFailure=True,
274 description=["rm build dir", "llvm", "(stage 2)"],
275 workdir=".",
276 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000277
278 # Configure llvm (stage 2).
Galina Kistanovaa06e4c82016-04-14 21:41:30 +0000279 f.addStep(ShellCommand(name='cmake',
Vassil Vassilev5a9b9ed2016-05-25 17:10:03 +0000280 command=['cmake'] + stage2_extra_configure_args + [
Galina Kistanovaa06e4c82016-04-14 21:41:30 +0000281 '-DLLVM_BUILD_TESTS=ON',
282 WithProperties('-DCMAKE_C_COMPILER=%%(builddir)s/%s/bin/clang' % llvm_1_objdir), # FIXME use installdir
283 WithProperties('-DCMAKE_CXX_COMPILER=%%(builddir)s/%s/bin/clang++' % llvm_1_objdir),
284 '-DCMAKE_BUILD_TYPE=%s' % stage2_config,
Galina Kistanovaa06e4c82016-04-14 21:41:30 +0000285 "../" + llvm_srcdir],
286 description='cmake stage2',
287 workdir=llvm_2_objdir,
288 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000289
290 # Build llvm (stage 2).
291 f.addStep(WarningCountingShellCommand(name="compile.llvm.stage2",
292 command=['nice', '-n', '10',
293 make, WithProperties("-j%s" % jobs)],
294 haltOnFailure=True,
295 description=["compiling", "(stage 2)",
296 stage2_config],
297 descriptionDone=["compile", "(stage 2)",
298 stage2_config],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000299 workdir=llvm_2_objdir,
300 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000301
302 if test:
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000303 f.addStep(lit_test_command.LitTestCommand(name='check-all',
David Blaikie7e6f8a12012-08-31 20:46:27 +0000304 command=[make, "check-all", "VERBOSE=1",
NAKAMURA Takumi1a4666b2013-01-19 03:39:07 +0000305 WithProperties("LIT_ARGS=%s" % clangTestArgs),
David Blaikiebc684012012-12-27 20:44:19 +0000306 WithProperties("EXTRA_TESTDIRS=%s" % extraTestDirs)],
David Blaikie7e6f8a12012-08-31 20:46:27 +0000307 description=["checking"],
308 descriptionDone=["checked"],
Daniel Dunbar469e8ca2010-05-19 21:26:48 +0000309 workdir=llvm_2_objdir,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000310 usePTY=use_pty_in_tests,
311 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000312
Galina Kistanovaa06e4c82016-04-14 21:41:30 +0000313 # TODO: Install llvm and clang for stage2.
Daniel Dunbar3efb7822010-02-26 19:20:00 +0000314
315 if package_dst:
316 name = WithProperties(
317 "%(builddir)s/" + llvm_2_objdir +
318 "/clang-r%(got_revision)s-b%(buildnumber)s.tgz")
319 f.addStep(ShellCommand(name='pkg.tar',
320 description="tar root",
321 command=["tar", "zcvf", name, "./"],
322 workdir=llvm_2_installdir,
323 warnOnFailure=True,
324 flunkOnFailure=False,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000325 haltOnFailure=False,
326 env=merged_env))
Daniel Dunbar3efb7822010-02-26 19:20:00 +0000327 f.addStep(ShellCommand(name='pkg.upload',
Andrew Trick70fa9d22011-08-25 23:38:51 +0000328 description="upload root",
Daniel Dunbar3efb7822010-02-26 19:20:00 +0000329 command=["scp", name,
330 WithProperties(
331 package_dst + "/%(buildername)s")],
332 workdir=".",
333 warnOnFailure=True,
334 flunkOnFailure=False,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000335 haltOnFailure=False,
336 env=merged_env))
Daniel Dunbar3efb7822010-02-26 19:20:00 +0000337
Daniel Dunbar235aa412009-07-18 07:16:15 +0000338 return f
Daniel Dunbar44abe742009-07-19 01:59:03 +0000339
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000340def addSVNUpdateSteps(f,
341 checkout_clang_tools_extra,
342 checkout_compiler_rt,
Renato Golin0bd2a532016-11-20 16:14:35 +0000343 checkout_test_suite,
Artem Belevich16fcd0e2016-12-21 21:15:56 +0000344 checkout_lld,
345 checkout_libcxx):
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000346 # We *must* checkout at least Clang+LLVM
347 f.addStep(SVN(name='svn-llvm',
348 mode='update', baseURL='http://llvm.org/svn/llvm-project/llvm/',
349 defaultBranch='trunk',
350 workdir='llvm'))
351 f.addStep(SVN(name='svn-clang',
352 mode='update', baseURL='http://llvm.org/svn/llvm-project/cfe/',
353 defaultBranch='trunk',
354 workdir='llvm/tools/clang'))
355
356 # Extra stuff that will be built/tested
357 if checkout_clang_tools_extra:
358 f.addStep(SVN(name='svn-clang-tools-extra',
359 mode='update', baseURL='http://llvm.org/svn/llvm-project/clang-tools-extra/',
360 defaultBranch='trunk',
361 workdir='llvm/tools/clang/tools/extra'))
362 if checkout_compiler_rt:
363 f.addStep(SVN(name='svn-compiler-rt',
364 mode='update', baseURL='http://llvm.org/svn/llvm-project/compiler-rt/',
365 defaultBranch='trunk',
366 workdir='llvm/projects/compiler-rt'))
367 if checkout_test_suite:
368 f.addStep(SVN(name='svn-lnt',
369 mode='update', baseURL='http://llvm.org/svn/llvm-project/lnt/',
370 defaultBranch='trunk',
371 workdir='test/lnt'))
372 f.addStep(SVN(name='svn-test-suite',
373 mode='update', baseURL='http://llvm.org/svn/llvm-project/test-suite/',
374 defaultBranch='trunk',
375 workdir='test/test-suite'))
Renato Golin0bd2a532016-11-20 16:14:35 +0000376 if checkout_lld:
377 f.addStep(SVN(name='svn-lld',
378 mode='update', baseURL='http://llvm.org/svn/llvm-project/lld/',
379 defaultBranch='trunk',
380 workdir='llvm/tools/lld'))
Artem Belevich16fcd0e2016-12-21 21:15:56 +0000381 if checkout_libcxx:
382 f.addStep(SVN(name='svn-libcxx',
383 mode='update',
384 baseURL='http://llvm.org/svn/llvm-project/libcxx/',
385 defaultBranch='trunk',
386 workdir='llvm/projects/libcxx'))
387 f.addStep(SVN(name='svn-libcxxabi',
388 mode='update',
389 baseURL='http://llvm.org/svn/llvm-project/libcxxabi/',
390 defaultBranch='trunk',
391 workdir='llvm/projects/libcxxabi'))
392 f.addStep(SVN(name='svn-libunwind',
393 mode='update',
394 baseURL='http://llvm.org/svn/llvm-project/libunwind/',
395 defaultBranch='trunk',
396 workdir='llvm/projects/libunwind'))
Renato Goline402f582014-09-04 19:25:24 +0000397
Daniel Sandersfa222332015-12-04 14:30:39 +0000398def addGCSUploadSteps(f, package_name, install_prefix, gcs_directory, env,
399 gcs_url_property=None):
400 """
401 Add steps to upload to the Google Cloud Storage bucket.
402
403 f - The BuildFactory to modify.
404 package_name - The name of this package for the descriptions (e.g.
405 'stage 1')
406 install_prefix - The directory the build has been installed to.
407 gcs_directory - The subdirectory of the bucket root to upload to. This
408 should match the builder name.
409 env - The environment to use. Set BOTO_CONFIG to use a configuration file
410 in a non-standard location, and BUCKET to use a different GCS bucket.
411 gcs_url_property - Property to assign the GCS url to.
412 """
413
414 gcs_url_fmt = ('gs://%(gcs_bucket)s/%(gcs_directory)s/'
415 'clang-r%(got_revision)s-t%(now)s-b%(buildnumber)s.tar.xz')
416 time_fmt = '%Y-%m-%d_%H-%M-%S'
417 gcs_url = \
418 WithProperties(
419 gcs_url_fmt,
420 gcs_bucket=lambda _: env.get('BUCKET', 'llvm-build-artifacts'),
421 gcs_directory=lambda _: gcs_directory,
422 now=lambda _: datetime.utcnow().strftime(time_fmt))
423
424 if gcs_url_property:
425 f.addStep(SetProperty(
426 name="record GCS url for " + package_name,
427 command=['echo', gcs_url],
428 property=gcs_url_property))
429
430 f.addStep(ShellCommand(name='package ' + package_name,
431 command=['tar', 'cvfJ', '../install.tar.xz', '.'],
432 description='packaging ' + package_name + '...',
433 workdir=install_prefix,
434 env=env))
435
436 f.addStep(ShellCommand(
437 name='upload ' + package_name + ' to storage bucket',
438 command=['gsutil', 'cp', '../install.tar.xz', gcs_url],
439 description=('uploading ' + package_name +
440 'to storage bucket ...'),
441 workdir=install_prefix,
442 env=env))
443
444def getClangCMakeGCSBuildFactory(
445 clean=True,
446 test=True,
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000447 cmake='cmake',
Daniel Sandersfa222332015-12-04 14:30:39 +0000448 jobs=None,
449
450 # VS tools environment variable if using MSVC. For example,
451 # %VS120COMNTOOLS% selects the 2013 toolchain.
452 vs=None,
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000453 vs_target_arch='x86',
Daniel Sandersfa222332015-12-04 14:30:39 +0000454
455 # Multi-stage compilation
456 useTwoStage=False,
457 testStage1=True,
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000458 stage1_config='Release',
459 stage2_config='Release',
Daniel Sandersfa222332015-12-04 14:30:39 +0000460
461 # Test-suite
462 runTestSuite=False,
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000463 nt_flags=[],
Daniel Sandersfa222332015-12-04 14:30:39 +0000464 submitURL=None,
465 testerName=None,
466
467 # Environmental variables for all steps.
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000468 env={},
469 extra_cmake_args=[],
Daniel Sandersfa222332015-12-04 14:30:39 +0000470
471 # Extra repositories
472 checkout_clang_tools_extra=True,
473 checkout_compiler_rt=True,
Renato Golin0bd2a532016-11-20 16:14:35 +0000474 checkout_lld=True,
Daniel Sandersfa222332015-12-04 14:30:39 +0000475
476 # Upload artifacts to Google Cloud Storage (for the llvmbisect tool)
477 stage1_upload_directory=None,
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000478
479 # Triggers
480 trigger_after_stage1=[]):
Daniel Sandersfa222332015-12-04 14:30:39 +0000481 return _getClangCMakeBuildFactory(
482 clean=clean, test=test, cmake=cmake, jobs=jobs, vs=vs,
483 vs_target_arch=vs_target_arch, useTwoStage=useTwoStage,
484 testStage1=testStage1, stage1_config=stage1_config,
485 stage2_config=stage2_config, runTestSuite=runTestSuite,
486 nt_flags=nt_flags, submitURL=submitURL, testerName=testerName,
487 env=env, extra_cmake_args=extra_cmake_args,
488 checkout_clang_tools_extra=checkout_clang_tools_extra,
489 checkout_compiler_rt=checkout_compiler_rt,
Renato Golin0bd2a532016-11-20 16:14:35 +0000490 checkout_lld=checkout_lld,
Daniel Sandersfa222332015-12-04 14:30:39 +0000491 stage1_upload_directory=stage1_upload_directory,
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000492 trigger_after_stage1=trigger_after_stage1)
Reid Kleckner25a26b02015-03-09 22:30:25 +0000493
494def getClangCMakeBuildFactory(
495 clean=True,
496 test=True,
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000497 cmake='cmake',
Reid Kleckner25a26b02015-03-09 22:30:25 +0000498 jobs=None,
499
500 # VS tools environment variable if using MSVC. For example,
501 # %VS120COMNTOOLS% selects the 2013 toolchain.
502 vs=None,
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000503 vs_target_arch='x86',
Reid Kleckner25a26b02015-03-09 22:30:25 +0000504
505 # Multi-stage compilation
506 useTwoStage=False,
507 testStage1=True,
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000508 stage1_config='Release',
509 stage2_config='Release',
Reid Kleckner25a26b02015-03-09 22:30:25 +0000510
Renato Golin61aed7f2015-06-17 19:12:50 +0000511 # Test-suite
512 runTestSuite=False,
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000513 nt_flags=[],
Renato Golin61aed7f2015-06-17 19:12:50 +0000514 submitURL=None,
515 testerName=None,
516
Reid Kleckner25a26b02015-03-09 22:30:25 +0000517 # Environmental variables for all steps.
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000518 env={},
519 extra_cmake_args=[],
Reid Kleckner25a26b02015-03-09 22:30:25 +0000520
521 # Extra repositories
522 checkout_clang_tools_extra=True,
Renato Golin0bd2a532016-11-20 16:14:35 +0000523 checkout_compiler_rt=True,
Artem Belevich16fcd0e2016-12-21 21:15:56 +0000524 checkout_lld=True,
525 checkout_libcxx=False,
526 checkout_test_suite=False):
Daniel Sandersfa222332015-12-04 14:30:39 +0000527 return _getClangCMakeBuildFactory(
528 clean=clean, test=test, cmake=cmake, jobs=jobs, vs=vs,
529 vs_target_arch=vs_target_arch, useTwoStage=useTwoStage,
530 testStage1=testStage1, stage1_config=stage1_config,
531 stage2_config=stage2_config, runTestSuite=runTestSuite,
532 nt_flags=nt_flags, submitURL=submitURL, testerName=testerName,
533 env=env, extra_cmake_args=extra_cmake_args,
534 checkout_clang_tools_extra=checkout_clang_tools_extra,
Renato Golin0bd2a532016-11-20 16:14:35 +0000535 checkout_lld=checkout_lld,
Artem Belevich16fcd0e2016-12-21 21:15:56 +0000536 checkout_compiler_rt=checkout_compiler_rt,
537 checkout_libcxx=checkout_libcxx,
538 checkout_test_suite=checkout_test_suite)
Daniel Sandersfa222332015-12-04 14:30:39 +0000539
540def _getClangCMakeBuildFactory(
541 clean=True,
542 test=True,
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000543 cmake='cmake',
Daniel Sandersfa222332015-12-04 14:30:39 +0000544 jobs=None,
545
546 # VS tools environment variable if using MSVC. For example,
547 # %VS120COMNTOOLS% selects the 2013 toolchain.
548 vs=None,
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000549 vs_target_arch='x86',
Daniel Sandersfa222332015-12-04 14:30:39 +0000550
551 # Multi-stage compilation
552 useTwoStage=False,
553 testStage1=True,
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000554 stage1_config='Release',
555 stage2_config='Release',
Daniel Sandersfa222332015-12-04 14:30:39 +0000556
557 # Test-suite
558 runTestSuite=False,
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000559 nt_flags=[],
Daniel Sandersfa222332015-12-04 14:30:39 +0000560 submitURL=None,
561 testerName=None,
562
563 # Environmental variables for all steps.
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000564 env={},
565 extra_cmake_args=[],
Daniel Sandersfa222332015-12-04 14:30:39 +0000566
567 # Extra repositories
568 checkout_clang_tools_extra=True,
569 checkout_compiler_rt=True,
Renato Golin0bd2a532016-11-20 16:14:35 +0000570 checkout_lld=True,
Artem Belevich16fcd0e2016-12-21 21:15:56 +0000571 checkout_libcxx=False,
572 checkout_test_suite=False,
Daniel Sandersfa222332015-12-04 14:30:39 +0000573
574 # Upload artifacts to Google Cloud Storage (for the llvmbisect tool)
575 stage1_upload_directory=None,
576
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000577 # Triggers
578 trigger_after_stage1=[]):
Reid Kleckner25a26b02015-03-09 22:30:25 +0000579
580 ############# PREPARING
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000581 f = buildbot.process.factory.BuildFactory()
Reid Kleckner25a26b02015-03-09 22:30:25 +0000582
Galina Kistanova49cbd602017-04-14 23:46:03 +0000583 clean_build_requested = lambda step: clean or step.build.getProperty("clean")
584
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000585 addSVNUpdateSteps(f,
586 checkout_clang_tools_extra=checkout_clang_tools_extra,
587 checkout_compiler_rt=checkout_compiler_rt,
Renato Golin0bd2a532016-11-20 16:14:35 +0000588 checkout_lld=checkout_lld,
Artem Belevich16fcd0e2016-12-21 21:15:56 +0000589 checkout_test_suite=runTestSuite or checkout_test_suite,
590 checkout_libcxx=checkout_libcxx)
Reid Kleckner25a26b02015-03-09 22:30:25 +0000591
Renato Goline402f582014-09-04 19:25:24 +0000592 # If jobs not defined, Ninja will choose a suitable value
Renato Golincc83db32015-06-17 19:23:40 +0000593 jobs_cmd = []
594 lit_args = "'-v"
Renato Goline402f582014-09-04 19:25:24 +0000595 if jobs is not None:
Renato Golincc83db32015-06-17 19:23:40 +0000596 jobs_cmd = ["-j"+str(jobs)]
597 lit_args += " -j"+str(jobs)+"'"
Renato Goline402f582014-09-04 19:25:24 +0000598 else:
Renato Golincc83db32015-06-17 19:23:40 +0000599 lit_args += "'"
600 ninja_cmd = ['ninja'] + jobs_cmd
601 ninja_install_cmd = ['ninja', 'install'] + jobs_cmd
602 ninja_check_cmd = ['ninja', 'check-all'] + jobs_cmd
Renato Goline402f582014-09-04 19:25:24 +0000603
604 # Global configurations
Renato Golincc83db32015-06-17 19:23:40 +0000605 stage1_build = 'stage1'
606 stage1_install = 'stage1.install'
607 stage2_build = 'stage2'
608 stage2_install = 'stage2.install'
Renato Goline402f582014-09-04 19:25:24 +0000609
Reid Kleckner25a26b02015-03-09 22:30:25 +0000610 # Set up VS environment, if appropriate.
611 if vs:
612 f.addStep(SetProperty(
613 command=builders_util.getVisualStudioEnvironment(vs, vs_target_arch),
614 extract_fn=builders_util.extractSlaveEnvironment))
615 assert not env, "Can't have custom builder env vars with VS"
616 env = Property('slave_env')
617
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000618
Renato Goline402f582014-09-04 19:25:24 +0000619 ############# CLEANING
Galina Kistanova49cbd602017-04-14 23:46:03 +0000620 f.addStep(ShellCommand(name='clean stage 1',
621 command=['rm','-rf',stage1_build],
622 warnOnFailure=True,
623 haltOnFailure=False,
624 flunkOnFailure=False,
625 description='cleaning stage 1',
626 descriptionDone='clean',
627 workdir='.',
628 doStepIf=clean_build_requested))
Renato Goline402f582014-09-04 19:25:24 +0000629
630
631 ############# STAGE 1
632 f.addStep(ShellCommand(name='cmake stage 1',
633 command=[cmake, "-G", "Ninja", "../llvm",
634 "-DCMAKE_BUILD_TYPE="+stage1_config,
635 "-DLLVM_ENABLE_ASSERTIONS=True",
636 "-DLLVM_LIT_ARGS="+lit_args,
637 "-DCMAKE_INSTALL_PREFIX=../"+stage1_install]
638 + extra_cmake_args,
639 haltOnFailure=True,
640 description='cmake stage 1',
641 workdir=stage1_build,
Galina Kistanova49cbd602017-04-14 23:46:03 +0000642 doStepIf=FileDoesNotExist("build.ninja"),
Renato Goline402f582014-09-04 19:25:24 +0000643 env=env))
644
645 f.addStep(WarningCountingShellCommand(name='build stage 1',
646 command=ninja_cmd,
647 haltOnFailure=True,
648 description='ninja all',
649 workdir=stage1_build,
650 env=env))
651
652 if test and testStage1:
Renato Golind1c46742015-08-06 18:05:34 +0000653 haltOnStage1Check = not useTwoStage and not runTestSuite
Renato Golincfbd5702014-09-06 19:09:16 +0000654 f.addStep(lit_test_command.LitTestCommand(name='ninja check 1',
655 command=ninja_check_cmd,
Renato Golind1c46742015-08-06 18:05:34 +0000656 haltOnFailure=haltOnStage1Check,
Renato Golincfbd5702014-09-06 19:09:16 +0000657 description=["checking stage 1"],
658 descriptionDone=["stage 1 checked"],
659 workdir=stage1_build,
660 env=env))
Renato Goline402f582014-09-04 19:25:24 +0000661
Daniel Sandersfa222332015-12-04 14:30:39 +0000662 if useTwoStage or runTestSuite or stage1_upload_directory:
Galina Kistanova49cbd602017-04-14 23:46:03 +0000663 f.addStep(ShellCommand(name='clean stage 1 install',
664 command=['rm','-rf',stage1_install],
665 warnOnFailure=True,
666 haltOnFailure=False,
667 flunkOnFailure=False,
668 description='cleaning stage 1 install',
669 descriptionDone='clean',
670 workdir='.'))
Renato Golin61aed7f2015-06-17 19:12:50 +0000671 f.addStep(ShellCommand(name='install stage 1',
672 command=ninja_install_cmd,
673 description='ninja install',
674 workdir=stage1_build,
Renato Goline402f582014-09-04 19:25:24 +0000675 env=env))
Renato Goline402f582014-09-04 19:25:24 +0000676
Daniel Sandersfa222332015-12-04 14:30:39 +0000677 if stage1_upload_directory:
678 addGCSUploadSteps(f, 'stage 1', stage1_install, stage1_upload_directory,
679 env, gcs_url_property='stage1_package_gcs_url')
680
Reid Kleckner25a26b02015-03-09 22:30:25 +0000681 # Compute the cmake define flag to set the C and C++ compiler to clang. Use
682 # clang-cl if we used MSVC for stage1.
683 if not vs:
684 cc = 'clang'
685 cxx = 'clang++'
686 else:
687 cc = 'clang-cl.exe'
688 cxx = 'clang-cl.exe'
689
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000690
Renato Golin61aed7f2015-06-17 19:12:50 +0000691 ############# STAGE 2
692 if useTwoStage:
Galina Kistanova79900972015-11-16 17:30:42 +0000693 # We always cleanly build the stage 2. If the compiler has been
694 # changed on the stage 1, we cannot trust any of the intermediate file
695 # from the old compiler. And if the stage 1 compiler is the same, we
696 # should not build in the first place.
697 f.addStep(ShellCommand(name='clean stage 2',
698 command=['rm','-rf',stage2_build],
699 warnOnFailure=True,
700 description='cleaning stage 2',
701 descriptionDone='clean',
Galina Kistanova49cbd602017-04-14 23:46:03 +0000702 workdir='.'))
Reid Kleckner25a26b02015-03-09 22:30:25 +0000703
Renato Golin61aed7f2015-06-17 19:12:50 +0000704 # Set the compiler using the CC and CXX environment variables to work around
705 # backslash string escaping bugs somewhere between buildbot and cmake. The
706 # env.exe helper is required to run the tests, so hopefully it's already on
707 # PATH.
708 cmake_cmd2 = ['env',
709 WithProperties('CC=%(workdir)s/'+stage1_install+'/bin/'+cc),
710 WithProperties('CXX=%(workdir)s/'+stage1_install+'/bin/'+cxx),
711 cmake, "-G", "Ninja", "../llvm",
712 "-DCMAKE_BUILD_TYPE="+stage2_config,
713 "-DLLVM_ENABLE_ASSERTIONS=True",
714 "-DLLVM_LIT_ARGS="+lit_args,
715 "-DCMAKE_INSTALL_PREFIX=../"+stage2_install] + extra_cmake_args
Reid Kleckner25a26b02015-03-09 22:30:25 +0000716
Renato Golin61aed7f2015-06-17 19:12:50 +0000717 f.addStep(ShellCommand(name='cmake stage 2',
718 command=cmake_cmd2,
719 haltOnFailure=True,
720 description='cmake stage 2',
721 workdir=stage2_build,
Renato Golin61aed7f2015-06-17 19:12:50 +0000722 env=env))
723
724 f.addStep(WarningCountingShellCommand(name='build stage 2',
725 command=ninja_cmd,
726 haltOnFailure=True,
727 description='ninja all',
728 workdir=stage2_build,
729 env=env))
730
731 if test:
732 f.addStep(lit_test_command.LitTestCommand(name='ninja check 2',
733 command=ninja_check_cmd,
734 haltOnFailure=not runTestSuite,
735 description=["checking stage 2"],
736 descriptionDone=["stage 2 checked"],
737 workdir=stage2_build,
738 env=env))
739
740 ############# TEST SUITE
741 ## Test-Suite (stage 2 if built, stage 1 otherwise)
742 if runTestSuite:
743 compiler_path = stage1_install
744 if useTwoStage:
745 compiler_path=stage2_install
Galina Kistanova49cbd602017-04-14 23:46:03 +0000746 f.addStep(ShellCommand(name='clean stage 2 install',
747 command=['rm','-rf',stage2_install],
748 warnOnFailure=True,
749 description='cleaning stage 2 install',
750 descriptionDone='clean',
751 workdir='.'))
Renato Golin61aed7f2015-06-17 19:12:50 +0000752 f.addStep(ShellCommand(name='install stage 2',
753 command=ninja_install_cmd,
754 description='ninja install 2',
Renato Golincfbd5702014-09-06 19:09:16 +0000755 workdir=stage2_build,
756 env=env))
Renato Goline402f582014-09-04 19:25:24 +0000757
Renato Golin61aed7f2015-06-17 19:12:50 +0000758 # Get generated python, lnt
759 python = WithProperties('%(workdir)s/test/sandbox/bin/python')
760 lnt = WithProperties('%(workdir)s/test/sandbox/bin/lnt')
761 lnt_setup = WithProperties('%(workdir)s/test/lnt/setup.py')
762
763 # Paths
764 sandbox = WithProperties('%(workdir)s/test/sandbox')
765 test_suite_dir = WithProperties('%(workdir)s/test/test-suite')
766
767 # Get latest built Clang (stage1 or stage2)
768 cc = WithProperties('%(workdir)s/'+compiler_path+'/bin/'+cc)
769 cxx = WithProperties('%(workdir)s/'+compiler_path+'/bin/'+cxx)
770
Renato Golin593e0d62016-09-21 17:24:56 +0000771 # LNT Command line (don't pass -jN. Users need to pass both --threads
772 # and --build-threads in nt_flags to get the same effect)
Renato Golin61aed7f2015-06-17 19:12:50 +0000773 test_suite_cmd = [python, lnt, 'runtest', 'nt',
Renato Golin61aed7f2015-06-17 19:12:50 +0000774 '--no-timestamp',
775 '--sandbox', sandbox,
776 '--test-suite', test_suite_dir,
777 '--cc', cc,
778 '--cxx', cxx]
779 # Append any option provided by the user
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000780 test_suite_cmd.extend(nt_flags)
Renato Golin61aed7f2015-06-17 19:12:50 +0000781 # Only submit if a URL has been specified
782 if submitURL is not None:
783 if not isinstance(submitURL, list):
784 submitURL = [submitURL]
785 for url in submitURL:
786 test_suite_cmd.extend(['--submit', url])
787 if testerName:
788 test_suite_cmd.extend(['--no-machdep-info', testerName])
789 # CC and CXX are needed as env for build-tools
Renato Goline6c1b3b2015-07-01 15:52:22 +0000790 test_suite_env = copy.deepcopy(env)
Renato Golin61aed7f2015-06-17 19:12:50 +0000791 test_suite_env['CC'] = cc
792 test_suite_env['CXX'] = cxx
793
794 # Steps to prepare, build and run LNT
795 f.addStep(ShellCommand(name='clean sandbox',
796 command=['rm', '-rf', 'sandbox'],
797 haltOnFailure=True,
798 description='removing sandbox directory',
799 workdir='test',
800 env=env))
801 f.addStep(ShellCommand(name='recreate sandbox',
802 command=['virtualenv', 'sandbox'],
803 haltOnFailure=True,
804 description='recreating sandbox',
805 workdir='test',
806 env=env))
807 f.addStep(ShellCommand(name='setup lit',
808 command=[python, lnt_setup, 'develop'],
809 haltOnFailure=True,
810 description='setting up LNT in sandbox',
811 workdir='test/sandbox',
812 env=env))
813 f.addStep(commands.LitTestCommand.LitTestCommand(
814 name='test-suite',
815 command=test_suite_cmd,
816 haltOnFailure=True,
817 description=['running the test suite'],
818 workdir='test/sandbox',
819 logfiles={'configure.log' : 'build/configure.log',
820 'build-tools.log' : 'build/build-tools.log',
821 'test.log' : 'build/test.log',
822 'report.json' : 'build/report.json'},
823 env=test_suite_env))
824
Renato Goline402f582014-09-04 19:25:24 +0000825 return f
826
Daniel Dunbar7363d032011-02-27 03:22:35 +0000827def addClangGCCTests(f, ignores={}, install_prefix="%(builddir)s/llvm.install",
828 languages = ('gcc', 'g++', 'objc', 'obj-c++')):
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000829 make_vars = [WithProperties(
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000830 'CC_UNDER_TEST=%s/bin/clang' % install_prefix),
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000831 WithProperties(
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000832 'CXX_UNDER_TEST=%s/bin/clang++' % install_prefix)]
David Blaikie05517332013-12-19 23:29:12 +0000833 f.addStep(SVN(name='svn-clang-gcc-tests', mode='update',
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000834 baseURL='http://llvm.org/svn/llvm-project/clang-tests/',
835 defaultBranch='trunk', workdir='clang-tests'))
836 gcc_dg_ignores = ignores.get('gcc-4_2-testsuite', {})
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000837 for lang in languages:
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000838 f.addStep(commands.SuppressionDejaGNUCommand.SuppressionDejaGNUCommand(
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000839 name='test-gcc-4_2-testsuite-%s' % lang,
840 command=["make", "-k", "check-%s" % lang] + make_vars,
841 description="gcc-4_2-testsuite (%s)" % lang,
842 workdir='clang-tests/gcc-4_2-testsuite',
David Dean2bd0c3a2011-10-18 16:36:28 +0000843 logfiles={ 'dg.sum' : 'obj/%s/%s.sum' % (lang, lang),
844 '%s.log' % lang : 'obj/%s/%s.log' % (lang, lang)},
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000845 ignore=gcc_dg_ignores.get(lang, [])))
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000846
Daniel Dunbar7363d032011-02-27 03:22:35 +0000847def addClangGDBTests(f, ignores={}, install_prefix="%(builddir)s/llvm.install"):
848 make_vars = [WithProperties(
849 'CC_UNDER_TEST=%s/bin/clang' % install_prefix),
850 WithProperties(
851 'CXX_UNDER_TEST=%s/bin/clang++' % install_prefix)]
David Blaikie05517332013-12-19 23:29:12 +0000852 f.addStep(SVN(name='svn-clang-gdb-tests', mode='update',
Daniel Dunbar7363d032011-02-27 03:22:35 +0000853 baseURL='http://llvm.org/svn/llvm-project/clang-tests/',
854 defaultBranch='trunk', workdir='clang-tests'))
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000855 f.addStep(commands.SuppressionDejaGNUCommand.SuppressionDejaGNUCommand(
Daniel Dunbar7363d032011-02-27 03:22:35 +0000856 name='test-gdb-1472-testsuite',
857 command=["make", "-k", "check"] + make_vars,
858 description="gdb-1472-testsuite",
859 workdir='clang-tests/gdb-1472-testsuite',
David Blaikie7ec695f2012-10-09 22:17:09 +0000860 logfiles={ 'dg.sum' : 'obj/filtered.gdb.sum',
David Blaikie624f4392012-11-05 22:34:35 +0000861 'gdb.log' : 'obj/gdb.log' }))
Daniel Dunbar7363d032011-02-27 03:22:35 +0000862
David Blaikie41d09c32013-01-02 21:11:09 +0000863def addModernClangGDBTests(f, jobs, install_prefix):
David Blaikie1bc5c372012-12-05 05:29:12 +0000864 make_vars = [WithProperties('RUNTESTFLAGS=CC_FOR_TARGET=\'{0}/bin/clang\' '
865 'CXX_FOR_TARGET=\'{0}/bin/clang++\' '
David Blaikie759bb752013-04-18 23:13:11 +0000866 'CFLAGS_FOR_TARGET=\'-w -fno-limit-debug-info\''
David Blaikief89877b2013-01-29 23:46:26 +0000867 .format(install_prefix))]
David Blaikie05517332013-12-19 23:29:12 +0000868 f.addStep(SVN(name='svn-clang-modern-gdb-tests', mode='update',
David Blaikief3f300b2012-11-17 01:13:41 +0000869 svnurl='http://llvm.org/svn/llvm-project/clang-tests-external/trunk/gdb/7.5',
David Blaikiedad03d52012-11-16 22:37:12 +0000870 workdir='clang-tests/src'))
David Blaikieb83bfdf2012-12-05 04:33:42 +0000871 f.addStep(Configure(command='../src/configure',
David Blaikief3f300b2012-11-17 01:13:41 +0000872 workdir='clang-tests/build/'))
David Blaikieb83bfdf2012-12-05 04:33:42 +0000873 f.addStep(WarningCountingShellCommand(name='gdb-75-build',
874 command=['make', WithProperties('-j%s' % jobs)],
875 haltOnFailure=True,
876 workdir='clang-tests/build'))
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000877 f.addStep(commands.DejaGNUCommand.DejaGNUCommand(
David Blaikiedad03d52012-11-16 22:37:12 +0000878 name='gdb-75-check',
David Blaikieb83bfdf2012-12-05 04:33:42 +0000879 command=['make', '-k', WithProperties('-j%s' % jobs), 'check'] + make_vars,
David Blaikiedad03d52012-11-16 22:37:12 +0000880 workdir='clang-tests/build',
David Blaikie1bc5c372012-12-05 05:29:12 +0000881 logfiles={'dg.sum':'gdb/testsuite/gdb.sum',
882 'gdb.log':'gdb/testsuite/gdb.log'}))
David Blaikiedad03d52012-11-16 22:37:12 +0000883
884
885
Daniel Dunbar7363d032011-02-27 03:22:35 +0000886# FIXME: Deprecated.
887addClangTests = addClangGCCTests
888
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000889def getClangTestsIgnoresFromPath(path, key):
890 def readList(path):
891 if not os.path.exists(path):
892 return []
893
894 f = open(path)
895 lines = [ln.strip() for ln in f]
896 f.close()
897 return lines
898
899 ignores = {}
900
901 gcc_dg_ignores = {}
902 for lang in ('gcc', 'g++', 'objc', 'obj-c++'):
903 lang_path = os.path.join(path, 'gcc-4_2-testsuite', 'expected_results',
904 key, lang)
905 gcc_dg_ignores[lang] = (
906 readList(os.path.join(lang_path, 'FAIL.txt')) +
907 readList(os.path.join(lang_path, 'UNRESOLVED.txt')) +
908 readList(os.path.join(lang_path, 'XPASS.txt')))
909 ignores['gcc-4_2-testsuite' ] = gcc_dg_ignores
910
Daniel Dunbar7363d032011-02-27 03:22:35 +0000911 ignores_path = os.path.join(path, 'gdb-1472-testsuite', 'expected_results',
912 key)
913 gdb_dg_ignores = (
914 readList(os.path.join(ignores_path, 'FAIL.txt')) +
915 readList(os.path.join(ignores_path, 'UNRESOLVED.txt')) +
916 readList(os.path.join(ignores_path, 'XPASS.txt')))
917 ignores['gdb-1472-testsuite' ] = gdb_dg_ignores
918
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000919 return ignores