blob: 5d6b0d75024668919684bda5f5e6e8c05a4d7d19 [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,
43 run_gdb=False,
David Blaikiedad03d52012-11-16 22:37:12 +000044 run_modern_gdb=False,
Vassil Vassilev0c647ef2016-06-30 21:16:45 +000045 run_gcc=False):
Galina Kistanovaf4d79352011-10-20 20:46:52 +000046 # Prepare environmental variables. Set here all env we want everywhere.
47 merged_env = {
48 'TERM' : 'dumb' # Make sure Clang doesn't use color escape sequences.
49 }
50 if env is not None:
51 # Overwrite pre-set items with the given ones, so user can set anything.
52 merged_env.update(env)
David Blaikie2f7eb282012-08-24 18:37:00 +000053
Jonathan Roelofs62415e52015-02-28 00:03:17 +000054 llvm_srcdir = "llvm.src"
55 llvm_1_objdir = "llvm.obj"
56 llvm_1_installdir = "llvm.install.1"
57 llvm_2_objdir = "llvm.obj.2"
58 llvm_2_installdir = "llvm.install"
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +000059
Daniel Dunbar235aa412009-07-18 07:16:15 +000060 f = buildbot.process.factory.BuildFactory()
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +000061
62 # Determine the build directory.
63 f.addStep(buildbot.steps.shell.SetProperty(name="get_builddir",
64 command=["pwd"],
65 property="builddir",
66 description="set build dir",
Galina Kistanovaf4d79352011-10-20 20:46:52 +000067 workdir=".",
68 env=merged_env))
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +000069
Daniel Dunbar06b20f12010-04-08 18:29:38 +000070 # Blow away completely, if requested.
71 if completely_clean:
72 f.addStep(ShellCommand(name="rm-llvm.src",
73 command=["rm", "-rf", llvm_srcdir],
74 haltOnFailure=True,
75 description=["rm src dir", "llvm"],
Galina Kistanovaf4d79352011-10-20 20:46:52 +000076 workdir=".",
77 env=merged_env))
Daniel Dunbar06b20f12010-04-08 18:29:38 +000078
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +000079 # Checkout sources.
Peter Collingbourned49ac282011-10-25 14:38:45 +000080 if trunk_revision:
81 # The SVN build step provides no mechanism to check out a specific revision
82 # based on a property, so just run the commands directly here.
83 svn_co = ['svn', 'checkout']
84 if force_checkout:
85 svn_co += ['--force']
86 svn_co += ['--revision', WithProperties(trunk_revision)]
87
88 svn_co_llvm = svn_co + \
89 [WithProperties('http://llvm.org/svn/llvm-project/llvm/trunk@%s' %
90 trunk_revision),
91 llvm_srcdir]
92 svn_co_clang = svn_co + \
93 [WithProperties('http://llvm.org/svn/llvm-project/cfe/trunk@%s' %
94 trunk_revision),
95 '%s/tools/clang' % llvm_srcdir]
David Blaikie845ae0d2012-08-10 00:51:38 +000096 svn_co_clang_tools_extra = svn_co + \
97 [WithProperties('http://llvm.org/svn/llvm-project/clang-tools-extra/trunk@%s' %
98 trunk_revision),
99 '%s/tools/clang/tools/extra' % llvm_srcdir]
Peter Collingbourned49ac282011-10-25 14:38:45 +0000100
101 f.addStep(ShellCommand(name='svn-llvm',
102 command=svn_co_llvm,
103 haltOnFailure=True,
104 workdir='.'))
105 f.addStep(ShellCommand(name='svn-clang',
106 command=svn_co_clang,
107 haltOnFailure=True,
108 workdir='.'))
David Blaikie845ae0d2012-08-10 00:51:38 +0000109 f.addStep(ShellCommand(name='svn-clang-tools-extra',
110 command=svn_co_clang_tools_extra,
111 haltOnFailure=True,
112 workdir='.'))
Peter Collingbourned49ac282011-10-25 14:38:45 +0000113 else:
114 f.addStep(SVN(name='svn-llvm',
Daniel Dunbarf4e23eb2010-09-20 21:13:02 +0000115 mode='update',
Peter Collingbourned49ac282011-10-25 14:38:45 +0000116 baseURL='http://llvm.org/svn/llvm-project/llvm/',
Daniel Dunbarf4e23eb2010-09-20 21:13:02 +0000117 defaultBranch='trunk',
Peter Collingbourned49ac282011-10-25 14:38:45 +0000118 workdir=llvm_srcdir))
119 f.addStep(SVN(name='svn-clang',
120 mode='update',
121 baseURL='http://llvm.org/svn/llvm-project/cfe/',
122 defaultBranch='trunk',
123 workdir='%s/tools/clang' % llvm_srcdir))
David Blaikie845ae0d2012-08-10 00:51:38 +0000124 f.addStep(SVN(name='svn-clang-tools-extra',
125 mode='update',
126 baseURL='http://llvm.org/svn/llvm-project/clang-tools-extra/',
127 defaultBranch='trunk',
128 workdir='%s/tools/clang/tools/extra' % llvm_srcdir))
Peter Collingbourned49ac282011-10-25 14:38:45 +0000129 if checkout_compiler_rt:
130 f.addStep(SVN(name='svn-compiler-rt',
131 mode='update',
132 baseURL='http://llvm.org/svn/llvm-project/compiler-rt/',
133 defaultBranch='trunk',
134 workdir='%s/projects/compiler-rt' % llvm_srcdir))
Daniel Dunbarfa0e0222009-11-09 06:08:28 +0000135
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000136 # Clean up llvm (stage 1); unless in-dir.
137 if clean and llvm_srcdir != llvm_1_objdir:
138 f.addStep(ShellCommand(name="rm-llvm.obj.stage1",
139 command=["rm", "-rf", llvm_1_objdir],
140 haltOnFailure=True,
141 description=["rm build dir", "llvm"],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000142 workdir=".",
143 env=merged_env))
Andrew Trick70fa9d22011-08-25 23:38:51 +0000144
David Blaikie8cbf62f2013-01-12 21:32:31 +0000145 if not clean:
Galina Kistanovaa06e4c82016-04-14 21:41:30 +0000146 expected_makefile = 'Makefile'
David Blaikie8cbf62f2013-01-12 21:32:31 +0000147 f.addStep(SetProperty(name="Makefile_isready",
148 workdir=llvm_1_objdir,
149 command=["sh", "-c",
Richard Smith02389162014-09-26 23:53:06 +0000150 "test -e %s && echo OK || echo Missing" % expected_makefile],
David Blaikie8cbf62f2013-01-12 21:32:31 +0000151 flunkOnFailure=False,
Galina Kistanovaa06e4c82016-04-14 21:41:30 +0000152 property="exists_Makefile"))
Richard Smith02389162014-09-26 23:53:06 +0000153
Galina Kistanovaa06e4c82016-04-14 21:41:30 +0000154 cmake_triple_arg = []
155 if triple:
156 cmake_triple_arg = ['-DLLVM_HOST_TRIPLE=%s' % triple]
157 f.addStep(ShellCommand(name='cmake',
158 command=['cmake',
159 '-DLLVM_BUILD_TESTS=ON',
160 '-DCMAKE_BUILD_TYPE=%s' % stage1_config] +
161 cmake_triple_arg +
162 extra_configure_args +
163 ["../" + llvm_srcdir],
164 description='cmake stage1',
165 workdir=llvm_1_objdir,
166 env=merged_env,
167 doStepIf=lambda step: step.build.getProperty("exists_Makefile") != "OK"))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000168
169 # Make clean if using in-dir builds.
170 if clean and llvm_srcdir == llvm_1_objdir:
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000171 f.addStep(WarningCountingShellCommand(name="clean-llvm",
Daniel Dunbard20468a2009-11-24 18:27:23 +0000172 command=[make, "clean"],
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000173 haltOnFailure=True,
174 description="cleaning llvm",
175 descriptionDone="clean llvm",
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000176 workdir=llvm_1_objdir,
Peter Collingbourne7a95b0c2011-10-26 16:40:17 +0000177 doStepIf=clean,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000178 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000179
Peter Collingbourne7a95b0c2011-10-26 16:40:17 +0000180 if extra_clean_step:
181 f.addStep(extra_clean_step)
182
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000183 f.addStep(WarningCountingShellCommand(name="compile",
Daniel Dunbard20468a2009-11-24 18:27:23 +0000184 command=['nice', '-n', '10',
185 make, WithProperties("-j%s" % jobs)],
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000186 haltOnFailure=True,
David Blaikie05517332013-12-19 23:29:12 +0000187 flunkOnFailure=not run_gdb,
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000188 description=["compiling", stage1_config],
189 descriptionDone=["compile", stage1_config],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000190 workdir=llvm_1_objdir,
191 env=merged_env))
Daniel Dunbar256fed42009-11-25 21:11:08 +0000192
193 if examples:
194 f.addStep(WarningCountingShellCommand(name="compile.examples",
195 command=['nice', '-n', '10',
196 make, WithProperties("-j%s" % jobs),
197 "BUILD_EXAMPLES=1"],
198 haltOnFailure=True,
Richard Smith65e6f5d2014-09-25 18:18:35 +0000199 description=["compiling", stage1_config, "examples"],
Daniel Dunbar256fed42009-11-25 21:11:08 +0000200 descriptionDone=["compile", stage1_config, "examples"],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000201 workdir=llvm_1_objdir,
202 env=merged_env))
Daniel Dunbar256fed42009-11-25 21:11:08 +0000203
NAKAMURA Takumi1a4666b2013-01-19 03:39:07 +0000204 clangTestArgs = '-v -j %s' % jobs
Daniel Dunbarfa0e0222009-11-09 06:08:28 +0000205 if valgrind:
Daniel Dunbar89184b92010-04-18 19:09:32 +0000206 clangTestArgs += ' --vg'
Daniel Dunbara1bebce2010-03-21 01:24:00 +0000207 if valgrindLeakCheck:
208 clangTestArgs += ' --vg-leak'
Nick Lewycky8d26e472011-08-27 21:18:56 +0000209 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 +0000210 extraTestDirs = ''
211 if run_cxx_tests:
212 extraTestDirs += '%(builddir)s/llvm/tools/clang/utils/C++Tests'
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000213 if test:
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000214 f.addStep(lit_test_command.LitTestCommand(name='check-all',
David Blaikie7e6f8a12012-08-31 20:46:27 +0000215 command=[make, "check-all", "VERBOSE=1",
NAKAMURA Takumi1a4666b2013-01-19 03:39:07 +0000216 WithProperties("LIT_ARGS=%s" % clangTestArgs),
David Blaikiebc684012012-12-27 20:44:19 +0000217 WithProperties("EXTRA_TESTDIRS=%s" % extraTestDirs)],
David Blaikie05517332013-12-19 23:29:12 +0000218 flunkOnFailure=not run_gdb,
David Blaikie7e6f8a12012-08-31 20:46:27 +0000219 description=["checking"],
220 descriptionDone=["checked"],
Daniel Dunbar469e8ca2010-05-19 21:26:48 +0000221 workdir=llvm_1_objdir,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000222 usePTY=use_pty_in_tests,
223 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000224
Galina Kistanovaa06e4c82016-04-14 21:41:30 +0000225 # TODO: Install llvm and clang for stage1.
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000226
David Blaikiedad03d52012-11-16 22:37:12 +0000227 if run_gdb or run_gcc or run_modern_gdb:
David Blaikiea76da842012-08-13 22:24:46 +0000228 ignores = getClangTestsIgnoresFromPath(os.path.expanduser('~/public/clang-tests'), 'clang-x86_64-darwin10')
229 install_prefix = "%%(builddir)s/%s" % llvm_1_installdir
230 if run_gdb:
231 addClangGDBTests(f, ignores, install_prefix)
David Blaikiedad03d52012-11-16 22:37:12 +0000232 if run_modern_gdb:
David Blaikie41d09c32013-01-02 21:11:09 +0000233 addModernClangGDBTests(f, jobs, install_prefix)
David Blaikiea76da842012-08-13 22:24:46 +0000234 if run_gcc:
235 addClangGCCTests(f, ignores, install_prefix)
236
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000237 if not useTwoStage:
Daniel Dunbardedf6572010-11-13 00:23:34 +0000238 if package_dst:
239 name = WithProperties(
240 "%(builddir)s/" + llvm_1_objdir +
241 "/clang-r%(got_revision)s-b%(buildnumber)s.tgz")
242 f.addStep(ShellCommand(name='pkg.tar',
243 description="tar root",
244 command=["tar", "zcvf", name, "./"],
245 workdir=llvm_1_installdir,
246 warnOnFailure=True,
247 flunkOnFailure=False,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000248 haltOnFailure=False,
249 env=merged_env))
Daniel Dunbardedf6572010-11-13 00:23:34 +0000250 f.addStep(ShellCommand(name='pkg.upload',
Andrew Trick70fa9d22011-08-25 23:38:51 +0000251 description="upload root",
Daniel Dunbardedf6572010-11-13 00:23:34 +0000252 command=["scp", name,
253 WithProperties(
254 package_dst + "/%(buildername)s")],
255 workdir=".",
256 warnOnFailure=True,
257 flunkOnFailure=False,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000258 haltOnFailure=False,
259 env=merged_env))
Daniel Dunbardedf6572010-11-13 00:23:34 +0000260
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000261 return f
262
263 # Clean up llvm (stage 2).
Richard Smith02389162014-09-26 23:53:06 +0000264 #
Galina Kistanova79900972015-11-16 17:30:42 +0000265 # We always cleanly build the stage 2. If the compiler has been
266 # changed on the stage 1, we cannot trust any of the intermediate file
267 # from the old compiler. And if the stage 1 compiler is the same, we should
268 # not build in the first place.
269 f.addStep(ShellCommand(name="rm-llvm.obj.stage2",
270 command=["rm", "-rf", llvm_2_objdir],
271 haltOnFailure=True,
272 description=["rm build dir", "llvm", "(stage 2)"],
273 workdir=".",
274 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000275
276 # Configure llvm (stage 2).
Galina Kistanovaa06e4c82016-04-14 21:41:30 +0000277 f.addStep(ShellCommand(name='cmake',
Vassil Vassilev5a9b9ed2016-05-25 17:10:03 +0000278 command=['cmake'] + stage2_extra_configure_args + [
Galina Kistanovaa06e4c82016-04-14 21:41:30 +0000279 '-DLLVM_BUILD_TESTS=ON',
280 WithProperties('-DCMAKE_C_COMPILER=%%(builddir)s/%s/bin/clang' % llvm_1_objdir), # FIXME use installdir
281 WithProperties('-DCMAKE_CXX_COMPILER=%%(builddir)s/%s/bin/clang++' % llvm_1_objdir),
282 '-DCMAKE_BUILD_TYPE=%s' % stage2_config,
Galina Kistanovaa06e4c82016-04-14 21:41:30 +0000283 "../" + llvm_srcdir],
284 description='cmake stage2',
285 workdir=llvm_2_objdir,
286 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000287
288 # Build llvm (stage 2).
289 f.addStep(WarningCountingShellCommand(name="compile.llvm.stage2",
290 command=['nice', '-n', '10',
291 make, WithProperties("-j%s" % jobs)],
292 haltOnFailure=True,
293 description=["compiling", "(stage 2)",
294 stage2_config],
295 descriptionDone=["compile", "(stage 2)",
296 stage2_config],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000297 workdir=llvm_2_objdir,
298 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000299
300 if test:
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000301 f.addStep(lit_test_command.LitTestCommand(name='check-all',
David Blaikie7e6f8a12012-08-31 20:46:27 +0000302 command=[make, "check-all", "VERBOSE=1",
NAKAMURA Takumi1a4666b2013-01-19 03:39:07 +0000303 WithProperties("LIT_ARGS=%s" % clangTestArgs),
David Blaikiebc684012012-12-27 20:44:19 +0000304 WithProperties("EXTRA_TESTDIRS=%s" % extraTestDirs)],
David Blaikie7e6f8a12012-08-31 20:46:27 +0000305 description=["checking"],
306 descriptionDone=["checked"],
Daniel Dunbar469e8ca2010-05-19 21:26:48 +0000307 workdir=llvm_2_objdir,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000308 usePTY=use_pty_in_tests,
309 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000310
Galina Kistanovaa06e4c82016-04-14 21:41:30 +0000311 # TODO: Install llvm and clang for stage2.
Daniel Dunbar3efb7822010-02-26 19:20:00 +0000312
313 if package_dst:
314 name = WithProperties(
315 "%(builddir)s/" + llvm_2_objdir +
316 "/clang-r%(got_revision)s-b%(buildnumber)s.tgz")
317 f.addStep(ShellCommand(name='pkg.tar',
318 description="tar root",
319 command=["tar", "zcvf", name, "./"],
320 workdir=llvm_2_installdir,
321 warnOnFailure=True,
322 flunkOnFailure=False,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000323 haltOnFailure=False,
324 env=merged_env))
Daniel Dunbar3efb7822010-02-26 19:20:00 +0000325 f.addStep(ShellCommand(name='pkg.upload',
Andrew Trick70fa9d22011-08-25 23:38:51 +0000326 description="upload root",
Daniel Dunbar3efb7822010-02-26 19:20:00 +0000327 command=["scp", name,
328 WithProperties(
329 package_dst + "/%(buildername)s")],
330 workdir=".",
331 warnOnFailure=True,
332 flunkOnFailure=False,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000333 haltOnFailure=False,
334 env=merged_env))
Daniel Dunbar3efb7822010-02-26 19:20:00 +0000335
Daniel Dunbar235aa412009-07-18 07:16:15 +0000336 return f
Daniel Dunbar44abe742009-07-19 01:59:03 +0000337
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000338def addSVNUpdateSteps(f,
339 checkout_clang_tools_extra,
340 checkout_compiler_rt,
341 checkout_test_suite):
342 # We *must* checkout at least Clang+LLVM
343 f.addStep(SVN(name='svn-llvm',
344 mode='update', baseURL='http://llvm.org/svn/llvm-project/llvm/',
345 defaultBranch='trunk',
346 workdir='llvm'))
347 f.addStep(SVN(name='svn-clang',
348 mode='update', baseURL='http://llvm.org/svn/llvm-project/cfe/',
349 defaultBranch='trunk',
350 workdir='llvm/tools/clang'))
351
352 # Extra stuff that will be built/tested
353 if checkout_clang_tools_extra:
354 f.addStep(SVN(name='svn-clang-tools-extra',
355 mode='update', baseURL='http://llvm.org/svn/llvm-project/clang-tools-extra/',
356 defaultBranch='trunk',
357 workdir='llvm/tools/clang/tools/extra'))
358 if checkout_compiler_rt:
359 f.addStep(SVN(name='svn-compiler-rt',
360 mode='update', baseURL='http://llvm.org/svn/llvm-project/compiler-rt/',
361 defaultBranch='trunk',
362 workdir='llvm/projects/compiler-rt'))
363 if checkout_test_suite:
364 f.addStep(SVN(name='svn-lnt',
365 mode='update', baseURL='http://llvm.org/svn/llvm-project/lnt/',
366 defaultBranch='trunk',
367 workdir='test/lnt'))
368 f.addStep(SVN(name='svn-test-suite',
369 mode='update', baseURL='http://llvm.org/svn/llvm-project/test-suite/',
370 defaultBranch='trunk',
371 workdir='test/test-suite'))
Renato Goline402f582014-09-04 19:25:24 +0000372
Daniel Sandersfa222332015-12-04 14:30:39 +0000373def addGCSUploadSteps(f, package_name, install_prefix, gcs_directory, env,
374 gcs_url_property=None):
375 """
376 Add steps to upload to the Google Cloud Storage bucket.
377
378 f - The BuildFactory to modify.
379 package_name - The name of this package for the descriptions (e.g.
380 'stage 1')
381 install_prefix - The directory the build has been installed to.
382 gcs_directory - The subdirectory of the bucket root to upload to. This
383 should match the builder name.
384 env - The environment to use. Set BOTO_CONFIG to use a configuration file
385 in a non-standard location, and BUCKET to use a different GCS bucket.
386 gcs_url_property - Property to assign the GCS url to.
387 """
388
389 gcs_url_fmt = ('gs://%(gcs_bucket)s/%(gcs_directory)s/'
390 'clang-r%(got_revision)s-t%(now)s-b%(buildnumber)s.tar.xz')
391 time_fmt = '%Y-%m-%d_%H-%M-%S'
392 gcs_url = \
393 WithProperties(
394 gcs_url_fmt,
395 gcs_bucket=lambda _: env.get('BUCKET', 'llvm-build-artifacts'),
396 gcs_directory=lambda _: gcs_directory,
397 now=lambda _: datetime.utcnow().strftime(time_fmt))
398
399 if gcs_url_property:
400 f.addStep(SetProperty(
401 name="record GCS url for " + package_name,
402 command=['echo', gcs_url],
403 property=gcs_url_property))
404
405 f.addStep(ShellCommand(name='package ' + package_name,
406 command=['tar', 'cvfJ', '../install.tar.xz', '.'],
407 description='packaging ' + package_name + '...',
408 workdir=install_prefix,
409 env=env))
410
411 f.addStep(ShellCommand(
412 name='upload ' + package_name + ' to storage bucket',
413 command=['gsutil', 'cp', '../install.tar.xz', gcs_url],
414 description=('uploading ' + package_name +
415 'to storage bucket ...'),
416 workdir=install_prefix,
417 env=env))
418
419def getClangCMakeGCSBuildFactory(
420 clean=True,
421 test=True,
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000422 cmake='cmake',
Daniel Sandersfa222332015-12-04 14:30:39 +0000423 jobs=None,
424
425 # VS tools environment variable if using MSVC. For example,
426 # %VS120COMNTOOLS% selects the 2013 toolchain.
427 vs=None,
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000428 vs_target_arch='x86',
Daniel Sandersfa222332015-12-04 14:30:39 +0000429
430 # Multi-stage compilation
431 useTwoStage=False,
432 testStage1=True,
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000433 stage1_config='Release',
434 stage2_config='Release',
Daniel Sandersfa222332015-12-04 14:30:39 +0000435
436 # Test-suite
437 runTestSuite=False,
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000438 nt_flags=[],
Daniel Sandersfa222332015-12-04 14:30:39 +0000439 submitURL=None,
440 testerName=None,
441
442 # Environmental variables for all steps.
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000443 env={},
444 extra_cmake_args=[],
Daniel Sandersfa222332015-12-04 14:30:39 +0000445
446 # Extra repositories
447 checkout_clang_tools_extra=True,
448 checkout_compiler_rt=True,
449
450 # Upload artifacts to Google Cloud Storage (for the llvmbisect tool)
451 stage1_upload_directory=None,
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000452
453 # Triggers
454 trigger_after_stage1=[]):
Daniel Sandersfa222332015-12-04 14:30:39 +0000455 return _getClangCMakeBuildFactory(
456 clean=clean, test=test, cmake=cmake, jobs=jobs, vs=vs,
457 vs_target_arch=vs_target_arch, useTwoStage=useTwoStage,
458 testStage1=testStage1, stage1_config=stage1_config,
459 stage2_config=stage2_config, runTestSuite=runTestSuite,
460 nt_flags=nt_flags, submitURL=submitURL, testerName=testerName,
461 env=env, extra_cmake_args=extra_cmake_args,
462 checkout_clang_tools_extra=checkout_clang_tools_extra,
463 checkout_compiler_rt=checkout_compiler_rt,
464 stage1_upload_directory=stage1_upload_directory,
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000465 trigger_after_stage1=trigger_after_stage1)
Reid Kleckner25a26b02015-03-09 22:30:25 +0000466
467def getClangCMakeBuildFactory(
468 clean=True,
469 test=True,
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000470 cmake='cmake',
Reid Kleckner25a26b02015-03-09 22:30:25 +0000471 jobs=None,
472
473 # VS tools environment variable if using MSVC. For example,
474 # %VS120COMNTOOLS% selects the 2013 toolchain.
475 vs=None,
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000476 vs_target_arch='x86',
Reid Kleckner25a26b02015-03-09 22:30:25 +0000477
478 # Multi-stage compilation
479 useTwoStage=False,
480 testStage1=True,
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000481 stage1_config='Release',
482 stage2_config='Release',
Reid Kleckner25a26b02015-03-09 22:30:25 +0000483
Renato Golin61aed7f2015-06-17 19:12:50 +0000484 # Test-suite
485 runTestSuite=False,
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000486 nt_flags=[],
Renato Golin61aed7f2015-06-17 19:12:50 +0000487 submitURL=None,
488 testerName=None,
489
Reid Kleckner25a26b02015-03-09 22:30:25 +0000490 # Environmental variables for all steps.
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000491 env={},
492 extra_cmake_args=[],
Reid Kleckner25a26b02015-03-09 22:30:25 +0000493
494 # Extra repositories
495 checkout_clang_tools_extra=True,
496 checkout_compiler_rt=True):
Daniel Sandersfa222332015-12-04 14:30:39 +0000497 return _getClangCMakeBuildFactory(
498 clean=clean, test=test, cmake=cmake, jobs=jobs, vs=vs,
499 vs_target_arch=vs_target_arch, useTwoStage=useTwoStage,
500 testStage1=testStage1, stage1_config=stage1_config,
501 stage2_config=stage2_config, runTestSuite=runTestSuite,
502 nt_flags=nt_flags, submitURL=submitURL, testerName=testerName,
503 env=env, extra_cmake_args=extra_cmake_args,
504 checkout_clang_tools_extra=checkout_clang_tools_extra,
505 checkout_compiler_rt=checkout_compiler_rt)
506
507def _getClangCMakeBuildFactory(
508 clean=True,
509 test=True,
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000510 cmake='cmake',
Daniel Sandersfa222332015-12-04 14:30:39 +0000511 jobs=None,
512
513 # VS tools environment variable if using MSVC. For example,
514 # %VS120COMNTOOLS% selects the 2013 toolchain.
515 vs=None,
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000516 vs_target_arch='x86',
Daniel Sandersfa222332015-12-04 14:30:39 +0000517
518 # Multi-stage compilation
519 useTwoStage=False,
520 testStage1=True,
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000521 stage1_config='Release',
522 stage2_config='Release',
Daniel Sandersfa222332015-12-04 14:30:39 +0000523
524 # Test-suite
525 runTestSuite=False,
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000526 nt_flags=[],
Daniel Sandersfa222332015-12-04 14:30:39 +0000527 submitURL=None,
528 testerName=None,
529
530 # Environmental variables for all steps.
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000531 env={},
532 extra_cmake_args=[],
Daniel Sandersfa222332015-12-04 14:30:39 +0000533
534 # Extra repositories
535 checkout_clang_tools_extra=True,
536 checkout_compiler_rt=True,
537
538 # Upload artifacts to Google Cloud Storage (for the llvmbisect tool)
539 stage1_upload_directory=None,
540
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000541 # Triggers
542 trigger_after_stage1=[]):
Reid Kleckner25a26b02015-03-09 22:30:25 +0000543
544 ############# PREPARING
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000545 f = buildbot.process.factory.BuildFactory()
Reid Kleckner25a26b02015-03-09 22:30:25 +0000546
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000547 addSVNUpdateSteps(f,
548 checkout_clang_tools_extra=checkout_clang_tools_extra,
549 checkout_compiler_rt=checkout_compiler_rt,
550 checkout_test_suite=runTestSuite)
Reid Kleckner25a26b02015-03-09 22:30:25 +0000551
Renato Goline402f582014-09-04 19:25:24 +0000552 # If jobs not defined, Ninja will choose a suitable value
Renato Golincc83db32015-06-17 19:23:40 +0000553 jobs_cmd = []
554 lit_args = "'-v"
Renato Goline402f582014-09-04 19:25:24 +0000555 if jobs is not None:
Renato Golincc83db32015-06-17 19:23:40 +0000556 jobs_cmd = ["-j"+str(jobs)]
557 lit_args += " -j"+str(jobs)+"'"
Renato Goline402f582014-09-04 19:25:24 +0000558 else:
Renato Golincc83db32015-06-17 19:23:40 +0000559 lit_args += "'"
560 ninja_cmd = ['ninja'] + jobs_cmd
561 ninja_install_cmd = ['ninja', 'install'] + jobs_cmd
562 ninja_check_cmd = ['ninja', 'check-all'] + jobs_cmd
Reid Kleckner25a26b02015-03-09 22:30:25 +0000563 check_build_cmd = ["sh", "-c",
564 "test -e build.ninja && echo OK || echo Missing"]
565 if vs:
566 check_build_cmd = ["cmd", "/c", "if exist build.ninja (echo OK) " +
567 " else (echo Missing & exit 1)"]
Renato Goline402f582014-09-04 19:25:24 +0000568
569 # Global configurations
Renato Golincc83db32015-06-17 19:23:40 +0000570 stage1_build = 'stage1'
571 stage1_install = 'stage1.install'
572 stage2_build = 'stage2'
573 stage2_install = 'stage2.install'
Renato Goline402f582014-09-04 19:25:24 +0000574
Reid Kleckner25a26b02015-03-09 22:30:25 +0000575 # Set up VS environment, if appropriate.
576 if vs:
577 f.addStep(SetProperty(
578 command=builders_util.getVisualStudioEnvironment(vs, vs_target_arch),
579 extract_fn=builders_util.extractSlaveEnvironment))
580 assert not env, "Can't have custom builder env vars with VS"
581 env = Property('slave_env')
582
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000583
Renato Goline402f582014-09-04 19:25:24 +0000584 ############# CLEANING
585 if clean:
586 f.addStep(ShellCommand(name='clean stage 1',
587 command=['rm','-rf',stage1_build],
588 warnOnFailure=True,
589 description='cleaning stage 1',
590 descriptionDone='clean',
591 workdir='.',
592 env=env))
593 else:
594 f.addStep(SetProperty(name="check ninja files 1",
595 workdir=stage1_build,
Reid Kleckner25a26b02015-03-09 22:30:25 +0000596 command=check_build_cmd,
Renato Goline402f582014-09-04 19:25:24 +0000597 flunkOnFailure=False,
598 property="exists_ninja_1"))
599
600
601 ############# STAGE 1
602 f.addStep(ShellCommand(name='cmake stage 1',
603 command=[cmake, "-G", "Ninja", "../llvm",
604 "-DCMAKE_BUILD_TYPE="+stage1_config,
605 "-DLLVM_ENABLE_ASSERTIONS=True",
606 "-DLLVM_LIT_ARGS="+lit_args,
607 "-DCMAKE_INSTALL_PREFIX=../"+stage1_install]
608 + extra_cmake_args,
609 haltOnFailure=True,
610 description='cmake stage 1',
611 workdir=stage1_build,
612 doStepIf=lambda step: step.build.getProperty("exists_ninja_1") != "OK",
613 env=env))
614
615 f.addStep(WarningCountingShellCommand(name='build stage 1',
616 command=ninja_cmd,
617 haltOnFailure=True,
618 description='ninja all',
619 workdir=stage1_build,
620 env=env))
621
622 if test and testStage1:
Renato Golind1c46742015-08-06 18:05:34 +0000623 haltOnStage1Check = not useTwoStage and not runTestSuite
Renato Golincfbd5702014-09-06 19:09:16 +0000624 f.addStep(lit_test_command.LitTestCommand(name='ninja check 1',
625 command=ninja_check_cmd,
Renato Golind1c46742015-08-06 18:05:34 +0000626 haltOnFailure=haltOnStage1Check,
Renato Golincfbd5702014-09-06 19:09:16 +0000627 description=["checking stage 1"],
628 descriptionDone=["stage 1 checked"],
629 workdir=stage1_build,
630 env=env))
Renato Goline402f582014-09-04 19:25:24 +0000631
Daniel Sandersfa222332015-12-04 14:30:39 +0000632 if useTwoStage or runTestSuite or stage1_upload_directory:
Renato Golin61aed7f2015-06-17 19:12:50 +0000633 f.addStep(ShellCommand(name='install stage 1',
634 command=ninja_install_cmd,
635 description='ninja install',
636 workdir=stage1_build,
Renato Goline402f582014-09-04 19:25:24 +0000637 env=env))
Renato Goline402f582014-09-04 19:25:24 +0000638
Daniel Sandersfa222332015-12-04 14:30:39 +0000639 if stage1_upload_directory:
640 addGCSUploadSteps(f, 'stage 1', stage1_install, stage1_upload_directory,
641 env, gcs_url_property='stage1_package_gcs_url')
642
Reid Kleckner25a26b02015-03-09 22:30:25 +0000643 # Compute the cmake define flag to set the C and C++ compiler to clang. Use
644 # clang-cl if we used MSVC for stage1.
645 if not vs:
646 cc = 'clang'
647 cxx = 'clang++'
648 else:
649 cc = 'clang-cl.exe'
650 cxx = 'clang-cl.exe'
651
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000652
Renato Golin61aed7f2015-06-17 19:12:50 +0000653 ############# STAGE 2
654 if useTwoStage:
Galina Kistanova79900972015-11-16 17:30:42 +0000655 # We always cleanly build the stage 2. If the compiler has been
656 # changed on the stage 1, we cannot trust any of the intermediate file
657 # from the old compiler. And if the stage 1 compiler is the same, we
658 # should not build in the first place.
659 f.addStep(ShellCommand(name='clean stage 2',
660 command=['rm','-rf',stage2_build],
661 warnOnFailure=True,
662 description='cleaning stage 2',
663 descriptionDone='clean',
664 workdir='.',
665 env=env))
Reid Kleckner25a26b02015-03-09 22:30:25 +0000666
Renato Golin61aed7f2015-06-17 19:12:50 +0000667 # Set the compiler using the CC and CXX environment variables to work around
668 # backslash string escaping bugs somewhere between buildbot and cmake. The
669 # env.exe helper is required to run the tests, so hopefully it's already on
670 # PATH.
671 cmake_cmd2 = ['env',
672 WithProperties('CC=%(workdir)s/'+stage1_install+'/bin/'+cc),
673 WithProperties('CXX=%(workdir)s/'+stage1_install+'/bin/'+cxx),
674 cmake, "-G", "Ninja", "../llvm",
675 "-DCMAKE_BUILD_TYPE="+stage2_config,
676 "-DLLVM_ENABLE_ASSERTIONS=True",
677 "-DLLVM_LIT_ARGS="+lit_args,
678 "-DCMAKE_INSTALL_PREFIX=../"+stage2_install] + extra_cmake_args
Reid Kleckner25a26b02015-03-09 22:30:25 +0000679
Renato Golin61aed7f2015-06-17 19:12:50 +0000680 f.addStep(ShellCommand(name='cmake stage 2',
681 command=cmake_cmd2,
682 haltOnFailure=True,
683 description='cmake stage 2',
684 workdir=stage2_build,
685 doStepIf=lambda step: step.build.getProperty("exists_ninja_2") != "OK",
686 env=env))
687
688 f.addStep(WarningCountingShellCommand(name='build stage 2',
689 command=ninja_cmd,
690 haltOnFailure=True,
691 description='ninja all',
692 workdir=stage2_build,
693 env=env))
694
695 if test:
696 f.addStep(lit_test_command.LitTestCommand(name='ninja check 2',
697 command=ninja_check_cmd,
698 haltOnFailure=not runTestSuite,
699 description=["checking stage 2"],
700 descriptionDone=["stage 2 checked"],
701 workdir=stage2_build,
702 env=env))
703
704 ############# TEST SUITE
705 ## Test-Suite (stage 2 if built, stage 1 otherwise)
706 if runTestSuite:
707 compiler_path = stage1_install
708 if useTwoStage:
709 compiler_path=stage2_install
710 f.addStep(ShellCommand(name='install stage 2',
711 command=ninja_install_cmd,
712 description='ninja install 2',
Renato Golincfbd5702014-09-06 19:09:16 +0000713 workdir=stage2_build,
714 env=env))
Renato Goline402f582014-09-04 19:25:24 +0000715
Renato Golin61aed7f2015-06-17 19:12:50 +0000716 # Get generated python, lnt
717 python = WithProperties('%(workdir)s/test/sandbox/bin/python')
718 lnt = WithProperties('%(workdir)s/test/sandbox/bin/lnt')
719 lnt_setup = WithProperties('%(workdir)s/test/lnt/setup.py')
720
721 # Paths
722 sandbox = WithProperties('%(workdir)s/test/sandbox')
723 test_suite_dir = WithProperties('%(workdir)s/test/test-suite')
724
725 # Get latest built Clang (stage1 or stage2)
726 cc = WithProperties('%(workdir)s/'+compiler_path+'/bin/'+cc)
727 cxx = WithProperties('%(workdir)s/'+compiler_path+'/bin/'+cxx)
728
Renato Golin593e0d62016-09-21 17:24:56 +0000729 # LNT Command line (don't pass -jN. Users need to pass both --threads
730 # and --build-threads in nt_flags to get the same effect)
Renato Golin61aed7f2015-06-17 19:12:50 +0000731 test_suite_cmd = [python, lnt, 'runtest', 'nt',
Renato Golin61aed7f2015-06-17 19:12:50 +0000732 '--no-timestamp',
733 '--sandbox', sandbox,
734 '--test-suite', test_suite_dir,
735 '--cc', cc,
736 '--cxx', cxx]
737 # Append any option provided by the user
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000738 test_suite_cmd.extend(nt_flags)
Renato Golin61aed7f2015-06-17 19:12:50 +0000739 # Only submit if a URL has been specified
740 if submitURL is not None:
741 if not isinstance(submitURL, list):
742 submitURL = [submitURL]
743 for url in submitURL:
744 test_suite_cmd.extend(['--submit', url])
745 if testerName:
746 test_suite_cmd.extend(['--no-machdep-info', testerName])
747 # CC and CXX are needed as env for build-tools
Renato Goline6c1b3b2015-07-01 15:52:22 +0000748 test_suite_env = copy.deepcopy(env)
Renato Golin61aed7f2015-06-17 19:12:50 +0000749 test_suite_env['CC'] = cc
750 test_suite_env['CXX'] = cxx
751
752 # Steps to prepare, build and run LNT
753 f.addStep(ShellCommand(name='clean sandbox',
754 command=['rm', '-rf', 'sandbox'],
755 haltOnFailure=True,
756 description='removing sandbox directory',
757 workdir='test',
758 env=env))
759 f.addStep(ShellCommand(name='recreate sandbox',
760 command=['virtualenv', 'sandbox'],
761 haltOnFailure=True,
762 description='recreating sandbox',
763 workdir='test',
764 env=env))
765 f.addStep(ShellCommand(name='setup lit',
766 command=[python, lnt_setup, 'develop'],
767 haltOnFailure=True,
768 description='setting up LNT in sandbox',
769 workdir='test/sandbox',
770 env=env))
771 f.addStep(commands.LitTestCommand.LitTestCommand(
772 name='test-suite',
773 command=test_suite_cmd,
774 haltOnFailure=True,
775 description=['running the test suite'],
776 workdir='test/sandbox',
777 logfiles={'configure.log' : 'build/configure.log',
778 'build-tools.log' : 'build/build-tools.log',
779 'test.log' : 'build/test.log',
780 'report.json' : 'build/report.json'},
781 env=test_suite_env))
782
Renato Goline402f582014-09-04 19:25:24 +0000783 return f
784
Daniel Dunbarc51a59e2010-09-23 14:57:45 +0000785def getClangMSVCBuildFactory(update=True, clean=True, vcDrive='c', jobs=1, cmake=r"cmake"):
Daniel Dunbar44abe742009-07-19 01:59:03 +0000786 f = buildbot.process.factory.BuildFactory()
787
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000788 if update:
Daniel Dunbar44abe742009-07-19 01:59:03 +0000789 f.addStep(SVN(name='svn-llvm',
790 mode='update', baseURL='http://llvm.org/svn/llvm-project/llvm/',
791 defaultBranch='trunk',
792 workdir='llvm'))
Daniel Dunbar44abe742009-07-19 01:59:03 +0000793 f.addStep(SVN(name='svn-clang',
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000794 mode='update', baseURL='http://llvm.org/svn/llvm-project/cfe/',
Daniel Dunbar44abe742009-07-19 01:59:03 +0000795 defaultBranch='trunk',
796 workdir='llvm/tools/clang'))
David Blaikie845ae0d2012-08-10 00:51:38 +0000797 f.addStep(SVN(name='svn-clang-tools-extra',
798 mode='update', baseURL='http://llvm.org/svn/llvm-project/clang-tools-extra/',
799 defaultBranch='trunk',
800 workdir='llvm/tools/clang/tools/extra'))
Daniel Dunbar44abe742009-07-19 01:59:03 +0000801
802 # Full & fast clean.
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000803 if clean:
Daniel Dunbar44abe742009-07-19 01:59:03 +0000804 f.addStep(ShellCommand(name='clean-1',
805 command=['del','/s/q','build'],
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000806 warnOnFailure=True,
Daniel Dunbar44abe742009-07-19 01:59:03 +0000807 description='cleaning',
808 descriptionDone='clean',
809 workdir='llvm'))
810 f.addStep(ShellCommand(name='clean-2',
811 command=['rmdir','/s/q','build'],
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000812 warnOnFailure=True,
Daniel Dunbar44abe742009-07-19 01:59:03 +0000813 description='cleaning',
814 descriptionDone='clean',
815 workdir='llvm'))
816
817 # Create the project files.
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000818
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000819 # Use batch files instead of ShellCommand directly, Windows quoting is
820 # borked. FIXME: See buildbot ticket #595 and buildbot ticket #377.
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000821 f.addStep(batch_file_download.BatchFileDownload(name='cmakegen',
Daniel Dunbar06b20f12010-04-08 18:29:38 +0000822 command=[cmake,
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000823 "-DLLVM_TARGETS_TO_BUILD:=X86",
Daniel Dunbar1ddedce2010-09-24 19:57:34 +0000824 "-DLLVM_INCLUDE_EXAMPLES:=OFF",
825 "-DLLVM_INCLUDE_TESTS:=OFF",
826 "-DLLVM_TARGETS_TO_BUILD:=X86",
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000827 "-G",
828 "Visual Studio 9 2008",
829 ".."],
830 workdir="llvm\\build"))
Daniel Dunbar44abe742009-07-19 01:59:03 +0000831 f.addStep(ShellCommand(name='cmake',
832 command=['cmakegen.bat'],
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000833 haltOnFailure=True,
Daniel Dunbar44abe742009-07-19 01:59:03 +0000834 description='cmake gen',
835 workdir='llvm\\build'))
836
837 # Build it.
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000838 f.addStep(batch_file_download.BatchFileDownload(name='vcbuild',
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000839 command=[vcDrive + r""":\Program Files\Microsoft Visual Studio 9.0\VC\VCPackages\vcbuild.exe""",
840 "/M%d" % jobs,
841 "LLVM.sln",
842 "Debug|Win32"],
843 workdir="llvm\\build"))
Daniel Dunbar44abe742009-07-19 01:59:03 +0000844 f.addStep(WarningCountingShellCommand(name='vcbuild',
845 command=['vcbuild.bat'],
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000846 haltOnFailure=True,
Daniel Dunbar44abe742009-07-19 01:59:03 +0000847 description='vcbuild',
848 workdir='llvm\\build',
849 warningPattern=" warning C.*:"))
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000850
851 # Build clang-test project.
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000852 f.addStep(batch_file_download.BatchFileDownload(name='vcbuild_test',
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000853 command=[vcDrive + r""":\Program Files\Microsoft Visual Studio 9.0\VC\VCPackages\vcbuild.exe""",
854 "clang-test.vcproj",
855 "Debug|Win32"],
856 workdir="llvm\\build\\tools\\clang\\test"))
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000857 f.addStep(lit_test_command.LitTestCommand(name='test-clang',
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000858 command=["vcbuild_test.bat"],
859 workdir="llvm\\build\\tools\\clang\\test"))
860
Daniel Dunbar44abe742009-07-19 01:59:03 +0000861 return f
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000862
Daniel Dunbar7363d032011-02-27 03:22:35 +0000863def addClangGCCTests(f, ignores={}, install_prefix="%(builddir)s/llvm.install",
864 languages = ('gcc', 'g++', 'objc', 'obj-c++')):
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000865 make_vars = [WithProperties(
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000866 'CC_UNDER_TEST=%s/bin/clang' % install_prefix),
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000867 WithProperties(
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000868 'CXX_UNDER_TEST=%s/bin/clang++' % install_prefix)]
David Blaikie05517332013-12-19 23:29:12 +0000869 f.addStep(SVN(name='svn-clang-gcc-tests', mode='update',
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000870 baseURL='http://llvm.org/svn/llvm-project/clang-tests/',
871 defaultBranch='trunk', workdir='clang-tests'))
872 gcc_dg_ignores = ignores.get('gcc-4_2-testsuite', {})
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000873 for lang in languages:
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000874 f.addStep(commands.SuppressionDejaGNUCommand.SuppressionDejaGNUCommand(
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000875 name='test-gcc-4_2-testsuite-%s' % lang,
876 command=["make", "-k", "check-%s" % lang] + make_vars,
877 description="gcc-4_2-testsuite (%s)" % lang,
878 workdir='clang-tests/gcc-4_2-testsuite',
David Dean2bd0c3a2011-10-18 16:36:28 +0000879 logfiles={ 'dg.sum' : 'obj/%s/%s.sum' % (lang, lang),
880 '%s.log' % lang : 'obj/%s/%s.log' % (lang, lang)},
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000881 ignore=gcc_dg_ignores.get(lang, [])))
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000882
Daniel Dunbar7363d032011-02-27 03:22:35 +0000883def addClangGDBTests(f, ignores={}, install_prefix="%(builddir)s/llvm.install"):
884 make_vars = [WithProperties(
885 'CC_UNDER_TEST=%s/bin/clang' % install_prefix),
886 WithProperties(
887 'CXX_UNDER_TEST=%s/bin/clang++' % install_prefix)]
David Blaikie05517332013-12-19 23:29:12 +0000888 f.addStep(SVN(name='svn-clang-gdb-tests', mode='update',
Daniel Dunbar7363d032011-02-27 03:22:35 +0000889 baseURL='http://llvm.org/svn/llvm-project/clang-tests/',
890 defaultBranch='trunk', workdir='clang-tests'))
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000891 f.addStep(commands.SuppressionDejaGNUCommand.SuppressionDejaGNUCommand(
Daniel Dunbar7363d032011-02-27 03:22:35 +0000892 name='test-gdb-1472-testsuite',
893 command=["make", "-k", "check"] + make_vars,
894 description="gdb-1472-testsuite",
895 workdir='clang-tests/gdb-1472-testsuite',
David Blaikie7ec695f2012-10-09 22:17:09 +0000896 logfiles={ 'dg.sum' : 'obj/filtered.gdb.sum',
David Blaikie624f4392012-11-05 22:34:35 +0000897 'gdb.log' : 'obj/gdb.log' }))
Daniel Dunbar7363d032011-02-27 03:22:35 +0000898
David Blaikie41d09c32013-01-02 21:11:09 +0000899def addModernClangGDBTests(f, jobs, install_prefix):
David Blaikie1bc5c372012-12-05 05:29:12 +0000900 make_vars = [WithProperties('RUNTESTFLAGS=CC_FOR_TARGET=\'{0}/bin/clang\' '
901 'CXX_FOR_TARGET=\'{0}/bin/clang++\' '
David Blaikie759bb752013-04-18 23:13:11 +0000902 'CFLAGS_FOR_TARGET=\'-w -fno-limit-debug-info\''
David Blaikief89877b2013-01-29 23:46:26 +0000903 .format(install_prefix))]
David Blaikie05517332013-12-19 23:29:12 +0000904 f.addStep(SVN(name='svn-clang-modern-gdb-tests', mode='update',
David Blaikief3f300b2012-11-17 01:13:41 +0000905 svnurl='http://llvm.org/svn/llvm-project/clang-tests-external/trunk/gdb/7.5',
David Blaikiedad03d52012-11-16 22:37:12 +0000906 workdir='clang-tests/src'))
David Blaikieb83bfdf2012-12-05 04:33:42 +0000907 f.addStep(Configure(command='../src/configure',
David Blaikief3f300b2012-11-17 01:13:41 +0000908 workdir='clang-tests/build/'))
David Blaikieb83bfdf2012-12-05 04:33:42 +0000909 f.addStep(WarningCountingShellCommand(name='gdb-75-build',
910 command=['make', WithProperties('-j%s' % jobs)],
911 haltOnFailure=True,
912 workdir='clang-tests/build'))
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000913 f.addStep(commands.DejaGNUCommand.DejaGNUCommand(
David Blaikiedad03d52012-11-16 22:37:12 +0000914 name='gdb-75-check',
David Blaikieb83bfdf2012-12-05 04:33:42 +0000915 command=['make', '-k', WithProperties('-j%s' % jobs), 'check'] + make_vars,
David Blaikiedad03d52012-11-16 22:37:12 +0000916 workdir='clang-tests/build',
David Blaikie1bc5c372012-12-05 05:29:12 +0000917 logfiles={'dg.sum':'gdb/testsuite/gdb.sum',
918 'gdb.log':'gdb/testsuite/gdb.log'}))
David Blaikiedad03d52012-11-16 22:37:12 +0000919
920
921
Daniel Dunbar7363d032011-02-27 03:22:35 +0000922# FIXME: Deprecated.
923addClangTests = addClangGCCTests
924
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000925def getClangTestsIgnoresFromPath(path, key):
926 def readList(path):
927 if not os.path.exists(path):
928 return []
929
930 f = open(path)
931 lines = [ln.strip() for ln in f]
932 f.close()
933 return lines
934
935 ignores = {}
936
937 gcc_dg_ignores = {}
938 for lang in ('gcc', 'g++', 'objc', 'obj-c++'):
939 lang_path = os.path.join(path, 'gcc-4_2-testsuite', 'expected_results',
940 key, lang)
941 gcc_dg_ignores[lang] = (
942 readList(os.path.join(lang_path, 'FAIL.txt')) +
943 readList(os.path.join(lang_path, 'UNRESOLVED.txt')) +
944 readList(os.path.join(lang_path, 'XPASS.txt')))
945 ignores['gcc-4_2-testsuite' ] = gcc_dg_ignores
946
Daniel Dunbar7363d032011-02-27 03:22:35 +0000947 ignores_path = os.path.join(path, 'gdb-1472-testsuite', 'expected_results',
948 key)
949 gdb_dg_ignores = (
950 readList(os.path.join(ignores_path, 'FAIL.txt')) +
951 readList(os.path.join(ignores_path, 'UNRESOLVED.txt')) +
952 readList(os.path.join(ignores_path, 'XPASS.txt')))
953 ignores['gdb-1472-testsuite' ] = gdb_dg_ignores
954
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000955 return ignores
David Deanf8b35442012-12-11 00:35:12 +0000956