blob: 96e1fdf123186facf2517d883f4600678ebad57f [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
Galina Kistanova5921add2018-11-14 05:34:46 +000020from zorg.buildbot.process.factory import LLVMBuildFactory
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +000021
Galina Kistanovaf4d79352011-10-20 20:46:52 +000022def getClangBuildFactory(
23 triple=None,
24 clean=True,
25 test=True,
26 package_dst=None,
27 run_cxx_tests=False,
28 examples=False,
29 valgrind=False,
30 valgrindLeakCheck=False,
Galina Kistanovaf4d79352011-10-20 20:46:52 +000031 useTwoStage=False,
32 completely_clean=False,
Galina Kistanovaf4d79352011-10-20 20:46:52 +000033 make='make',
34 jobs="%(jobs)s",
35 stage1_config='Debug+Asserts',
36 stage2_config='Release+Asserts',
37 env={}, # Environmental variables for all steps.
38 extra_configure_args=[],
Vassil Vassilev5a9b9ed2016-05-25 17:10:03 +000039 stage2_extra_configure_args=[],
Galina Kistanovaf4d79352011-10-20 20:46:52 +000040 use_pty_in_tests=False,
Peter Collingbourned49ac282011-10-25 14:38:45 +000041 trunk_revision=None,
42 force_checkout=False,
Peter Collingbourne7a95b0c2011-10-26 16:40:17 +000043 extra_clean_step=None,
David Blaikiea76da842012-08-13 22:24:46 +000044 checkout_compiler_rt=False,
Galina Kistanova2ab1e2d2016-11-22 00:23:43 +000045 checkout_lld=False,
David Blaikiea76da842012-08-13 22:24:46 +000046 run_gdb=False,
David Blaikiedad03d52012-11-16 22:37:12 +000047 run_modern_gdb=False,
Vassil Vassilev0c647ef2016-06-30 21:16:45 +000048 run_gcc=False):
Galina Kistanovaf4d79352011-10-20 20:46:52 +000049 # Prepare environmental variables. Set here all env we want everywhere.
50 merged_env = {
51 'TERM' : 'dumb' # Make sure Clang doesn't use color escape sequences.
52 }
53 if env is not None:
54 # Overwrite pre-set items with the given ones, so user can set anything.
55 merged_env.update(env)
David Blaikie2f7eb282012-08-24 18:37:00 +000056
Jonathan Roelofs62415e52015-02-28 00:03:17 +000057 llvm_srcdir = "llvm.src"
58 llvm_1_objdir = "llvm.obj"
59 llvm_1_installdir = "llvm.install.1"
60 llvm_2_objdir = "llvm.obj.2"
61 llvm_2_installdir = "llvm.install"
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +000062
Daniel Dunbar235aa412009-07-18 07:16:15 +000063 f = buildbot.process.factory.BuildFactory()
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +000064
65 # Determine the build directory.
66 f.addStep(buildbot.steps.shell.SetProperty(name="get_builddir",
67 command=["pwd"],
68 property="builddir",
69 description="set build dir",
Galina Kistanovaf4d79352011-10-20 20:46:52 +000070 workdir=".",
71 env=merged_env))
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +000072
Daniel Dunbar06b20f12010-04-08 18:29:38 +000073 # Blow away completely, if requested.
74 if completely_clean:
75 f.addStep(ShellCommand(name="rm-llvm.src",
76 command=["rm", "-rf", llvm_srcdir],
77 haltOnFailure=True,
78 description=["rm src dir", "llvm"],
Galina Kistanovaf4d79352011-10-20 20:46:52 +000079 workdir=".",
80 env=merged_env))
Daniel Dunbar06b20f12010-04-08 18:29:38 +000081
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +000082 # Checkout sources.
Peter Collingbourned49ac282011-10-25 14:38:45 +000083 if trunk_revision:
84 # The SVN build step provides no mechanism to check out a specific revision
85 # based on a property, so just run the commands directly here.
86 svn_co = ['svn', 'checkout']
87 if force_checkout:
88 svn_co += ['--force']
89 svn_co += ['--revision', WithProperties(trunk_revision)]
90
91 svn_co_llvm = svn_co + \
92 [WithProperties('http://llvm.org/svn/llvm-project/llvm/trunk@%s' %
93 trunk_revision),
94 llvm_srcdir]
95 svn_co_clang = svn_co + \
96 [WithProperties('http://llvm.org/svn/llvm-project/cfe/trunk@%s' %
97 trunk_revision),
98 '%s/tools/clang' % llvm_srcdir]
David Blaikie845ae0d2012-08-10 00:51:38 +000099 svn_co_clang_tools_extra = svn_co + \
100 [WithProperties('http://llvm.org/svn/llvm-project/clang-tools-extra/trunk@%s' %
101 trunk_revision),
102 '%s/tools/clang/tools/extra' % llvm_srcdir]
Peter Collingbourned49ac282011-10-25 14:38:45 +0000103
104 f.addStep(ShellCommand(name='svn-llvm',
105 command=svn_co_llvm,
106 haltOnFailure=True,
107 workdir='.'))
108 f.addStep(ShellCommand(name='svn-clang',
109 command=svn_co_clang,
110 haltOnFailure=True,
111 workdir='.'))
David Blaikie845ae0d2012-08-10 00:51:38 +0000112 f.addStep(ShellCommand(name='svn-clang-tools-extra',
113 command=svn_co_clang_tools_extra,
114 haltOnFailure=True,
115 workdir='.'))
Peter Collingbourned49ac282011-10-25 14:38:45 +0000116 else:
117 f.addStep(SVN(name='svn-llvm',
Daniel Dunbarf4e23eb2010-09-20 21:13:02 +0000118 mode='update',
Peter Collingbourned49ac282011-10-25 14:38:45 +0000119 baseURL='http://llvm.org/svn/llvm-project/llvm/',
Daniel Dunbarf4e23eb2010-09-20 21:13:02 +0000120 defaultBranch='trunk',
Peter Collingbourned49ac282011-10-25 14:38:45 +0000121 workdir=llvm_srcdir))
122 f.addStep(SVN(name='svn-clang',
123 mode='update',
124 baseURL='http://llvm.org/svn/llvm-project/cfe/',
125 defaultBranch='trunk',
126 workdir='%s/tools/clang' % llvm_srcdir))
David Blaikie845ae0d2012-08-10 00:51:38 +0000127 f.addStep(SVN(name='svn-clang-tools-extra',
128 mode='update',
129 baseURL='http://llvm.org/svn/llvm-project/clang-tools-extra/',
130 defaultBranch='trunk',
131 workdir='%s/tools/clang/tools/extra' % llvm_srcdir))
Peter Collingbourned49ac282011-10-25 14:38:45 +0000132 if checkout_compiler_rt:
133 f.addStep(SVN(name='svn-compiler-rt',
134 mode='update',
135 baseURL='http://llvm.org/svn/llvm-project/compiler-rt/',
136 defaultBranch='trunk',
137 workdir='%s/projects/compiler-rt' % llvm_srcdir))
Daniel Dunbarfa0e0222009-11-09 06:08:28 +0000138
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000139 # Clean up llvm (stage 1); unless in-dir.
140 if clean and llvm_srcdir != llvm_1_objdir:
141 f.addStep(ShellCommand(name="rm-llvm.obj.stage1",
142 command=["rm", "-rf", llvm_1_objdir],
143 haltOnFailure=True,
144 description=["rm build dir", "llvm"],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000145 workdir=".",
146 env=merged_env))
Andrew Trick70fa9d22011-08-25 23:38:51 +0000147
David Blaikie8cbf62f2013-01-12 21:32:31 +0000148 if not clean:
Galina Kistanovaa06e4c82016-04-14 21:41:30 +0000149 expected_makefile = 'Makefile'
David Blaikie8cbf62f2013-01-12 21:32:31 +0000150 f.addStep(SetProperty(name="Makefile_isready",
151 workdir=llvm_1_objdir,
152 command=["sh", "-c",
Richard Smith02389162014-09-26 23:53:06 +0000153 "test -e %s && echo OK || echo Missing" % expected_makefile],
David Blaikie8cbf62f2013-01-12 21:32:31 +0000154 flunkOnFailure=False,
Galina Kistanovaa06e4c82016-04-14 21:41:30 +0000155 property="exists_Makefile"))
Richard Smith02389162014-09-26 23:53:06 +0000156
Galina Kistanovaa06e4c82016-04-14 21:41:30 +0000157 cmake_triple_arg = []
158 if triple:
159 cmake_triple_arg = ['-DLLVM_HOST_TRIPLE=%s' % triple]
160 f.addStep(ShellCommand(name='cmake',
161 command=['cmake',
162 '-DLLVM_BUILD_TESTS=ON',
163 '-DCMAKE_BUILD_TYPE=%s' % stage1_config] +
164 cmake_triple_arg +
165 extra_configure_args +
166 ["../" + llvm_srcdir],
167 description='cmake stage1',
168 workdir=llvm_1_objdir,
169 env=merged_env,
170 doStepIf=lambda step: step.build.getProperty("exists_Makefile") != "OK"))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000171
172 # Make clean if using in-dir builds.
173 if clean and llvm_srcdir == llvm_1_objdir:
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000174 f.addStep(WarningCountingShellCommand(name="clean-llvm",
Daniel Dunbard20468a2009-11-24 18:27:23 +0000175 command=[make, "clean"],
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000176 haltOnFailure=True,
177 description="cleaning llvm",
178 descriptionDone="clean llvm",
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000179 workdir=llvm_1_objdir,
Peter Collingbourne7a95b0c2011-10-26 16:40:17 +0000180 doStepIf=clean,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000181 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000182
Peter Collingbourne7a95b0c2011-10-26 16:40:17 +0000183 if extra_clean_step:
184 f.addStep(extra_clean_step)
185
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000186 f.addStep(WarningCountingShellCommand(name="compile",
Daniel Dunbard20468a2009-11-24 18:27:23 +0000187 command=['nice', '-n', '10',
188 make, WithProperties("-j%s" % jobs)],
Daniel Dunbar7e959c82009-09-28 04:01:19 +0000189 haltOnFailure=True,
David Blaikie05517332013-12-19 23:29:12 +0000190 flunkOnFailure=not run_gdb,
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000191 description=["compiling", stage1_config],
192 descriptionDone=["compile", stage1_config],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000193 workdir=llvm_1_objdir,
194 env=merged_env))
Daniel Dunbar256fed42009-11-25 21:11:08 +0000195
196 if examples:
197 f.addStep(WarningCountingShellCommand(name="compile.examples",
198 command=['nice', '-n', '10',
199 make, WithProperties("-j%s" % jobs),
200 "BUILD_EXAMPLES=1"],
201 haltOnFailure=True,
Richard Smith65e6f5d2014-09-25 18:18:35 +0000202 description=["compiling", stage1_config, "examples"],
Daniel Dunbar256fed42009-11-25 21:11:08 +0000203 descriptionDone=["compile", stage1_config, "examples"],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000204 workdir=llvm_1_objdir,
205 env=merged_env))
Daniel Dunbar256fed42009-11-25 21:11:08 +0000206
NAKAMURA Takumi1a4666b2013-01-19 03:39:07 +0000207 clangTestArgs = '-v -j %s' % jobs
Daniel Dunbarfa0e0222009-11-09 06:08:28 +0000208 if valgrind:
Daniel Dunbar89184b92010-04-18 19:09:32 +0000209 clangTestArgs += ' --vg'
Daniel Dunbara1bebce2010-03-21 01:24:00 +0000210 if valgrindLeakCheck:
211 clangTestArgs += ' --vg-leak'
Nick Lewycky8d26e472011-08-27 21:18:56 +0000212 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 +0000213 extraTestDirs = ''
214 if run_cxx_tests:
215 extraTestDirs += '%(builddir)s/llvm/tools/clang/utils/C++Tests'
Daniel Dunbarb51f6ab2009-11-09 03:09:23 +0000216 if test:
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000217 f.addStep(lit_test_command.LitTestCommand(name='check-all',
David Blaikie7e6f8a12012-08-31 20:46:27 +0000218 command=[make, "check-all", "VERBOSE=1",
NAKAMURA Takumi1a4666b2013-01-19 03:39:07 +0000219 WithProperties("LIT_ARGS=%s" % clangTestArgs),
David Blaikiebc684012012-12-27 20:44:19 +0000220 WithProperties("EXTRA_TESTDIRS=%s" % extraTestDirs)],
David Blaikie05517332013-12-19 23:29:12 +0000221 flunkOnFailure=not run_gdb,
David Blaikie7e6f8a12012-08-31 20:46:27 +0000222 description=["checking"],
223 descriptionDone=["checked"],
Daniel Dunbar469e8ca2010-05-19 21:26:48 +0000224 workdir=llvm_1_objdir,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000225 usePTY=use_pty_in_tests,
226 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000227
Galina Kistanovaa06e4c82016-04-14 21:41:30 +0000228 # TODO: Install llvm and clang for stage1.
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000229
David Blaikiedad03d52012-11-16 22:37:12 +0000230 if run_gdb or run_gcc or run_modern_gdb:
David Blaikiea76da842012-08-13 22:24:46 +0000231 ignores = getClangTestsIgnoresFromPath(os.path.expanduser('~/public/clang-tests'), 'clang-x86_64-darwin10')
232 install_prefix = "%%(builddir)s/%s" % llvm_1_installdir
233 if run_gdb:
234 addClangGDBTests(f, ignores, install_prefix)
David Blaikiedad03d52012-11-16 22:37:12 +0000235 if run_modern_gdb:
David Blaikie41d09c32013-01-02 21:11:09 +0000236 addModernClangGDBTests(f, jobs, install_prefix)
David Blaikiea76da842012-08-13 22:24:46 +0000237 if run_gcc:
238 addClangGCCTests(f, ignores, install_prefix)
239
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000240 if not useTwoStage:
Daniel Dunbardedf6572010-11-13 00:23:34 +0000241 if package_dst:
242 name = WithProperties(
243 "%(builddir)s/" + llvm_1_objdir +
244 "/clang-r%(got_revision)s-b%(buildnumber)s.tgz")
245 f.addStep(ShellCommand(name='pkg.tar',
246 description="tar root",
247 command=["tar", "zcvf", name, "./"],
248 workdir=llvm_1_installdir,
249 warnOnFailure=True,
250 flunkOnFailure=False,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000251 haltOnFailure=False,
252 env=merged_env))
Daniel Dunbardedf6572010-11-13 00:23:34 +0000253 f.addStep(ShellCommand(name='pkg.upload',
Andrew Trick70fa9d22011-08-25 23:38:51 +0000254 description="upload root",
Daniel Dunbardedf6572010-11-13 00:23:34 +0000255 command=["scp", name,
256 WithProperties(
257 package_dst + "/%(buildername)s")],
258 workdir=".",
259 warnOnFailure=True,
260 flunkOnFailure=False,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000261 haltOnFailure=False,
262 env=merged_env))
Daniel Dunbardedf6572010-11-13 00:23:34 +0000263
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000264 return f
265
266 # Clean up llvm (stage 2).
Richard Smith02389162014-09-26 23:53:06 +0000267 #
Galina Kistanova79900972015-11-16 17:30:42 +0000268 # We always cleanly build the stage 2. If the compiler has been
269 # changed on the stage 1, we cannot trust any of the intermediate file
270 # from the old compiler. And if the stage 1 compiler is the same, we should
271 # not build in the first place.
272 f.addStep(ShellCommand(name="rm-llvm.obj.stage2",
273 command=["rm", "-rf", llvm_2_objdir],
274 haltOnFailure=True,
275 description=["rm build dir", "llvm", "(stage 2)"],
276 workdir=".",
277 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000278
279 # Configure llvm (stage 2).
Galina Kistanovaa06e4c82016-04-14 21:41:30 +0000280 f.addStep(ShellCommand(name='cmake',
Vassil Vassilev5a9b9ed2016-05-25 17:10:03 +0000281 command=['cmake'] + stage2_extra_configure_args + [
Galina Kistanovaa06e4c82016-04-14 21:41:30 +0000282 '-DLLVM_BUILD_TESTS=ON',
283 WithProperties('-DCMAKE_C_COMPILER=%%(builddir)s/%s/bin/clang' % llvm_1_objdir), # FIXME use installdir
284 WithProperties('-DCMAKE_CXX_COMPILER=%%(builddir)s/%s/bin/clang++' % llvm_1_objdir),
285 '-DCMAKE_BUILD_TYPE=%s' % stage2_config,
Galina Kistanovaa06e4c82016-04-14 21:41:30 +0000286 "../" + llvm_srcdir],
287 description='cmake stage2',
288 workdir=llvm_2_objdir,
289 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000290
291 # Build llvm (stage 2).
292 f.addStep(WarningCountingShellCommand(name="compile.llvm.stage2",
293 command=['nice', '-n', '10',
294 make, WithProperties("-j%s" % jobs)],
295 haltOnFailure=True,
296 description=["compiling", "(stage 2)",
297 stage2_config],
298 descriptionDone=["compile", "(stage 2)",
299 stage2_config],
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000300 workdir=llvm_2_objdir,
301 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000302
303 if test:
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000304 f.addStep(lit_test_command.LitTestCommand(name='check-all',
David Blaikie7e6f8a12012-08-31 20:46:27 +0000305 command=[make, "check-all", "VERBOSE=1",
NAKAMURA Takumi1a4666b2013-01-19 03:39:07 +0000306 WithProperties("LIT_ARGS=%s" % clangTestArgs),
David Blaikiebc684012012-12-27 20:44:19 +0000307 WithProperties("EXTRA_TESTDIRS=%s" % extraTestDirs)],
David Blaikie7e6f8a12012-08-31 20:46:27 +0000308 description=["checking"],
309 descriptionDone=["checked"],
Daniel Dunbar469e8ca2010-05-19 21:26:48 +0000310 workdir=llvm_2_objdir,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000311 usePTY=use_pty_in_tests,
312 env=merged_env))
Daniel Dunbar8a89a6f2009-11-25 04:27:32 +0000313
Galina Kistanovaa06e4c82016-04-14 21:41:30 +0000314 # TODO: Install llvm and clang for stage2.
Daniel Dunbar3efb7822010-02-26 19:20:00 +0000315
316 if package_dst:
317 name = WithProperties(
318 "%(builddir)s/" + llvm_2_objdir +
319 "/clang-r%(got_revision)s-b%(buildnumber)s.tgz")
320 f.addStep(ShellCommand(name='pkg.tar',
321 description="tar root",
322 command=["tar", "zcvf", name, "./"],
323 workdir=llvm_2_installdir,
324 warnOnFailure=True,
325 flunkOnFailure=False,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000326 haltOnFailure=False,
327 env=merged_env))
Daniel Dunbar3efb7822010-02-26 19:20:00 +0000328 f.addStep(ShellCommand(name='pkg.upload',
Andrew Trick70fa9d22011-08-25 23:38:51 +0000329 description="upload root",
Daniel Dunbar3efb7822010-02-26 19:20:00 +0000330 command=["scp", name,
331 WithProperties(
332 package_dst + "/%(buildername)s")],
333 workdir=".",
334 warnOnFailure=True,
335 flunkOnFailure=False,
Galina Kistanovaf4d79352011-10-20 20:46:52 +0000336 haltOnFailure=False,
337 env=merged_env))
Daniel Dunbar3efb7822010-02-26 19:20:00 +0000338
Daniel Dunbar235aa412009-07-18 07:16:15 +0000339 return f
Daniel Dunbar44abe742009-07-19 01:59:03 +0000340
Daniel Sandersfa222332015-12-04 14:30:39 +0000341def addGCSUploadSteps(f, package_name, install_prefix, gcs_directory, env,
Leandro Nunes7b83ba42018-06-25 13:54:50 +0000342 gcs_url_property=None, use_pixz_compression=False,
343 xz_compression_factor=6):
Daniel Sandersfa222332015-12-04 14:30:39 +0000344 """
345 Add steps to upload to the Google Cloud Storage bucket.
346
347 f - The BuildFactory to modify.
348 package_name - The name of this package for the descriptions (e.g.
349 'stage 1')
350 install_prefix - The directory the build has been installed to.
351 gcs_directory - The subdirectory of the bucket root to upload to. This
352 should match the builder name.
353 env - The environment to use. Set BOTO_CONFIG to use a configuration file
354 in a non-standard location, and BUCKET to use a different GCS bucket.
355 gcs_url_property - Property to assign the GCS url to.
356 """
357
358 gcs_url_fmt = ('gs://%(gcs_bucket)s/%(gcs_directory)s/'
359 'clang-r%(got_revision)s-t%(now)s-b%(buildnumber)s.tar.xz')
360 time_fmt = '%Y-%m-%d_%H-%M-%S'
Leandro Nunes7b83ba42018-06-25 13:54:50 +0000361 output_file_name = '../install.tar.xz'
362
Daniel Sandersfa222332015-12-04 14:30:39 +0000363 gcs_url = \
364 WithProperties(
365 gcs_url_fmt,
366 gcs_bucket=lambda _: env.get('BUCKET', 'llvm-build-artifacts'),
367 gcs_directory=lambda _: gcs_directory,
368 now=lambda _: datetime.utcnow().strftime(time_fmt))
369
370 if gcs_url_property:
371 f.addStep(SetProperty(
372 name="record GCS url for " + package_name,
373 command=['echo', gcs_url],
374 property=gcs_url_property))
375
Leandro Nunes7b83ba42018-06-25 13:54:50 +0000376 if use_pixz_compression:
377 # tweak the xz compression level to generate packages faster
378 tar_command = ['tar', '-Ipixz', '-cvf', output_file_name, '.']
379 else:
380 xz_command = 'xz -{0}'.format(xz_compression_factor)
381 tar_command = ['tar', '-I', xz_command, '-cvf', output_file_name, '.']
382
Daniel Sandersfa222332015-12-04 14:30:39 +0000383 f.addStep(ShellCommand(name='package ' + package_name,
Leandro Nunes7b83ba42018-06-25 13:54:50 +0000384 command=tar_command,
Daniel Sandersfa222332015-12-04 14:30:39 +0000385 description='packaging ' + package_name + '...',
386 workdir=install_prefix,
387 env=env))
388
389 f.addStep(ShellCommand(
390 name='upload ' + package_name + ' to storage bucket',
391 command=['gsutil', 'cp', '../install.tar.xz', gcs_url],
392 description=('uploading ' + package_name +
393 'to storage bucket ...'),
394 workdir=install_prefix,
395 env=env))
396
397def getClangCMakeGCSBuildFactory(
398 clean=True,
399 test=True,
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000400 cmake='cmake',
Daniel Sandersfa222332015-12-04 14:30:39 +0000401 jobs=None,
402
403 # VS tools environment variable if using MSVC. For example,
404 # %VS120COMNTOOLS% selects the 2013 toolchain.
405 vs=None,
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000406 vs_target_arch='x86',
Daniel Sandersfa222332015-12-04 14:30:39 +0000407
408 # Multi-stage compilation
409 useTwoStage=False,
410 testStage1=True,
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000411 stage1_config='Release',
412 stage2_config='Release',
Daniel Sandersfa222332015-12-04 14:30:39 +0000413
414 # Test-suite
415 runTestSuite=False,
Galina Kistanova84b11952019-10-17 04:07:11 +0000416 nt_flags=None,
417 testsuite_flags=None,
Daniel Sandersfa222332015-12-04 14:30:39 +0000418 submitURL=None,
419 testerName=None,
420
421 # Environmental variables for all steps.
Galina Kistanova84b11952019-10-17 04:07:11 +0000422 env=None,
423 extra_cmake_args=None,
Daniel Sandersfa222332015-12-04 14:30:39 +0000424
425 # Extra repositories
426 checkout_clang_tools_extra=True,
427 checkout_compiler_rt=True,
Renato Golin0bd2a532016-11-20 16:14:35 +0000428 checkout_lld=True,
Leandro Nunes7b83ba42018-06-25 13:54:50 +0000429 checkout_libcxx=False,
Daniel Sandersfa222332015-12-04 14:30:39 +0000430
431 # Upload artifacts to Google Cloud Storage (for the llvmbisect tool)
432 stage1_upload_directory=None,
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000433
Leandro Nunes7b83ba42018-06-25 13:54:50 +0000434 # Use a lower compression level to generate the build-cache package faster.
435 # defuault is 6 according to xz documentation
436 xz_compression_factor=6,
437 use_pixz_compression=False,
438
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000439 # Triggers
Galina Kistanova84b11952019-10-17 04:07:11 +0000440 trigger_after_stage1=None):
Daniel Sandersfa222332015-12-04 14:30:39 +0000441 return _getClangCMakeBuildFactory(
Stella Stamenovae9bbc272018-10-26 18:17:50 +0000442 clean=clean, test=test, cmake=cmake, jobs=jobs, vs=vs,
443 vs_target_arch=vs_target_arch, useTwoStage=useTwoStage,
Daniel Sandersfa222332015-12-04 14:30:39 +0000444 testStage1=testStage1, stage1_config=stage1_config,
445 stage2_config=stage2_config, runTestSuite=runTestSuite,
Kristof Beylsf4639b52017-08-10 08:53:52 +0000446 nt_flags=nt_flags, testsuite_flags=testsuite_flags,
447 submitURL=submitURL, testerName=testerName,
Daniel Sandersfa222332015-12-04 14:30:39 +0000448 env=env, extra_cmake_args=extra_cmake_args,
449 checkout_clang_tools_extra=checkout_clang_tools_extra,
450 checkout_compiler_rt=checkout_compiler_rt,
Renato Golin0bd2a532016-11-20 16:14:35 +0000451 checkout_lld=checkout_lld,
Leandro Nunes7b83ba42018-06-25 13:54:50 +0000452 checkout_libcxx=checkout_libcxx,
Daniel Sandersfa222332015-12-04 14:30:39 +0000453 stage1_upload_directory=stage1_upload_directory,
Leandro Nunes7b83ba42018-06-25 13:54:50 +0000454 xz_compression_factor=xz_compression_factor,
455 use_pixz_compression=use_pixz_compression,
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000456 trigger_after_stage1=trigger_after_stage1)
Reid Kleckner25a26b02015-03-09 22:30:25 +0000457
458def getClangCMakeBuildFactory(
459 clean=True,
460 test=True,
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000461 cmake='cmake',
Reid Kleckner25a26b02015-03-09 22:30:25 +0000462 jobs=None,
463
464 # VS tools environment variable if using MSVC. For example,
465 # %VS120COMNTOOLS% selects the 2013 toolchain.
466 vs=None,
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000467 vs_target_arch='x86',
Reid Kleckner25a26b02015-03-09 22:30:25 +0000468
469 # Multi-stage compilation
470 useTwoStage=False,
471 testStage1=True,
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000472 stage1_config='Release',
473 stage2_config='Release',
Reid Kleckner25a26b02015-03-09 22:30:25 +0000474
Renato Golin61aed7f2015-06-17 19:12:50 +0000475 # Test-suite
476 runTestSuite=False,
Galina Kistanova84b11952019-10-17 04:07:11 +0000477 nt_flags=None,
478 testsuite_flags=None,
Renato Golin61aed7f2015-06-17 19:12:50 +0000479 submitURL=None,
480 testerName=None,
481
Reid Kleckner25a26b02015-03-09 22:30:25 +0000482 # Environmental variables for all steps.
Galina Kistanova84b11952019-10-17 04:07:11 +0000483 env=None,
484 extra_cmake_args=None,
Reid Kleckner25a26b02015-03-09 22:30:25 +0000485
486 # Extra repositories
487 checkout_clang_tools_extra=True,
Renato Golin0bd2a532016-11-20 16:14:35 +0000488 checkout_compiler_rt=True,
Artem Belevich16fcd0e2016-12-21 21:15:56 +0000489 checkout_lld=True,
490 checkout_libcxx=False,
491 checkout_test_suite=False):
Daniel Sandersfa222332015-12-04 14:30:39 +0000492 return _getClangCMakeBuildFactory(
Stella Stamenovae9bbc272018-10-26 18:17:50 +0000493 clean=clean, test=test, cmake=cmake, jobs=jobs, vs=vs,
494 vs_target_arch=vs_target_arch, useTwoStage=useTwoStage,
Daniel Sandersfa222332015-12-04 14:30:39 +0000495 testStage1=testStage1, stage1_config=stage1_config,
496 stage2_config=stage2_config, runTestSuite=runTestSuite,
Kristof Beylsf4639b52017-08-10 08:53:52 +0000497 nt_flags=nt_flags, testsuite_flags=testsuite_flags,
498 submitURL=submitURL, testerName=testerName,
Daniel Sandersfa222332015-12-04 14:30:39 +0000499 env=env, extra_cmake_args=extra_cmake_args,
500 checkout_clang_tools_extra=checkout_clang_tools_extra,
Renato Golin0bd2a532016-11-20 16:14:35 +0000501 checkout_lld=checkout_lld,
Artem Belevich16fcd0e2016-12-21 21:15:56 +0000502 checkout_compiler_rt=checkout_compiler_rt,
503 checkout_libcxx=checkout_libcxx,
504 checkout_test_suite=checkout_test_suite)
Daniel Sandersfa222332015-12-04 14:30:39 +0000505
506def _getClangCMakeBuildFactory(
507 clean=True,
508 test=True,
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000509 cmake='cmake',
Daniel Sandersfa222332015-12-04 14:30:39 +0000510 jobs=None,
511
512 # VS tools environment variable if using MSVC. For example,
513 # %VS120COMNTOOLS% selects the 2013 toolchain.
514 vs=None,
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000515 vs_target_arch='x86',
Daniel Sandersfa222332015-12-04 14:30:39 +0000516
517 # Multi-stage compilation
518 useTwoStage=False,
519 testStage1=True,
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000520 stage1_config='Release',
521 stage2_config='Release',
Daniel Sandersfa222332015-12-04 14:30:39 +0000522
523 # Test-suite
524 runTestSuite=False,
Galina Kistanova84b11952019-10-17 04:07:11 +0000525 nt_flags=None,
526 testsuite_flags=None,
Daniel Sandersfa222332015-12-04 14:30:39 +0000527 submitURL=None,
528 testerName=None,
529
530 # Environmental variables for all steps.
Galina Kistanova84b11952019-10-17 04:07:11 +0000531 env=None,
532 extra_cmake_args=None,
Daniel Sandersfa222332015-12-04 14:30:39 +0000533
534 # Extra repositories
535 checkout_clang_tools_extra=True,
536 checkout_compiler_rt=True,
Renato Golin0bd2a532016-11-20 16:14:35 +0000537 checkout_lld=True,
Artem Belevich16fcd0e2016-12-21 21:15:56 +0000538 checkout_libcxx=False,
539 checkout_test_suite=False,
Daniel Sandersfa222332015-12-04 14:30:39 +0000540
541 # Upload artifacts to Google Cloud Storage (for the llvmbisect tool)
542 stage1_upload_directory=None,
543
Leandro Nunes7b83ba42018-06-25 13:54:50 +0000544 # Use a lower compression level to generate the build-cache package faster
545 # default is 6 according to documentation
546 xz_compression_factor=6,
547 use_pixz_compression=False,
548
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000549 # Triggers
Galina Kistanova84b11952019-10-17 04:07:11 +0000550 trigger_after_stage1=None):
Reid Kleckner25a26b02015-03-09 22:30:25 +0000551
552 ############# PREPARING
Galina Kistanova84b11952019-10-17 04:07:11 +0000553 if nt_flags is None:
554 nt_flags = []
555 if testsuite_flags is None:
556 testsuite_flags = []
557 if env is None:
558 env = {}
559 if extra_cmake_args is None:
560 extra_cmake_args = []
561 if trigger_after_stage1 is None:
562 trigger_after_stage1 = []
563
Galina Kistanova5921add2018-11-14 05:34:46 +0000564 clean_build_requested = lambda step: \
565 step.build.getProperty( \
566 "clean", \
567 default=step.build.getProperty("clean_obj") \
568 ) or clean
Reid Kleckner25a26b02015-03-09 22:30:25 +0000569
Galina Kistanova5921add2018-11-14 05:34:46 +0000570 # We *must* checkout at least Clang+LLVM
571 depends_on_projects = ['llvm', 'clang']
572 if checkout_clang_tools_extra:
573 depends_on_projects.append('clang-tools-extra')
574 if checkout_compiler_rt:
575 depends_on_projects.append('compiler-rt')
576 if checkout_lld:
577 depends_on_projects.append('lld')
578 if runTestSuite or checkout_test_suite:
579 depends_on_projects.append('lnt')
580 depends_on_projects.append('test-suite')
581 if checkout_libcxx:
582 depends_on_projects.append('libcxx')
583 depends_on_projects.append('libcxxabi')
584 depends_on_projects.append('libunwind')
Galina Kistanova49cbd602017-04-14 23:46:03 +0000585
Galina Kistanova5921add2018-11-14 05:34:46 +0000586 f = LLVMBuildFactory(
587 depends_on_projects=depends_on_projects,
588 llvm_srcdir='llvm')
589
590 f.addSVNSteps()
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.
Stella Stamenovae9bbc272018-10-26 18:17:50 +0000611 if vs:
Reid Kleckner25a26b02015-03-09 22:30:25 +0000612 f.addStep(SetProperty(
Stella Stamenovae9bbc272018-10-26 18:17:50 +0000613 command=builders_util.getVisualStudioEnvironment(vs, vs_target_arch),
Reid Kleckner25a26b02015-03-09 22:30:25 +0000614 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,
Leandro Nunes7b83ba42018-06-25 13:54:50 +0000679 env, gcs_url_property='stage1_package_gcs_url',
680 use_pixz_compression=use_pixz_compression,
681 xz_compression_factor=xz_compression_factor)
Daniel Sandersfa222332015-12-04 14:30:39 +0000682
Reid Kleckner25a26b02015-03-09 22:30:25 +0000683 # Compute the cmake define flag to set the C and C++ compiler to clang. Use
684 # clang-cl if we used MSVC for stage1.
685 if not vs:
686 cc = 'clang'
687 cxx = 'clang++'
688 else:
689 cc = 'clang-cl.exe'
690 cxx = 'clang-cl.exe'
691
Galina Kistanovaff5e78a2016-09-06 17:44:53 +0000692
Renato Golin61aed7f2015-06-17 19:12:50 +0000693 ############# STAGE 2
694 if useTwoStage:
Galina Kistanova79900972015-11-16 17:30:42 +0000695 # We always cleanly build the stage 2. If the compiler has been
696 # changed on the stage 1, we cannot trust any of the intermediate file
697 # from the old compiler. And if the stage 1 compiler is the same, we
698 # should not build in the first place.
699 f.addStep(ShellCommand(name='clean stage 2',
700 command=['rm','-rf',stage2_build],
701 warnOnFailure=True,
702 description='cleaning stage 2',
703 descriptionDone='clean',
Galina Kistanova49cbd602017-04-14 23:46:03 +0000704 workdir='.'))
Reid Kleckner25a26b02015-03-09 22:30:25 +0000705
Renato Golin61aed7f2015-06-17 19:12:50 +0000706 # Set the compiler using the CC and CXX environment variables to work around
707 # backslash string escaping bugs somewhere between buildbot and cmake. The
708 # env.exe helper is required to run the tests, so hopefully it's already on
709 # PATH.
710 cmake_cmd2 = ['env',
711 WithProperties('CC=%(workdir)s/'+stage1_install+'/bin/'+cc),
712 WithProperties('CXX=%(workdir)s/'+stage1_install+'/bin/'+cxx),
713 cmake, "-G", "Ninja", "../llvm",
714 "-DCMAKE_BUILD_TYPE="+stage2_config,
715 "-DLLVM_ENABLE_ASSERTIONS=True",
716 "-DLLVM_LIT_ARGS="+lit_args,
717 "-DCMAKE_INSTALL_PREFIX=../"+stage2_install] + extra_cmake_args
Reid Kleckner25a26b02015-03-09 22:30:25 +0000718
Renato Golin61aed7f2015-06-17 19:12:50 +0000719 f.addStep(ShellCommand(name='cmake stage 2',
720 command=cmake_cmd2,
721 haltOnFailure=True,
722 description='cmake stage 2',
723 workdir=stage2_build,
Renato Golin61aed7f2015-06-17 19:12:50 +0000724 env=env))
725
726 f.addStep(WarningCountingShellCommand(name='build stage 2',
727 command=ninja_cmd,
728 haltOnFailure=True,
729 description='ninja all',
730 workdir=stage2_build,
731 env=env))
732
733 if test:
734 f.addStep(lit_test_command.LitTestCommand(name='ninja check 2',
735 command=ninja_check_cmd,
736 haltOnFailure=not runTestSuite,
737 description=["checking stage 2"],
738 descriptionDone=["stage 2 checked"],
739 workdir=stage2_build,
740 env=env))
741
742 ############# TEST SUITE
743 ## Test-Suite (stage 2 if built, stage 1 otherwise)
744 if runTestSuite:
745 compiler_path = stage1_install
746 if useTwoStage:
747 compiler_path=stage2_install
Galina Kistanova49cbd602017-04-14 23:46:03 +0000748 f.addStep(ShellCommand(name='clean stage 2 install',
749 command=['rm','-rf',stage2_install],
750 warnOnFailure=True,
751 description='cleaning stage 2 install',
752 descriptionDone='clean',
753 workdir='.'))
Renato Golin61aed7f2015-06-17 19:12:50 +0000754 f.addStep(ShellCommand(name='install stage 2',
755 command=ninja_install_cmd,
756 description='ninja install 2',
Renato Golincfbd5702014-09-06 19:09:16 +0000757 workdir=stage2_build,
758 env=env))
Renato Goline402f582014-09-04 19:25:24 +0000759
Renato Golin61aed7f2015-06-17 19:12:50 +0000760 # Get generated python, lnt
761 python = WithProperties('%(workdir)s/test/sandbox/bin/python')
762 lnt = WithProperties('%(workdir)s/test/sandbox/bin/lnt')
763 lnt_setup = WithProperties('%(workdir)s/test/lnt/setup.py')
764
765 # Paths
766 sandbox = WithProperties('%(workdir)s/test/sandbox')
767 test_suite_dir = WithProperties('%(workdir)s/test/test-suite')
768
769 # Get latest built Clang (stage1 or stage2)
770 cc = WithProperties('%(workdir)s/'+compiler_path+'/bin/'+cc)
771 cxx = WithProperties('%(workdir)s/'+compiler_path+'/bin/'+cxx)
772
Renato Golin593e0d62016-09-21 17:24:56 +0000773 # LNT Command line (don't pass -jN. Users need to pass both --threads
Kristof Beylsf4639b52017-08-10 08:53:52 +0000774 # and --build-threads in nt_flags/test_suite_flags to get the same effect)
775 use_runtest_testsuite = len(nt_flags) == 0
776 if not use_runtest_testsuite:
777 test_suite_cmd = [python, lnt, 'runtest', 'nt',
778 '--no-timestamp',
779 '--sandbox', sandbox,
780 '--test-suite', test_suite_dir,
781 '--cc', cc,
782 '--cxx', cxx]
783 # Append any option provided by the user
784 test_suite_cmd.extend(nt_flags)
785 else:
786 lit = WithProperties('%(workdir)s/'+stage1_build+'/bin/llvm-lit')
787 test_suite_cmd = [python, lnt, 'runtest', 'test-suite',
788 '--no-timestamp',
789 '--sandbox', sandbox,
790 '--test-suite', test_suite_dir,
791 '--cc', cc,
792 '--cxx', cxx,
793 '--use-lit', lit]
794 # Append any option provided by the user
795 test_suite_cmd.extend(testsuite_flags)
796
Renato Golin61aed7f2015-06-17 19:12:50 +0000797 # Only submit if a URL has been specified
798 if submitURL is not None:
799 if not isinstance(submitURL, list):
800 submitURL = [submitURL]
801 for url in submitURL:
802 test_suite_cmd.extend(['--submit', url])
Kristof Beylsf4639b52017-08-10 08:53:52 +0000803 # lnt runtest test-suite doesn't understand --no-machdep-info:
804 if testerName and not use_runtest_testsuite:
Renato Golin61aed7f2015-06-17 19:12:50 +0000805 test_suite_cmd.extend(['--no-machdep-info', testerName])
806 # CC and CXX are needed as env for build-tools
Renato Goline6c1b3b2015-07-01 15:52:22 +0000807 test_suite_env = copy.deepcopy(env)
Renato Golin61aed7f2015-06-17 19:12:50 +0000808 test_suite_env['CC'] = cc
809 test_suite_env['CXX'] = cxx
810
811 # Steps to prepare, build and run LNT
812 f.addStep(ShellCommand(name='clean sandbox',
813 command=['rm', '-rf', 'sandbox'],
814 haltOnFailure=True,
815 description='removing sandbox directory',
816 workdir='test',
817 env=env))
818 f.addStep(ShellCommand(name='recreate sandbox',
819 command=['virtualenv', 'sandbox'],
820 haltOnFailure=True,
821 description='recreating sandbox',
822 workdir='test',
823 env=env))
824 f.addStep(ShellCommand(name='setup lit',
825 command=[python, lnt_setup, 'develop'],
826 haltOnFailure=True,
827 description='setting up LNT in sandbox',
828 workdir='test/sandbox',
829 env=env))
830 f.addStep(commands.LitTestCommand.LitTestCommand(
831 name='test-suite',
832 command=test_suite_cmd,
833 haltOnFailure=True,
834 description=['running the test suite'],
835 workdir='test/sandbox',
836 logfiles={'configure.log' : 'build/configure.log',
837 'build-tools.log' : 'build/build-tools.log',
838 'test.log' : 'build/test.log',
839 'report.json' : 'build/report.json'},
840 env=test_suite_env))
841
Renato Goline402f582014-09-04 19:25:24 +0000842 return f
843
Daniel Dunbar7363d032011-02-27 03:22:35 +0000844def addClangGCCTests(f, ignores={}, install_prefix="%(builddir)s/llvm.install",
845 languages = ('gcc', 'g++', 'objc', 'obj-c++')):
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000846 make_vars = [WithProperties(
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000847 'CC_UNDER_TEST=%s/bin/clang' % install_prefix),
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000848 WithProperties(
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000849 'CXX_UNDER_TEST=%s/bin/clang++' % install_prefix)]
David Blaikie05517332013-12-19 23:29:12 +0000850 f.addStep(SVN(name='svn-clang-gcc-tests', mode='update',
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000851 baseURL='http://llvm.org/svn/llvm-project/clang-tests/',
852 defaultBranch='trunk', workdir='clang-tests'))
853 gcc_dg_ignores = ignores.get('gcc-4_2-testsuite', {})
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000854 for lang in languages:
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000855 f.addStep(commands.SuppressionDejaGNUCommand.SuppressionDejaGNUCommand(
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000856 name='test-gcc-4_2-testsuite-%s' % lang,
857 command=["make", "-k", "check-%s" % lang] + make_vars,
858 description="gcc-4_2-testsuite (%s)" % lang,
859 workdir='clang-tests/gcc-4_2-testsuite',
David Dean2bd0c3a2011-10-18 16:36:28 +0000860 logfiles={ 'dg.sum' : 'obj/%s/%s.sum' % (lang, lang),
861 '%s.log' % lang : 'obj/%s/%s.log' % (lang, lang)},
Daniel Dunbar22d594a2010-07-31 05:29:16 +0000862 ignore=gcc_dg_ignores.get(lang, [])))
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000863
Daniel Dunbar7363d032011-02-27 03:22:35 +0000864def addClangGDBTests(f, ignores={}, install_prefix="%(builddir)s/llvm.install"):
865 make_vars = [WithProperties(
866 'CC_UNDER_TEST=%s/bin/clang' % install_prefix),
867 WithProperties(
868 'CXX_UNDER_TEST=%s/bin/clang++' % install_prefix)]
David Blaikie05517332013-12-19 23:29:12 +0000869 f.addStep(SVN(name='svn-clang-gdb-tests', mode='update',
Daniel Dunbar7363d032011-02-27 03:22:35 +0000870 baseURL='http://llvm.org/svn/llvm-project/clang-tests/',
871 defaultBranch='trunk', workdir='clang-tests'))
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000872 f.addStep(commands.SuppressionDejaGNUCommand.SuppressionDejaGNUCommand(
Daniel Dunbar7363d032011-02-27 03:22:35 +0000873 name='test-gdb-1472-testsuite',
874 command=["make", "-k", "check"] + make_vars,
875 description="gdb-1472-testsuite",
876 workdir='clang-tests/gdb-1472-testsuite',
David Blaikie7ec695f2012-10-09 22:17:09 +0000877 logfiles={ 'dg.sum' : 'obj/filtered.gdb.sum',
David Blaikie624f4392012-11-05 22:34:35 +0000878 'gdb.log' : 'obj/gdb.log' }))
Daniel Dunbar7363d032011-02-27 03:22:35 +0000879
David Blaikie41d09c32013-01-02 21:11:09 +0000880def addModernClangGDBTests(f, jobs, install_prefix):
David Blaikie1bc5c372012-12-05 05:29:12 +0000881 make_vars = [WithProperties('RUNTESTFLAGS=CC_FOR_TARGET=\'{0}/bin/clang\' '
882 'CXX_FOR_TARGET=\'{0}/bin/clang++\' '
David Blaikie759bb752013-04-18 23:13:11 +0000883 'CFLAGS_FOR_TARGET=\'-w -fno-limit-debug-info\''
David Blaikief89877b2013-01-29 23:46:26 +0000884 .format(install_prefix))]
David Blaikie05517332013-12-19 23:29:12 +0000885 f.addStep(SVN(name='svn-clang-modern-gdb-tests', mode='update',
David Blaikief3f300b2012-11-17 01:13:41 +0000886 svnurl='http://llvm.org/svn/llvm-project/clang-tests-external/trunk/gdb/7.5',
David Blaikiedad03d52012-11-16 22:37:12 +0000887 workdir='clang-tests/src'))
David Blaikieb83bfdf2012-12-05 04:33:42 +0000888 f.addStep(Configure(command='../src/configure',
David Blaikief3f300b2012-11-17 01:13:41 +0000889 workdir='clang-tests/build/'))
David Blaikieb83bfdf2012-12-05 04:33:42 +0000890 f.addStep(WarningCountingShellCommand(name='gdb-75-build',
891 command=['make', WithProperties('-j%s' % jobs)],
892 haltOnFailure=True,
893 workdir='clang-tests/build'))
Michael Gottesmana6b5be82013-06-28 21:57:20 +0000894 f.addStep(commands.DejaGNUCommand.DejaGNUCommand(
David Blaikiedad03d52012-11-16 22:37:12 +0000895 name='gdb-75-check',
David Blaikieb83bfdf2012-12-05 04:33:42 +0000896 command=['make', '-k', WithProperties('-j%s' % jobs), 'check'] + make_vars,
David Blaikiedad03d52012-11-16 22:37:12 +0000897 workdir='clang-tests/build',
David Blaikie1bc5c372012-12-05 05:29:12 +0000898 logfiles={'dg.sum':'gdb/testsuite/gdb.sum',
899 'gdb.log':'gdb/testsuite/gdb.log'}))
David Blaikiedad03d52012-11-16 22:37:12 +0000900
901
902
Daniel Dunbar7363d032011-02-27 03:22:35 +0000903# FIXME: Deprecated.
904addClangTests = addClangGCCTests
905
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000906def getClangTestsIgnoresFromPath(path, key):
907 def readList(path):
908 if not os.path.exists(path):
909 return []
910
911 f = open(path)
912 lines = [ln.strip() for ln in f]
913 f.close()
914 return lines
915
916 ignores = {}
917
918 gcc_dg_ignores = {}
919 for lang in ('gcc', 'g++', 'objc', 'obj-c++'):
920 lang_path = os.path.join(path, 'gcc-4_2-testsuite', 'expected_results',
921 key, lang)
922 gcc_dg_ignores[lang] = (
923 readList(os.path.join(lang_path, 'FAIL.txt')) +
924 readList(os.path.join(lang_path, 'UNRESOLVED.txt')) +
925 readList(os.path.join(lang_path, 'XPASS.txt')))
926 ignores['gcc-4_2-testsuite' ] = gcc_dg_ignores
927
Daniel Dunbar7363d032011-02-27 03:22:35 +0000928 ignores_path = os.path.join(path, 'gdb-1472-testsuite', 'expected_results',
929 key)
930 gdb_dg_ignores = (
931 readList(os.path.join(ignores_path, 'FAIL.txt')) +
932 readList(os.path.join(ignores_path, 'UNRESOLVED.txt')) +
933 readList(os.path.join(ignores_path, 'XPASS.txt')))
934 ignores['gdb-1472-testsuite' ] = gdb_dg_ignores
935
Daniel Dunbar2b67e8f2011-02-11 21:03:41 +0000936 return ignores