Daniel Dunbar | 235aa41 | 2009-07-18 07:16:15 +0000 | [diff] [blame] | 1 | import buildbot |
| 2 | import buildbot.process.factory |
Renato Golin | e6c1b3b | 2015-07-01 15:52:22 +0000 | [diff] [blame] | 3 | import copy |
David Dean | f8b3544 | 2012-12-11 00:35:12 +0000 | [diff] [blame] | 4 | import os |
Daniel Sanders | fa22233 | 2015-12-04 14:30:39 +0000 | [diff] [blame] | 5 | from datetime import datetime |
David Dean | f8b3544 | 2012-12-11 00:35:12 +0000 | [diff] [blame] | 6 | |
Reid Kleckner | 25a26b0 | 2015-03-09 22:30:25 +0000 | [diff] [blame] | 7 | from buildbot.process.properties import WithProperties, Property |
David Blaikie | 8cbf62f | 2013-01-12 21:32:31 +0000 | [diff] [blame] | 8 | from buildbot.steps.shell import Configure, ShellCommand, SetProperty |
Daniel Dunbar | 44abe74 | 2009-07-19 01:59:03 +0000 | [diff] [blame] | 9 | from buildbot.steps.shell import WarningCountingShellCommand |
David Dean | f8b3544 | 2012-12-11 00:35:12 +0000 | [diff] [blame] | 10 | from buildbot.steps.source import SVN |
Daniel Dunbar | 44abe74 | 2009-07-19 01:59:03 +0000 | [diff] [blame] | 11 | from buildbot.steps.transfer import FileDownload |
Michael Gottesman | a6b5be8 | 2013-06-28 21:57:20 +0000 | [diff] [blame] | 12 | |
Michael Gottesman | 960bcfa | 2013-08-30 05:46:15 +0000 | [diff] [blame] | 13 | import zorg.buildbot.util.artifacts as artifacts |
Michael Gottesman | a6b5be8 | 2013-06-28 21:57:20 +0000 | [diff] [blame] | 14 | import zorg.buildbot.builders.Util as builders_util |
Michael Gottesman | dc771a0 | 2013-08-30 05:46:22 +0000 | [diff] [blame] | 15 | import zorg.buildbot.util.phasedbuilderutils as phasedbuilderutils |
Michael Gottesman | a6b5be8 | 2013-06-28 21:57:20 +0000 | [diff] [blame] | 16 | import zorg.buildbot.commands as commands |
| 17 | import zorg.buildbot.commands.BatchFileDownload as batch_file_download |
| 18 | import zorg.buildbot.commands.LitTestCommand as lit_test_command |
Galina Kistanova | 49cbd60 | 2017-04-14 23:46:03 +0000 | [diff] [blame] | 19 | from zorg.buildbot.conditions.FileConditions import FileDoesNotExist |
Daniel Dunbar | 8a89a6f | 2009-11-25 04:27:32 +0000 | [diff] [blame] | 20 | |
Galina Kistanova | f4d7935 | 2011-10-20 20:46:52 +0000 | [diff] [blame] | 21 | def getClangBuildFactory( |
| 22 | triple=None, |
| 23 | clean=True, |
| 24 | test=True, |
| 25 | package_dst=None, |
| 26 | run_cxx_tests=False, |
| 27 | examples=False, |
| 28 | valgrind=False, |
| 29 | valgrindLeakCheck=False, |
Galina Kistanova | f4d7935 | 2011-10-20 20:46:52 +0000 | [diff] [blame] | 30 | useTwoStage=False, |
| 31 | completely_clean=False, |
Galina Kistanova | f4d7935 | 2011-10-20 20:46:52 +0000 | [diff] [blame] | 32 | make='make', |
| 33 | jobs="%(jobs)s", |
| 34 | stage1_config='Debug+Asserts', |
| 35 | stage2_config='Release+Asserts', |
| 36 | env={}, # Environmental variables for all steps. |
| 37 | extra_configure_args=[], |
Vassil Vassilev | 5a9b9ed | 2016-05-25 17:10:03 +0000 | [diff] [blame] | 38 | stage2_extra_configure_args=[], |
Galina Kistanova | f4d7935 | 2011-10-20 20:46:52 +0000 | [diff] [blame] | 39 | use_pty_in_tests=False, |
Peter Collingbourne | d49ac28 | 2011-10-25 14:38:45 +0000 | [diff] [blame] | 40 | trunk_revision=None, |
| 41 | force_checkout=False, |
Peter Collingbourne | 7a95b0c | 2011-10-26 16:40:17 +0000 | [diff] [blame] | 42 | extra_clean_step=None, |
David Blaikie | a76da84 | 2012-08-13 22:24:46 +0000 | [diff] [blame] | 43 | checkout_compiler_rt=False, |
Galina Kistanova | 2ab1e2d | 2016-11-22 00:23:43 +0000 | [diff] [blame] | 44 | checkout_lld=False, |
David Blaikie | a76da84 | 2012-08-13 22:24:46 +0000 | [diff] [blame] | 45 | run_gdb=False, |
David Blaikie | dad03d5 | 2012-11-16 22:37:12 +0000 | [diff] [blame] | 46 | run_modern_gdb=False, |
Vassil Vassilev | 0c647ef | 2016-06-30 21:16:45 +0000 | [diff] [blame] | 47 | run_gcc=False): |
Galina Kistanova | f4d7935 | 2011-10-20 20:46:52 +0000 | [diff] [blame] | 48 | # Prepare environmental variables. Set here all env we want everywhere. |
| 49 | merged_env = { |
| 50 | 'TERM' : 'dumb' # Make sure Clang doesn't use color escape sequences. |
| 51 | } |
| 52 | if env is not None: |
| 53 | # Overwrite pre-set items with the given ones, so user can set anything. |
| 54 | merged_env.update(env) |
David Blaikie | 2f7eb28 | 2012-08-24 18:37:00 +0000 | [diff] [blame] | 55 | |
Jonathan Roelofs | 62415e5 | 2015-02-28 00:03:17 +0000 | [diff] [blame] | 56 | llvm_srcdir = "llvm.src" |
| 57 | llvm_1_objdir = "llvm.obj" |
| 58 | llvm_1_installdir = "llvm.install.1" |
| 59 | llvm_2_objdir = "llvm.obj.2" |
| 60 | llvm_2_installdir = "llvm.install" |
Daniel Dunbar | 8a89a6f | 2009-11-25 04:27:32 +0000 | [diff] [blame] | 61 | |
Daniel Dunbar | 235aa41 | 2009-07-18 07:16:15 +0000 | [diff] [blame] | 62 | f = buildbot.process.factory.BuildFactory() |
Daniel Dunbar | b51f6ab | 2009-11-09 03:09:23 +0000 | [diff] [blame] | 63 | |
| 64 | # Determine the build directory. |
| 65 | f.addStep(buildbot.steps.shell.SetProperty(name="get_builddir", |
| 66 | command=["pwd"], |
| 67 | property="builddir", |
| 68 | description="set build dir", |
Galina Kistanova | f4d7935 | 2011-10-20 20:46:52 +0000 | [diff] [blame] | 69 | workdir=".", |
| 70 | env=merged_env)) |
Daniel Dunbar | b51f6ab | 2009-11-09 03:09:23 +0000 | [diff] [blame] | 71 | |
Daniel Dunbar | 06b20f1 | 2010-04-08 18:29:38 +0000 | [diff] [blame] | 72 | # Blow away completely, if requested. |
| 73 | if completely_clean: |
| 74 | f.addStep(ShellCommand(name="rm-llvm.src", |
| 75 | command=["rm", "-rf", llvm_srcdir], |
| 76 | haltOnFailure=True, |
| 77 | description=["rm src dir", "llvm"], |
Galina Kistanova | f4d7935 | 2011-10-20 20:46:52 +0000 | [diff] [blame] | 78 | workdir=".", |
| 79 | env=merged_env)) |
Daniel Dunbar | 06b20f1 | 2010-04-08 18:29:38 +0000 | [diff] [blame] | 80 | |
Daniel Dunbar | b51f6ab | 2009-11-09 03:09:23 +0000 | [diff] [blame] | 81 | # Checkout sources. |
Peter Collingbourne | d49ac28 | 2011-10-25 14:38:45 +0000 | [diff] [blame] | 82 | if trunk_revision: |
| 83 | # The SVN build step provides no mechanism to check out a specific revision |
| 84 | # based on a property, so just run the commands directly here. |
| 85 | svn_co = ['svn', 'checkout'] |
| 86 | if force_checkout: |
| 87 | svn_co += ['--force'] |
| 88 | svn_co += ['--revision', WithProperties(trunk_revision)] |
| 89 | |
| 90 | svn_co_llvm = svn_co + \ |
| 91 | [WithProperties('http://llvm.org/svn/llvm-project/llvm/trunk@%s' % |
| 92 | trunk_revision), |
| 93 | llvm_srcdir] |
| 94 | svn_co_clang = svn_co + \ |
| 95 | [WithProperties('http://llvm.org/svn/llvm-project/cfe/trunk@%s' % |
| 96 | trunk_revision), |
| 97 | '%s/tools/clang' % llvm_srcdir] |
David Blaikie | 845ae0d | 2012-08-10 00:51:38 +0000 | [diff] [blame] | 98 | svn_co_clang_tools_extra = svn_co + \ |
| 99 | [WithProperties('http://llvm.org/svn/llvm-project/clang-tools-extra/trunk@%s' % |
| 100 | trunk_revision), |
| 101 | '%s/tools/clang/tools/extra' % llvm_srcdir] |
Peter Collingbourne | d49ac28 | 2011-10-25 14:38:45 +0000 | [diff] [blame] | 102 | |
| 103 | f.addStep(ShellCommand(name='svn-llvm', |
| 104 | command=svn_co_llvm, |
| 105 | haltOnFailure=True, |
| 106 | workdir='.')) |
| 107 | f.addStep(ShellCommand(name='svn-clang', |
| 108 | command=svn_co_clang, |
| 109 | haltOnFailure=True, |
| 110 | workdir='.')) |
David Blaikie | 845ae0d | 2012-08-10 00:51:38 +0000 | [diff] [blame] | 111 | f.addStep(ShellCommand(name='svn-clang-tools-extra', |
| 112 | command=svn_co_clang_tools_extra, |
| 113 | haltOnFailure=True, |
| 114 | workdir='.')) |
Peter Collingbourne | d49ac28 | 2011-10-25 14:38:45 +0000 | [diff] [blame] | 115 | else: |
| 116 | f.addStep(SVN(name='svn-llvm', |
Daniel Dunbar | f4e23eb | 2010-09-20 21:13:02 +0000 | [diff] [blame] | 117 | mode='update', |
Peter Collingbourne | d49ac28 | 2011-10-25 14:38:45 +0000 | [diff] [blame] | 118 | baseURL='http://llvm.org/svn/llvm-project/llvm/', |
Daniel Dunbar | f4e23eb | 2010-09-20 21:13:02 +0000 | [diff] [blame] | 119 | defaultBranch='trunk', |
Peter Collingbourne | d49ac28 | 2011-10-25 14:38:45 +0000 | [diff] [blame] | 120 | workdir=llvm_srcdir)) |
| 121 | f.addStep(SVN(name='svn-clang', |
| 122 | mode='update', |
| 123 | baseURL='http://llvm.org/svn/llvm-project/cfe/', |
| 124 | defaultBranch='trunk', |
| 125 | workdir='%s/tools/clang' % llvm_srcdir)) |
David Blaikie | 845ae0d | 2012-08-10 00:51:38 +0000 | [diff] [blame] | 126 | f.addStep(SVN(name='svn-clang-tools-extra', |
| 127 | mode='update', |
| 128 | baseURL='http://llvm.org/svn/llvm-project/clang-tools-extra/', |
| 129 | defaultBranch='trunk', |
| 130 | workdir='%s/tools/clang/tools/extra' % llvm_srcdir)) |
Peter Collingbourne | d49ac28 | 2011-10-25 14:38:45 +0000 | [diff] [blame] | 131 | if checkout_compiler_rt: |
| 132 | f.addStep(SVN(name='svn-compiler-rt', |
| 133 | mode='update', |
| 134 | baseURL='http://llvm.org/svn/llvm-project/compiler-rt/', |
| 135 | defaultBranch='trunk', |
| 136 | workdir='%s/projects/compiler-rt' % llvm_srcdir)) |
Daniel Dunbar | fa0e022 | 2009-11-09 06:08:28 +0000 | [diff] [blame] | 137 | |
Daniel Dunbar | 8a89a6f | 2009-11-25 04:27:32 +0000 | [diff] [blame] | 138 | # Clean up llvm (stage 1); unless in-dir. |
| 139 | if clean and llvm_srcdir != llvm_1_objdir: |
| 140 | f.addStep(ShellCommand(name="rm-llvm.obj.stage1", |
| 141 | command=["rm", "-rf", llvm_1_objdir], |
| 142 | haltOnFailure=True, |
| 143 | description=["rm build dir", "llvm"], |
Galina Kistanova | f4d7935 | 2011-10-20 20:46:52 +0000 | [diff] [blame] | 144 | workdir=".", |
| 145 | env=merged_env)) |
Andrew Trick | 70fa9d2 | 2011-08-25 23:38:51 +0000 | [diff] [blame] | 146 | |
David Blaikie | 8cbf62f | 2013-01-12 21:32:31 +0000 | [diff] [blame] | 147 | if not clean: |
Galina Kistanova | a06e4c8 | 2016-04-14 21:41:30 +0000 | [diff] [blame] | 148 | expected_makefile = 'Makefile' |
David Blaikie | 8cbf62f | 2013-01-12 21:32:31 +0000 | [diff] [blame] | 149 | f.addStep(SetProperty(name="Makefile_isready", |
| 150 | workdir=llvm_1_objdir, |
| 151 | command=["sh", "-c", |
Richard Smith | 0238916 | 2014-09-26 23:53:06 +0000 | [diff] [blame] | 152 | "test -e %s && echo OK || echo Missing" % expected_makefile], |
David Blaikie | 8cbf62f | 2013-01-12 21:32:31 +0000 | [diff] [blame] | 153 | flunkOnFailure=False, |
Galina Kistanova | a06e4c8 | 2016-04-14 21:41:30 +0000 | [diff] [blame] | 154 | property="exists_Makefile")) |
Richard Smith | 0238916 | 2014-09-26 23:53:06 +0000 | [diff] [blame] | 155 | |
Galina Kistanova | a06e4c8 | 2016-04-14 21:41:30 +0000 | [diff] [blame] | 156 | cmake_triple_arg = [] |
| 157 | if triple: |
| 158 | cmake_triple_arg = ['-DLLVM_HOST_TRIPLE=%s' % triple] |
| 159 | f.addStep(ShellCommand(name='cmake', |
| 160 | command=['cmake', |
| 161 | '-DLLVM_BUILD_TESTS=ON', |
| 162 | '-DCMAKE_BUILD_TYPE=%s' % stage1_config] + |
| 163 | cmake_triple_arg + |
| 164 | extra_configure_args + |
| 165 | ["../" + llvm_srcdir], |
| 166 | description='cmake stage1', |
| 167 | workdir=llvm_1_objdir, |
| 168 | env=merged_env, |
| 169 | doStepIf=lambda step: step.build.getProperty("exists_Makefile") != "OK")) |
Daniel Dunbar | 8a89a6f | 2009-11-25 04:27:32 +0000 | [diff] [blame] | 170 | |
| 171 | # Make clean if using in-dir builds. |
| 172 | if clean and llvm_srcdir == llvm_1_objdir: |
Daniel Dunbar | b51f6ab | 2009-11-09 03:09:23 +0000 | [diff] [blame] | 173 | f.addStep(WarningCountingShellCommand(name="clean-llvm", |
Daniel Dunbar | d20468a | 2009-11-24 18:27:23 +0000 | [diff] [blame] | 174 | command=[make, "clean"], |
Daniel Dunbar | b51f6ab | 2009-11-09 03:09:23 +0000 | [diff] [blame] | 175 | haltOnFailure=True, |
| 176 | description="cleaning llvm", |
| 177 | descriptionDone="clean llvm", |
Galina Kistanova | f4d7935 | 2011-10-20 20:46:52 +0000 | [diff] [blame] | 178 | workdir=llvm_1_objdir, |
Peter Collingbourne | 7a95b0c | 2011-10-26 16:40:17 +0000 | [diff] [blame] | 179 | doStepIf=clean, |
Galina Kistanova | f4d7935 | 2011-10-20 20:46:52 +0000 | [diff] [blame] | 180 | env=merged_env)) |
Daniel Dunbar | 8a89a6f | 2009-11-25 04:27:32 +0000 | [diff] [blame] | 181 | |
Peter Collingbourne | 7a95b0c | 2011-10-26 16:40:17 +0000 | [diff] [blame] | 182 | if extra_clean_step: |
| 183 | f.addStep(extra_clean_step) |
| 184 | |
Daniel Dunbar | 7e959c8 | 2009-09-28 04:01:19 +0000 | [diff] [blame] | 185 | f.addStep(WarningCountingShellCommand(name="compile", |
Daniel Dunbar | d20468a | 2009-11-24 18:27:23 +0000 | [diff] [blame] | 186 | command=['nice', '-n', '10', |
| 187 | make, WithProperties("-j%s" % jobs)], |
Daniel Dunbar | 7e959c8 | 2009-09-28 04:01:19 +0000 | [diff] [blame] | 188 | haltOnFailure=True, |
David Blaikie | 0551733 | 2013-12-19 23:29:12 +0000 | [diff] [blame] | 189 | flunkOnFailure=not run_gdb, |
Daniel Dunbar | 8a89a6f | 2009-11-25 04:27:32 +0000 | [diff] [blame] | 190 | description=["compiling", stage1_config], |
| 191 | descriptionDone=["compile", stage1_config], |
Galina Kistanova | f4d7935 | 2011-10-20 20:46:52 +0000 | [diff] [blame] | 192 | workdir=llvm_1_objdir, |
| 193 | env=merged_env)) |
Daniel Dunbar | 256fed4 | 2009-11-25 21:11:08 +0000 | [diff] [blame] | 194 | |
| 195 | if examples: |
| 196 | f.addStep(WarningCountingShellCommand(name="compile.examples", |
| 197 | command=['nice', '-n', '10', |
| 198 | make, WithProperties("-j%s" % jobs), |
| 199 | "BUILD_EXAMPLES=1"], |
| 200 | haltOnFailure=True, |
Richard Smith | 65e6f5d | 2014-09-25 18:18:35 +0000 | [diff] [blame] | 201 | description=["compiling", stage1_config, "examples"], |
Daniel Dunbar | 256fed4 | 2009-11-25 21:11:08 +0000 | [diff] [blame] | 202 | descriptionDone=["compile", stage1_config, "examples"], |
Galina Kistanova | f4d7935 | 2011-10-20 20:46:52 +0000 | [diff] [blame] | 203 | workdir=llvm_1_objdir, |
| 204 | env=merged_env)) |
Daniel Dunbar | 256fed4 | 2009-11-25 21:11:08 +0000 | [diff] [blame] | 205 | |
NAKAMURA Takumi | 1a4666b | 2013-01-19 03:39:07 +0000 | [diff] [blame] | 206 | clangTestArgs = '-v -j %s' % jobs |
Daniel Dunbar | fa0e022 | 2009-11-09 06:08:28 +0000 | [diff] [blame] | 207 | if valgrind: |
Daniel Dunbar | 89184b9 | 2010-04-18 19:09:32 +0000 | [diff] [blame] | 208 | clangTestArgs += ' --vg' |
Daniel Dunbar | a1bebce | 2010-03-21 01:24:00 +0000 | [diff] [blame] | 209 | if valgrindLeakCheck: |
| 210 | clangTestArgs += ' --vg-leak' |
Nick Lewycky | 8d26e47 | 2011-08-27 21:18:56 +0000 | [diff] [blame] | 211 | 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 Dunbar | fa0e022 | 2009-11-09 06:08:28 +0000 | [diff] [blame] | 212 | extraTestDirs = '' |
| 213 | if run_cxx_tests: |
| 214 | extraTestDirs += '%(builddir)s/llvm/tools/clang/utils/C++Tests' |
Daniel Dunbar | b51f6ab | 2009-11-09 03:09:23 +0000 | [diff] [blame] | 215 | if test: |
Michael Gottesman | a6b5be8 | 2013-06-28 21:57:20 +0000 | [diff] [blame] | 216 | f.addStep(lit_test_command.LitTestCommand(name='check-all', |
David Blaikie | 7e6f8a1 | 2012-08-31 20:46:27 +0000 | [diff] [blame] | 217 | command=[make, "check-all", "VERBOSE=1", |
NAKAMURA Takumi | 1a4666b | 2013-01-19 03:39:07 +0000 | [diff] [blame] | 218 | WithProperties("LIT_ARGS=%s" % clangTestArgs), |
David Blaikie | bc68401 | 2012-12-27 20:44:19 +0000 | [diff] [blame] | 219 | WithProperties("EXTRA_TESTDIRS=%s" % extraTestDirs)], |
David Blaikie | 0551733 | 2013-12-19 23:29:12 +0000 | [diff] [blame] | 220 | flunkOnFailure=not run_gdb, |
David Blaikie | 7e6f8a1 | 2012-08-31 20:46:27 +0000 | [diff] [blame] | 221 | description=["checking"], |
| 222 | descriptionDone=["checked"], |
Daniel Dunbar | 469e8ca | 2010-05-19 21:26:48 +0000 | [diff] [blame] | 223 | workdir=llvm_1_objdir, |
Galina Kistanova | f4d7935 | 2011-10-20 20:46:52 +0000 | [diff] [blame] | 224 | usePTY=use_pty_in_tests, |
| 225 | env=merged_env)) |
Daniel Dunbar | 8a89a6f | 2009-11-25 04:27:32 +0000 | [diff] [blame] | 226 | |
Galina Kistanova | a06e4c8 | 2016-04-14 21:41:30 +0000 | [diff] [blame] | 227 | # TODO: Install llvm and clang for stage1. |
Daniel Dunbar | 8a89a6f | 2009-11-25 04:27:32 +0000 | [diff] [blame] | 228 | |
David Blaikie | dad03d5 | 2012-11-16 22:37:12 +0000 | [diff] [blame] | 229 | if run_gdb or run_gcc or run_modern_gdb: |
David Blaikie | a76da84 | 2012-08-13 22:24:46 +0000 | [diff] [blame] | 230 | ignores = getClangTestsIgnoresFromPath(os.path.expanduser('~/public/clang-tests'), 'clang-x86_64-darwin10') |
| 231 | install_prefix = "%%(builddir)s/%s" % llvm_1_installdir |
| 232 | if run_gdb: |
| 233 | addClangGDBTests(f, ignores, install_prefix) |
David Blaikie | dad03d5 | 2012-11-16 22:37:12 +0000 | [diff] [blame] | 234 | if run_modern_gdb: |
David Blaikie | 41d09c3 | 2013-01-02 21:11:09 +0000 | [diff] [blame] | 235 | addModernClangGDBTests(f, jobs, install_prefix) |
David Blaikie | a76da84 | 2012-08-13 22:24:46 +0000 | [diff] [blame] | 236 | if run_gcc: |
| 237 | addClangGCCTests(f, ignores, install_prefix) |
| 238 | |
Daniel Dunbar | 8a89a6f | 2009-11-25 04:27:32 +0000 | [diff] [blame] | 239 | if not useTwoStage: |
Daniel Dunbar | dedf657 | 2010-11-13 00:23:34 +0000 | [diff] [blame] | 240 | if package_dst: |
| 241 | name = WithProperties( |
| 242 | "%(builddir)s/" + llvm_1_objdir + |
| 243 | "/clang-r%(got_revision)s-b%(buildnumber)s.tgz") |
| 244 | f.addStep(ShellCommand(name='pkg.tar', |
| 245 | description="tar root", |
| 246 | command=["tar", "zcvf", name, "./"], |
| 247 | workdir=llvm_1_installdir, |
| 248 | warnOnFailure=True, |
| 249 | flunkOnFailure=False, |
Galina Kistanova | f4d7935 | 2011-10-20 20:46:52 +0000 | [diff] [blame] | 250 | haltOnFailure=False, |
| 251 | env=merged_env)) |
Daniel Dunbar | dedf657 | 2010-11-13 00:23:34 +0000 | [diff] [blame] | 252 | f.addStep(ShellCommand(name='pkg.upload', |
Andrew Trick | 70fa9d2 | 2011-08-25 23:38:51 +0000 | [diff] [blame] | 253 | description="upload root", |
Daniel Dunbar | dedf657 | 2010-11-13 00:23:34 +0000 | [diff] [blame] | 254 | command=["scp", name, |
| 255 | WithProperties( |
| 256 | package_dst + "/%(buildername)s")], |
| 257 | workdir=".", |
| 258 | warnOnFailure=True, |
| 259 | flunkOnFailure=False, |
Galina Kistanova | f4d7935 | 2011-10-20 20:46:52 +0000 | [diff] [blame] | 260 | haltOnFailure=False, |
| 261 | env=merged_env)) |
Daniel Dunbar | dedf657 | 2010-11-13 00:23:34 +0000 | [diff] [blame] | 262 | |
Daniel Dunbar | 8a89a6f | 2009-11-25 04:27:32 +0000 | [diff] [blame] | 263 | return f |
| 264 | |
| 265 | # Clean up llvm (stage 2). |
Richard Smith | 0238916 | 2014-09-26 23:53:06 +0000 | [diff] [blame] | 266 | # |
Galina Kistanova | 7990097 | 2015-11-16 17:30:42 +0000 | [diff] [blame] | 267 | # We always cleanly build the stage 2. If the compiler has been |
| 268 | # changed on the stage 1, we cannot trust any of the intermediate file |
| 269 | # from the old compiler. And if the stage 1 compiler is the same, we should |
| 270 | # not build in the first place. |
| 271 | f.addStep(ShellCommand(name="rm-llvm.obj.stage2", |
| 272 | command=["rm", "-rf", llvm_2_objdir], |
| 273 | haltOnFailure=True, |
| 274 | description=["rm build dir", "llvm", "(stage 2)"], |
| 275 | workdir=".", |
| 276 | env=merged_env)) |
Daniel Dunbar | 8a89a6f | 2009-11-25 04:27:32 +0000 | [diff] [blame] | 277 | |
| 278 | # Configure llvm (stage 2). |
Galina Kistanova | a06e4c8 | 2016-04-14 21:41:30 +0000 | [diff] [blame] | 279 | f.addStep(ShellCommand(name='cmake', |
Vassil Vassilev | 5a9b9ed | 2016-05-25 17:10:03 +0000 | [diff] [blame] | 280 | command=['cmake'] + stage2_extra_configure_args + [ |
Galina Kistanova | a06e4c8 | 2016-04-14 21:41:30 +0000 | [diff] [blame] | 281 | '-DLLVM_BUILD_TESTS=ON', |
| 282 | WithProperties('-DCMAKE_C_COMPILER=%%(builddir)s/%s/bin/clang' % llvm_1_objdir), # FIXME use installdir |
| 283 | WithProperties('-DCMAKE_CXX_COMPILER=%%(builddir)s/%s/bin/clang++' % llvm_1_objdir), |
| 284 | '-DCMAKE_BUILD_TYPE=%s' % stage2_config, |
Galina Kistanova | a06e4c8 | 2016-04-14 21:41:30 +0000 | [diff] [blame] | 285 | "../" + llvm_srcdir], |
| 286 | description='cmake stage2', |
| 287 | workdir=llvm_2_objdir, |
| 288 | env=merged_env)) |
Daniel Dunbar | 8a89a6f | 2009-11-25 04:27:32 +0000 | [diff] [blame] | 289 | |
| 290 | # Build llvm (stage 2). |
| 291 | f.addStep(WarningCountingShellCommand(name="compile.llvm.stage2", |
| 292 | command=['nice', '-n', '10', |
| 293 | make, WithProperties("-j%s" % jobs)], |
| 294 | haltOnFailure=True, |
| 295 | description=["compiling", "(stage 2)", |
| 296 | stage2_config], |
| 297 | descriptionDone=["compile", "(stage 2)", |
| 298 | stage2_config], |
Galina Kistanova | f4d7935 | 2011-10-20 20:46:52 +0000 | [diff] [blame] | 299 | workdir=llvm_2_objdir, |
| 300 | env=merged_env)) |
Daniel Dunbar | 8a89a6f | 2009-11-25 04:27:32 +0000 | [diff] [blame] | 301 | |
| 302 | if test: |
Michael Gottesman | a6b5be8 | 2013-06-28 21:57:20 +0000 | [diff] [blame] | 303 | f.addStep(lit_test_command.LitTestCommand(name='check-all', |
David Blaikie | 7e6f8a1 | 2012-08-31 20:46:27 +0000 | [diff] [blame] | 304 | command=[make, "check-all", "VERBOSE=1", |
NAKAMURA Takumi | 1a4666b | 2013-01-19 03:39:07 +0000 | [diff] [blame] | 305 | WithProperties("LIT_ARGS=%s" % clangTestArgs), |
David Blaikie | bc68401 | 2012-12-27 20:44:19 +0000 | [diff] [blame] | 306 | WithProperties("EXTRA_TESTDIRS=%s" % extraTestDirs)], |
David Blaikie | 7e6f8a1 | 2012-08-31 20:46:27 +0000 | [diff] [blame] | 307 | description=["checking"], |
| 308 | descriptionDone=["checked"], |
Daniel Dunbar | 469e8ca | 2010-05-19 21:26:48 +0000 | [diff] [blame] | 309 | workdir=llvm_2_objdir, |
Galina Kistanova | f4d7935 | 2011-10-20 20:46:52 +0000 | [diff] [blame] | 310 | usePTY=use_pty_in_tests, |
| 311 | env=merged_env)) |
Daniel Dunbar | 8a89a6f | 2009-11-25 04:27:32 +0000 | [diff] [blame] | 312 | |
Galina Kistanova | a06e4c8 | 2016-04-14 21:41:30 +0000 | [diff] [blame] | 313 | # TODO: Install llvm and clang for stage2. |
Daniel Dunbar | 3efb782 | 2010-02-26 19:20:00 +0000 | [diff] [blame] | 314 | |
| 315 | if package_dst: |
| 316 | name = WithProperties( |
| 317 | "%(builddir)s/" + llvm_2_objdir + |
| 318 | "/clang-r%(got_revision)s-b%(buildnumber)s.tgz") |
| 319 | f.addStep(ShellCommand(name='pkg.tar', |
| 320 | description="tar root", |
| 321 | command=["tar", "zcvf", name, "./"], |
| 322 | workdir=llvm_2_installdir, |
| 323 | warnOnFailure=True, |
| 324 | flunkOnFailure=False, |
Galina Kistanova | f4d7935 | 2011-10-20 20:46:52 +0000 | [diff] [blame] | 325 | haltOnFailure=False, |
| 326 | env=merged_env)) |
Daniel Dunbar | 3efb782 | 2010-02-26 19:20:00 +0000 | [diff] [blame] | 327 | f.addStep(ShellCommand(name='pkg.upload', |
Andrew Trick | 70fa9d2 | 2011-08-25 23:38:51 +0000 | [diff] [blame] | 328 | description="upload root", |
Daniel Dunbar | 3efb782 | 2010-02-26 19:20:00 +0000 | [diff] [blame] | 329 | command=["scp", name, |
| 330 | WithProperties( |
| 331 | package_dst + "/%(buildername)s")], |
| 332 | workdir=".", |
| 333 | warnOnFailure=True, |
| 334 | flunkOnFailure=False, |
Galina Kistanova | f4d7935 | 2011-10-20 20:46:52 +0000 | [diff] [blame] | 335 | haltOnFailure=False, |
| 336 | env=merged_env)) |
Daniel Dunbar | 3efb782 | 2010-02-26 19:20:00 +0000 | [diff] [blame] | 337 | |
Daniel Dunbar | 235aa41 | 2009-07-18 07:16:15 +0000 | [diff] [blame] | 338 | return f |
Daniel Dunbar | 44abe74 | 2009-07-19 01:59:03 +0000 | [diff] [blame] | 339 | |
Galina Kistanova | ff5e78a | 2016-09-06 17:44:53 +0000 | [diff] [blame] | 340 | def addSVNUpdateSteps(f, |
| 341 | checkout_clang_tools_extra, |
| 342 | checkout_compiler_rt, |
Renato Golin | 0bd2a53 | 2016-11-20 16:14:35 +0000 | [diff] [blame] | 343 | checkout_test_suite, |
Artem Belevich | 16fcd0e | 2016-12-21 21:15:56 +0000 | [diff] [blame] | 344 | checkout_lld, |
| 345 | checkout_libcxx): |
Galina Kistanova | ff5e78a | 2016-09-06 17:44:53 +0000 | [diff] [blame] | 346 | # We *must* checkout at least Clang+LLVM |
| 347 | f.addStep(SVN(name='svn-llvm', |
| 348 | mode='update', baseURL='http://llvm.org/svn/llvm-project/llvm/', |
| 349 | defaultBranch='trunk', |
| 350 | workdir='llvm')) |
| 351 | f.addStep(SVN(name='svn-clang', |
| 352 | mode='update', baseURL='http://llvm.org/svn/llvm-project/cfe/', |
| 353 | defaultBranch='trunk', |
| 354 | workdir='llvm/tools/clang')) |
| 355 | |
| 356 | # Extra stuff that will be built/tested |
| 357 | if checkout_clang_tools_extra: |
| 358 | f.addStep(SVN(name='svn-clang-tools-extra', |
| 359 | mode='update', baseURL='http://llvm.org/svn/llvm-project/clang-tools-extra/', |
| 360 | defaultBranch='trunk', |
| 361 | workdir='llvm/tools/clang/tools/extra')) |
| 362 | if checkout_compiler_rt: |
| 363 | f.addStep(SVN(name='svn-compiler-rt', |
| 364 | mode='update', baseURL='http://llvm.org/svn/llvm-project/compiler-rt/', |
| 365 | defaultBranch='trunk', |
| 366 | workdir='llvm/projects/compiler-rt')) |
| 367 | if checkout_test_suite: |
| 368 | f.addStep(SVN(name='svn-lnt', |
| 369 | mode='update', baseURL='http://llvm.org/svn/llvm-project/lnt/', |
| 370 | defaultBranch='trunk', |
| 371 | workdir='test/lnt')) |
| 372 | f.addStep(SVN(name='svn-test-suite', |
Galina Kistanova | a86d0c7 | 2018-04-04 00:54:30 +0000 | [diff] [blame] | 373 | mode='update', baseURL='https://llvm.org/svn/llvm-project/test-suite/', |
Galina Kistanova | ff5e78a | 2016-09-06 17:44:53 +0000 | [diff] [blame] | 374 | defaultBranch='trunk', |
| 375 | workdir='test/test-suite')) |
Renato Golin | 0bd2a53 | 2016-11-20 16:14:35 +0000 | [diff] [blame] | 376 | if checkout_lld: |
| 377 | f.addStep(SVN(name='svn-lld', |
| 378 | mode='update', baseURL='http://llvm.org/svn/llvm-project/lld/', |
| 379 | defaultBranch='trunk', |
| 380 | workdir='llvm/tools/lld')) |
Artem Belevich | 16fcd0e | 2016-12-21 21:15:56 +0000 | [diff] [blame] | 381 | if checkout_libcxx: |
| 382 | f.addStep(SVN(name='svn-libcxx', |
| 383 | mode='update', |
| 384 | baseURL='http://llvm.org/svn/llvm-project/libcxx/', |
| 385 | defaultBranch='trunk', |
| 386 | workdir='llvm/projects/libcxx')) |
| 387 | f.addStep(SVN(name='svn-libcxxabi', |
| 388 | mode='update', |
| 389 | baseURL='http://llvm.org/svn/llvm-project/libcxxabi/', |
| 390 | defaultBranch='trunk', |
| 391 | workdir='llvm/projects/libcxxabi')) |
| 392 | f.addStep(SVN(name='svn-libunwind', |
| 393 | mode='update', |
| 394 | baseURL='http://llvm.org/svn/llvm-project/libunwind/', |
| 395 | defaultBranch='trunk', |
| 396 | workdir='llvm/projects/libunwind')) |
Renato Golin | e402f58 | 2014-09-04 19:25:24 +0000 | [diff] [blame] | 397 | |
Daniel Sanders | fa22233 | 2015-12-04 14:30:39 +0000 | [diff] [blame] | 398 | def addGCSUploadSteps(f, package_name, install_prefix, gcs_directory, env, |
Leandro Nunes | 7b83ba4 | 2018-06-25 13:54:50 +0000 | [diff] [blame] | 399 | gcs_url_property=None, use_pixz_compression=False, |
| 400 | xz_compression_factor=6): |
Daniel Sanders | fa22233 | 2015-12-04 14:30:39 +0000 | [diff] [blame] | 401 | """ |
| 402 | Add steps to upload to the Google Cloud Storage bucket. |
| 403 | |
| 404 | f - The BuildFactory to modify. |
| 405 | package_name - The name of this package for the descriptions (e.g. |
| 406 | 'stage 1') |
| 407 | install_prefix - The directory the build has been installed to. |
| 408 | gcs_directory - The subdirectory of the bucket root to upload to. This |
| 409 | should match the builder name. |
| 410 | env - The environment to use. Set BOTO_CONFIG to use a configuration file |
| 411 | in a non-standard location, and BUCKET to use a different GCS bucket. |
| 412 | gcs_url_property - Property to assign the GCS url to. |
| 413 | """ |
| 414 | |
| 415 | gcs_url_fmt = ('gs://%(gcs_bucket)s/%(gcs_directory)s/' |
| 416 | 'clang-r%(got_revision)s-t%(now)s-b%(buildnumber)s.tar.xz') |
| 417 | time_fmt = '%Y-%m-%d_%H-%M-%S' |
Leandro Nunes | 7b83ba4 | 2018-06-25 13:54:50 +0000 | [diff] [blame] | 418 | output_file_name = '../install.tar.xz' |
| 419 | |
Daniel Sanders | fa22233 | 2015-12-04 14:30:39 +0000 | [diff] [blame] | 420 | gcs_url = \ |
| 421 | WithProperties( |
| 422 | gcs_url_fmt, |
| 423 | gcs_bucket=lambda _: env.get('BUCKET', 'llvm-build-artifacts'), |
| 424 | gcs_directory=lambda _: gcs_directory, |
| 425 | now=lambda _: datetime.utcnow().strftime(time_fmt)) |
| 426 | |
| 427 | if gcs_url_property: |
| 428 | f.addStep(SetProperty( |
| 429 | name="record GCS url for " + package_name, |
| 430 | command=['echo', gcs_url], |
| 431 | property=gcs_url_property)) |
| 432 | |
Leandro Nunes | 7b83ba4 | 2018-06-25 13:54:50 +0000 | [diff] [blame] | 433 | if use_pixz_compression: |
| 434 | # tweak the xz compression level to generate packages faster |
| 435 | tar_command = ['tar', '-Ipixz', '-cvf', output_file_name, '.'] |
| 436 | else: |
| 437 | xz_command = 'xz -{0}'.format(xz_compression_factor) |
| 438 | tar_command = ['tar', '-I', xz_command, '-cvf', output_file_name, '.'] |
| 439 | |
Daniel Sanders | fa22233 | 2015-12-04 14:30:39 +0000 | [diff] [blame] | 440 | f.addStep(ShellCommand(name='package ' + package_name, |
Leandro Nunes | 7b83ba4 | 2018-06-25 13:54:50 +0000 | [diff] [blame] | 441 | command=tar_command, |
Daniel Sanders | fa22233 | 2015-12-04 14:30:39 +0000 | [diff] [blame] | 442 | description='packaging ' + package_name + '...', |
| 443 | workdir=install_prefix, |
| 444 | env=env)) |
| 445 | |
| 446 | f.addStep(ShellCommand( |
| 447 | name='upload ' + package_name + ' to storage bucket', |
| 448 | command=['gsutil', 'cp', '../install.tar.xz', gcs_url], |
| 449 | description=('uploading ' + package_name + |
| 450 | 'to storage bucket ...'), |
| 451 | workdir=install_prefix, |
| 452 | env=env)) |
| 453 | |
| 454 | def getClangCMakeGCSBuildFactory( |
| 455 | clean=True, |
| 456 | test=True, |
Galina Kistanova | ff5e78a | 2016-09-06 17:44:53 +0000 | [diff] [blame] | 457 | cmake='cmake', |
Daniel Sanders | fa22233 | 2015-12-04 14:30:39 +0000 | [diff] [blame] | 458 | jobs=None, |
| 459 | |
| 460 | # VS tools environment variable if using MSVC. For example, |
| 461 | # %VS120COMNTOOLS% selects the 2013 toolchain. |
| 462 | vs=None, |
Galina Kistanova | ff5e78a | 2016-09-06 17:44:53 +0000 | [diff] [blame] | 463 | vs_target_arch='x86', |
Stella Stamenova | 61f2e26 | 2018-10-25 20:30:08 +0000 | [diff] [blame] | 464 | autodetectVS=False, |
Daniel Sanders | fa22233 | 2015-12-04 14:30:39 +0000 | [diff] [blame] | 465 | |
| 466 | # Multi-stage compilation |
| 467 | useTwoStage=False, |
| 468 | testStage1=True, |
Galina Kistanova | ff5e78a | 2016-09-06 17:44:53 +0000 | [diff] [blame] | 469 | stage1_config='Release', |
| 470 | stage2_config='Release', |
Daniel Sanders | fa22233 | 2015-12-04 14:30:39 +0000 | [diff] [blame] | 471 | |
| 472 | # Test-suite |
| 473 | runTestSuite=False, |
Galina Kistanova | ff5e78a | 2016-09-06 17:44:53 +0000 | [diff] [blame] | 474 | nt_flags=[], |
Kristof Beyls | f4639b5 | 2017-08-10 08:53:52 +0000 | [diff] [blame] | 475 | testsuite_flags=[], |
Daniel Sanders | fa22233 | 2015-12-04 14:30:39 +0000 | [diff] [blame] | 476 | submitURL=None, |
| 477 | testerName=None, |
| 478 | |
| 479 | # Environmental variables for all steps. |
Galina Kistanova | ff5e78a | 2016-09-06 17:44:53 +0000 | [diff] [blame] | 480 | env={}, |
| 481 | extra_cmake_args=[], |
Daniel Sanders | fa22233 | 2015-12-04 14:30:39 +0000 | [diff] [blame] | 482 | |
| 483 | # Extra repositories |
| 484 | checkout_clang_tools_extra=True, |
| 485 | checkout_compiler_rt=True, |
Renato Golin | 0bd2a53 | 2016-11-20 16:14:35 +0000 | [diff] [blame] | 486 | checkout_lld=True, |
Leandro Nunes | 7b83ba4 | 2018-06-25 13:54:50 +0000 | [diff] [blame] | 487 | checkout_libcxx=False, |
Daniel Sanders | fa22233 | 2015-12-04 14:30:39 +0000 | [diff] [blame] | 488 | |
| 489 | # Upload artifacts to Google Cloud Storage (for the llvmbisect tool) |
| 490 | stage1_upload_directory=None, |
Galina Kistanova | ff5e78a | 2016-09-06 17:44:53 +0000 | [diff] [blame] | 491 | |
Leandro Nunes | 7b83ba4 | 2018-06-25 13:54:50 +0000 | [diff] [blame] | 492 | # Use a lower compression level to generate the build-cache package faster. |
| 493 | # defuault is 6 according to xz documentation |
| 494 | xz_compression_factor=6, |
| 495 | use_pixz_compression=False, |
| 496 | |
Galina Kistanova | ff5e78a | 2016-09-06 17:44:53 +0000 | [diff] [blame] | 497 | # Triggers |
| 498 | trigger_after_stage1=[]): |
Daniel Sanders | fa22233 | 2015-12-04 14:30:39 +0000 | [diff] [blame] | 499 | return _getClangCMakeBuildFactory( |
Stella Stamenova | 61f2e26 | 2018-10-25 20:30:08 +0000 | [diff] [blame] | 500 | clean=clean, test=test, cmake=cmake, jobs=jobs, |
| 501 | vs=vs, vs_target_arch=vs_target_arch, autodetectVS=autodetectVS, |
| 502 | useTwoStage=useTwoStage, |
Daniel Sanders | fa22233 | 2015-12-04 14:30:39 +0000 | [diff] [blame] | 503 | testStage1=testStage1, stage1_config=stage1_config, |
| 504 | stage2_config=stage2_config, runTestSuite=runTestSuite, |
Kristof Beyls | f4639b5 | 2017-08-10 08:53:52 +0000 | [diff] [blame] | 505 | nt_flags=nt_flags, testsuite_flags=testsuite_flags, |
| 506 | submitURL=submitURL, testerName=testerName, |
Daniel Sanders | fa22233 | 2015-12-04 14:30:39 +0000 | [diff] [blame] | 507 | env=env, extra_cmake_args=extra_cmake_args, |
| 508 | checkout_clang_tools_extra=checkout_clang_tools_extra, |
| 509 | checkout_compiler_rt=checkout_compiler_rt, |
Renato Golin | 0bd2a53 | 2016-11-20 16:14:35 +0000 | [diff] [blame] | 510 | checkout_lld=checkout_lld, |
Leandro Nunes | 7b83ba4 | 2018-06-25 13:54:50 +0000 | [diff] [blame] | 511 | checkout_libcxx=checkout_libcxx, |
Daniel Sanders | fa22233 | 2015-12-04 14:30:39 +0000 | [diff] [blame] | 512 | stage1_upload_directory=stage1_upload_directory, |
Leandro Nunes | 7b83ba4 | 2018-06-25 13:54:50 +0000 | [diff] [blame] | 513 | xz_compression_factor=xz_compression_factor, |
| 514 | use_pixz_compression=use_pixz_compression, |
Galina Kistanova | ff5e78a | 2016-09-06 17:44:53 +0000 | [diff] [blame] | 515 | trigger_after_stage1=trigger_after_stage1) |
Reid Kleckner | 25a26b0 | 2015-03-09 22:30:25 +0000 | [diff] [blame] | 516 | |
| 517 | def getClangCMakeBuildFactory( |
| 518 | clean=True, |
| 519 | test=True, |
Galina Kistanova | ff5e78a | 2016-09-06 17:44:53 +0000 | [diff] [blame] | 520 | cmake='cmake', |
Reid Kleckner | 25a26b0 | 2015-03-09 22:30:25 +0000 | [diff] [blame] | 521 | jobs=None, |
| 522 | |
| 523 | # VS tools environment variable if using MSVC. For example, |
| 524 | # %VS120COMNTOOLS% selects the 2013 toolchain. |
| 525 | vs=None, |
Galina Kistanova | ff5e78a | 2016-09-06 17:44:53 +0000 | [diff] [blame] | 526 | vs_target_arch='x86', |
Stella Stamenova | 61f2e26 | 2018-10-25 20:30:08 +0000 | [diff] [blame] | 527 | autodetectVS=False, |
Reid Kleckner | 25a26b0 | 2015-03-09 22:30:25 +0000 | [diff] [blame] | 528 | |
| 529 | # Multi-stage compilation |
| 530 | useTwoStage=False, |
| 531 | testStage1=True, |
Galina Kistanova | ff5e78a | 2016-09-06 17:44:53 +0000 | [diff] [blame] | 532 | stage1_config='Release', |
| 533 | stage2_config='Release', |
Reid Kleckner | 25a26b0 | 2015-03-09 22:30:25 +0000 | [diff] [blame] | 534 | |
Renato Golin | 61aed7f | 2015-06-17 19:12:50 +0000 | [diff] [blame] | 535 | # Test-suite |
| 536 | runTestSuite=False, |
Galina Kistanova | ff5e78a | 2016-09-06 17:44:53 +0000 | [diff] [blame] | 537 | nt_flags=[], |
Kristof Beyls | f4639b5 | 2017-08-10 08:53:52 +0000 | [diff] [blame] | 538 | testsuite_flags=[], |
Renato Golin | 61aed7f | 2015-06-17 19:12:50 +0000 | [diff] [blame] | 539 | submitURL=None, |
| 540 | testerName=None, |
| 541 | |
Reid Kleckner | 25a26b0 | 2015-03-09 22:30:25 +0000 | [diff] [blame] | 542 | # Environmental variables for all steps. |
Galina Kistanova | ff5e78a | 2016-09-06 17:44:53 +0000 | [diff] [blame] | 543 | env={}, |
| 544 | extra_cmake_args=[], |
Reid Kleckner | 25a26b0 | 2015-03-09 22:30:25 +0000 | [diff] [blame] | 545 | |
| 546 | # Extra repositories |
| 547 | checkout_clang_tools_extra=True, |
Renato Golin | 0bd2a53 | 2016-11-20 16:14:35 +0000 | [diff] [blame] | 548 | checkout_compiler_rt=True, |
Artem Belevich | 16fcd0e | 2016-12-21 21:15:56 +0000 | [diff] [blame] | 549 | checkout_lld=True, |
| 550 | checkout_libcxx=False, |
| 551 | checkout_test_suite=False): |
Daniel Sanders | fa22233 | 2015-12-04 14:30:39 +0000 | [diff] [blame] | 552 | return _getClangCMakeBuildFactory( |
Stella Stamenova | 61f2e26 | 2018-10-25 20:30:08 +0000 | [diff] [blame] | 553 | clean=clean, test=test, cmake=cmake, jobs=jobs, |
| 554 | vs=vs, vs_target_arch=vs_target_arch, autodetectVS=autodetectVS, |
| 555 | useTwoStage=useTwoStage, |
Daniel Sanders | fa22233 | 2015-12-04 14:30:39 +0000 | [diff] [blame] | 556 | testStage1=testStage1, stage1_config=stage1_config, |
| 557 | stage2_config=stage2_config, runTestSuite=runTestSuite, |
Kristof Beyls | f4639b5 | 2017-08-10 08:53:52 +0000 | [diff] [blame] | 558 | nt_flags=nt_flags, testsuite_flags=testsuite_flags, |
| 559 | submitURL=submitURL, testerName=testerName, |
Daniel Sanders | fa22233 | 2015-12-04 14:30:39 +0000 | [diff] [blame] | 560 | env=env, extra_cmake_args=extra_cmake_args, |
| 561 | checkout_clang_tools_extra=checkout_clang_tools_extra, |
Renato Golin | 0bd2a53 | 2016-11-20 16:14:35 +0000 | [diff] [blame] | 562 | checkout_lld=checkout_lld, |
Artem Belevich | 16fcd0e | 2016-12-21 21:15:56 +0000 | [diff] [blame] | 563 | checkout_compiler_rt=checkout_compiler_rt, |
| 564 | checkout_libcxx=checkout_libcxx, |
| 565 | checkout_test_suite=checkout_test_suite) |
Daniel Sanders | fa22233 | 2015-12-04 14:30:39 +0000 | [diff] [blame] | 566 | |
| 567 | def _getClangCMakeBuildFactory( |
| 568 | clean=True, |
| 569 | test=True, |
Galina Kistanova | ff5e78a | 2016-09-06 17:44:53 +0000 | [diff] [blame] | 570 | cmake='cmake', |
Daniel Sanders | fa22233 | 2015-12-04 14:30:39 +0000 | [diff] [blame] | 571 | jobs=None, |
| 572 | |
| 573 | # VS tools environment variable if using MSVC. For example, |
| 574 | # %VS120COMNTOOLS% selects the 2013 toolchain. |
| 575 | vs=None, |
Galina Kistanova | ff5e78a | 2016-09-06 17:44:53 +0000 | [diff] [blame] | 576 | vs_target_arch='x86', |
Stella Stamenova | 61f2e26 | 2018-10-25 20:30:08 +0000 | [diff] [blame] | 577 | autodetectVS=False, |
Daniel Sanders | fa22233 | 2015-12-04 14:30:39 +0000 | [diff] [blame] | 578 | |
| 579 | # Multi-stage compilation |
| 580 | useTwoStage=False, |
| 581 | testStage1=True, |
Galina Kistanova | ff5e78a | 2016-09-06 17:44:53 +0000 | [diff] [blame] | 582 | stage1_config='Release', |
| 583 | stage2_config='Release', |
Daniel Sanders | fa22233 | 2015-12-04 14:30:39 +0000 | [diff] [blame] | 584 | |
| 585 | # Test-suite |
| 586 | runTestSuite=False, |
Galina Kistanova | ff5e78a | 2016-09-06 17:44:53 +0000 | [diff] [blame] | 587 | nt_flags=[], |
Kristof Beyls | f4639b5 | 2017-08-10 08:53:52 +0000 | [diff] [blame] | 588 | testsuite_flags=[], |
Daniel Sanders | fa22233 | 2015-12-04 14:30:39 +0000 | [diff] [blame] | 589 | submitURL=None, |
| 590 | testerName=None, |
| 591 | |
| 592 | # Environmental variables for all steps. |
Galina Kistanova | ff5e78a | 2016-09-06 17:44:53 +0000 | [diff] [blame] | 593 | env={}, |
| 594 | extra_cmake_args=[], |
Daniel Sanders | fa22233 | 2015-12-04 14:30:39 +0000 | [diff] [blame] | 595 | |
| 596 | # Extra repositories |
| 597 | checkout_clang_tools_extra=True, |
| 598 | checkout_compiler_rt=True, |
Renato Golin | 0bd2a53 | 2016-11-20 16:14:35 +0000 | [diff] [blame] | 599 | checkout_lld=True, |
Artem Belevich | 16fcd0e | 2016-12-21 21:15:56 +0000 | [diff] [blame] | 600 | checkout_libcxx=False, |
| 601 | checkout_test_suite=False, |
Daniel Sanders | fa22233 | 2015-12-04 14:30:39 +0000 | [diff] [blame] | 602 | |
| 603 | # Upload artifacts to Google Cloud Storage (for the llvmbisect tool) |
| 604 | stage1_upload_directory=None, |
| 605 | |
Leandro Nunes | 7b83ba4 | 2018-06-25 13:54:50 +0000 | [diff] [blame] | 606 | # Use a lower compression level to generate the build-cache package faster |
| 607 | # default is 6 according to documentation |
| 608 | xz_compression_factor=6, |
| 609 | use_pixz_compression=False, |
| 610 | |
Galina Kistanova | ff5e78a | 2016-09-06 17:44:53 +0000 | [diff] [blame] | 611 | # Triggers |
| 612 | trigger_after_stage1=[]): |
Reid Kleckner | 25a26b0 | 2015-03-09 22:30:25 +0000 | [diff] [blame] | 613 | |
| 614 | ############# PREPARING |
Galina Kistanova | ff5e78a | 2016-09-06 17:44:53 +0000 | [diff] [blame] | 615 | f = buildbot.process.factory.BuildFactory() |
Reid Kleckner | 25a26b0 | 2015-03-09 22:30:25 +0000 | [diff] [blame] | 616 | |
Galina Kistanova | 49cbd60 | 2017-04-14 23:46:03 +0000 | [diff] [blame] | 617 | clean_build_requested = lambda step: clean or step.build.getProperty("clean") |
| 618 | |
Galina Kistanova | ff5e78a | 2016-09-06 17:44:53 +0000 | [diff] [blame] | 619 | addSVNUpdateSteps(f, |
| 620 | checkout_clang_tools_extra=checkout_clang_tools_extra, |
| 621 | checkout_compiler_rt=checkout_compiler_rt, |
Renato Golin | 0bd2a53 | 2016-11-20 16:14:35 +0000 | [diff] [blame] | 622 | checkout_lld=checkout_lld, |
Artem Belevich | 16fcd0e | 2016-12-21 21:15:56 +0000 | [diff] [blame] | 623 | checkout_test_suite=runTestSuite or checkout_test_suite, |
| 624 | checkout_libcxx=checkout_libcxx) |
Reid Kleckner | 25a26b0 | 2015-03-09 22:30:25 +0000 | [diff] [blame] | 625 | |
Renato Golin | e402f58 | 2014-09-04 19:25:24 +0000 | [diff] [blame] | 626 | # If jobs not defined, Ninja will choose a suitable value |
Renato Golin | cc83db3 | 2015-06-17 19:23:40 +0000 | [diff] [blame] | 627 | jobs_cmd = [] |
| 628 | lit_args = "'-v" |
Renato Golin | e402f58 | 2014-09-04 19:25:24 +0000 | [diff] [blame] | 629 | if jobs is not None: |
Renato Golin | cc83db3 | 2015-06-17 19:23:40 +0000 | [diff] [blame] | 630 | jobs_cmd = ["-j"+str(jobs)] |
| 631 | lit_args += " -j"+str(jobs)+"'" |
Renato Golin | e402f58 | 2014-09-04 19:25:24 +0000 | [diff] [blame] | 632 | else: |
Renato Golin | cc83db3 | 2015-06-17 19:23:40 +0000 | [diff] [blame] | 633 | lit_args += "'" |
| 634 | ninja_cmd = ['ninja'] + jobs_cmd |
| 635 | ninja_install_cmd = ['ninja', 'install'] + jobs_cmd |
| 636 | ninja_check_cmd = ['ninja', 'check-all'] + jobs_cmd |
Renato Golin | e402f58 | 2014-09-04 19:25:24 +0000 | [diff] [blame] | 637 | |
| 638 | # Global configurations |
Renato Golin | cc83db3 | 2015-06-17 19:23:40 +0000 | [diff] [blame] | 639 | stage1_build = 'stage1' |
| 640 | stage1_install = 'stage1.install' |
| 641 | stage2_build = 'stage2' |
| 642 | stage2_install = 'stage2.install' |
Renato Golin | e402f58 | 2014-09-04 19:25:24 +0000 | [diff] [blame] | 643 | |
Reid Kleckner | 25a26b0 | 2015-03-09 22:30:25 +0000 | [diff] [blame] | 644 | # Set up VS environment, if appropriate. |
Stella Stamenova | 61f2e26 | 2018-10-25 20:30:08 +0000 | [diff] [blame] | 645 | if vs or autodetectVS: |
Reid Kleckner | 25a26b0 | 2015-03-09 22:30:25 +0000 | [diff] [blame] | 646 | f.addStep(SetProperty( |
Stella Stamenova | 61f2e26 | 2018-10-25 20:30:08 +0000 | [diff] [blame] | 647 | command=builders_util.getVisualStudioEnvironment(vs, vs_target_arch, autodetectVS), |
Reid Kleckner | 25a26b0 | 2015-03-09 22:30:25 +0000 | [diff] [blame] | 648 | extract_fn=builders_util.extractSlaveEnvironment)) |
| 649 | assert not env, "Can't have custom builder env vars with VS" |
| 650 | env = Property('slave_env') |
| 651 | |
Galina Kistanova | ff5e78a | 2016-09-06 17:44:53 +0000 | [diff] [blame] | 652 | |
Renato Golin | e402f58 | 2014-09-04 19:25:24 +0000 | [diff] [blame] | 653 | ############# CLEANING |
Galina Kistanova | 49cbd60 | 2017-04-14 23:46:03 +0000 | [diff] [blame] | 654 | f.addStep(ShellCommand(name='clean stage 1', |
| 655 | command=['rm','-rf',stage1_build], |
| 656 | warnOnFailure=True, |
| 657 | haltOnFailure=False, |
| 658 | flunkOnFailure=False, |
| 659 | description='cleaning stage 1', |
| 660 | descriptionDone='clean', |
| 661 | workdir='.', |
| 662 | doStepIf=clean_build_requested)) |
Renato Golin | e402f58 | 2014-09-04 19:25:24 +0000 | [diff] [blame] | 663 | |
| 664 | |
| 665 | ############# STAGE 1 |
| 666 | f.addStep(ShellCommand(name='cmake stage 1', |
| 667 | command=[cmake, "-G", "Ninja", "../llvm", |
| 668 | "-DCMAKE_BUILD_TYPE="+stage1_config, |
| 669 | "-DLLVM_ENABLE_ASSERTIONS=True", |
| 670 | "-DLLVM_LIT_ARGS="+lit_args, |
| 671 | "-DCMAKE_INSTALL_PREFIX=../"+stage1_install] |
| 672 | + extra_cmake_args, |
| 673 | haltOnFailure=True, |
| 674 | description='cmake stage 1', |
| 675 | workdir=stage1_build, |
Galina Kistanova | 49cbd60 | 2017-04-14 23:46:03 +0000 | [diff] [blame] | 676 | doStepIf=FileDoesNotExist("build.ninja"), |
Renato Golin | e402f58 | 2014-09-04 19:25:24 +0000 | [diff] [blame] | 677 | env=env)) |
| 678 | |
| 679 | f.addStep(WarningCountingShellCommand(name='build stage 1', |
| 680 | command=ninja_cmd, |
| 681 | haltOnFailure=True, |
| 682 | description='ninja all', |
| 683 | workdir=stage1_build, |
| 684 | env=env)) |
| 685 | |
| 686 | if test and testStage1: |
Renato Golin | d1c4674 | 2015-08-06 18:05:34 +0000 | [diff] [blame] | 687 | haltOnStage1Check = not useTwoStage and not runTestSuite |
Renato Golin | cfbd570 | 2014-09-06 19:09:16 +0000 | [diff] [blame] | 688 | f.addStep(lit_test_command.LitTestCommand(name='ninja check 1', |
| 689 | command=ninja_check_cmd, |
Renato Golin | d1c4674 | 2015-08-06 18:05:34 +0000 | [diff] [blame] | 690 | haltOnFailure=haltOnStage1Check, |
Renato Golin | cfbd570 | 2014-09-06 19:09:16 +0000 | [diff] [blame] | 691 | description=["checking stage 1"], |
| 692 | descriptionDone=["stage 1 checked"], |
| 693 | workdir=stage1_build, |
| 694 | env=env)) |
Renato Golin | e402f58 | 2014-09-04 19:25:24 +0000 | [diff] [blame] | 695 | |
Daniel Sanders | fa22233 | 2015-12-04 14:30:39 +0000 | [diff] [blame] | 696 | if useTwoStage or runTestSuite or stage1_upload_directory: |
Galina Kistanova | 49cbd60 | 2017-04-14 23:46:03 +0000 | [diff] [blame] | 697 | f.addStep(ShellCommand(name='clean stage 1 install', |
| 698 | command=['rm','-rf',stage1_install], |
| 699 | warnOnFailure=True, |
| 700 | haltOnFailure=False, |
| 701 | flunkOnFailure=False, |
| 702 | description='cleaning stage 1 install', |
| 703 | descriptionDone='clean', |
| 704 | workdir='.')) |
Renato Golin | 61aed7f | 2015-06-17 19:12:50 +0000 | [diff] [blame] | 705 | f.addStep(ShellCommand(name='install stage 1', |
| 706 | command=ninja_install_cmd, |
| 707 | description='ninja install', |
| 708 | workdir=stage1_build, |
Renato Golin | e402f58 | 2014-09-04 19:25:24 +0000 | [diff] [blame] | 709 | env=env)) |
Renato Golin | e402f58 | 2014-09-04 19:25:24 +0000 | [diff] [blame] | 710 | |
Daniel Sanders | fa22233 | 2015-12-04 14:30:39 +0000 | [diff] [blame] | 711 | if stage1_upload_directory: |
| 712 | addGCSUploadSteps(f, 'stage 1', stage1_install, stage1_upload_directory, |
Leandro Nunes | 7b83ba4 | 2018-06-25 13:54:50 +0000 | [diff] [blame] | 713 | env, gcs_url_property='stage1_package_gcs_url', |
| 714 | use_pixz_compression=use_pixz_compression, |
| 715 | xz_compression_factor=xz_compression_factor) |
Daniel Sanders | fa22233 | 2015-12-04 14:30:39 +0000 | [diff] [blame] | 716 | |
Reid Kleckner | 25a26b0 | 2015-03-09 22:30:25 +0000 | [diff] [blame] | 717 | # Compute the cmake define flag to set the C and C++ compiler to clang. Use |
| 718 | # clang-cl if we used MSVC for stage1. |
| 719 | if not vs: |
| 720 | cc = 'clang' |
| 721 | cxx = 'clang++' |
| 722 | else: |
| 723 | cc = 'clang-cl.exe' |
| 724 | cxx = 'clang-cl.exe' |
| 725 | |
Galina Kistanova | ff5e78a | 2016-09-06 17:44:53 +0000 | [diff] [blame] | 726 | |
Renato Golin | 61aed7f | 2015-06-17 19:12:50 +0000 | [diff] [blame] | 727 | ############# STAGE 2 |
| 728 | if useTwoStage: |
Galina Kistanova | 7990097 | 2015-11-16 17:30:42 +0000 | [diff] [blame] | 729 | # We always cleanly build the stage 2. If the compiler has been |
| 730 | # changed on the stage 1, we cannot trust any of the intermediate file |
| 731 | # from the old compiler. And if the stage 1 compiler is the same, we |
| 732 | # should not build in the first place. |
| 733 | f.addStep(ShellCommand(name='clean stage 2', |
| 734 | command=['rm','-rf',stage2_build], |
| 735 | warnOnFailure=True, |
| 736 | description='cleaning stage 2', |
| 737 | descriptionDone='clean', |
Galina Kistanova | 49cbd60 | 2017-04-14 23:46:03 +0000 | [diff] [blame] | 738 | workdir='.')) |
Reid Kleckner | 25a26b0 | 2015-03-09 22:30:25 +0000 | [diff] [blame] | 739 | |
Renato Golin | 61aed7f | 2015-06-17 19:12:50 +0000 | [diff] [blame] | 740 | # Set the compiler using the CC and CXX environment variables to work around |
| 741 | # backslash string escaping bugs somewhere between buildbot and cmake. The |
| 742 | # env.exe helper is required to run the tests, so hopefully it's already on |
| 743 | # PATH. |
| 744 | cmake_cmd2 = ['env', |
| 745 | WithProperties('CC=%(workdir)s/'+stage1_install+'/bin/'+cc), |
| 746 | WithProperties('CXX=%(workdir)s/'+stage1_install+'/bin/'+cxx), |
| 747 | cmake, "-G", "Ninja", "../llvm", |
| 748 | "-DCMAKE_BUILD_TYPE="+stage2_config, |
| 749 | "-DLLVM_ENABLE_ASSERTIONS=True", |
| 750 | "-DLLVM_LIT_ARGS="+lit_args, |
| 751 | "-DCMAKE_INSTALL_PREFIX=../"+stage2_install] + extra_cmake_args |
Reid Kleckner | 25a26b0 | 2015-03-09 22:30:25 +0000 | [diff] [blame] | 752 | |
Renato Golin | 61aed7f | 2015-06-17 19:12:50 +0000 | [diff] [blame] | 753 | f.addStep(ShellCommand(name='cmake stage 2', |
| 754 | command=cmake_cmd2, |
| 755 | haltOnFailure=True, |
| 756 | description='cmake stage 2', |
| 757 | workdir=stage2_build, |
Renato Golin | 61aed7f | 2015-06-17 19:12:50 +0000 | [diff] [blame] | 758 | env=env)) |
| 759 | |
| 760 | f.addStep(WarningCountingShellCommand(name='build stage 2', |
| 761 | command=ninja_cmd, |
| 762 | haltOnFailure=True, |
| 763 | description='ninja all', |
| 764 | workdir=stage2_build, |
| 765 | env=env)) |
| 766 | |
| 767 | if test: |
| 768 | f.addStep(lit_test_command.LitTestCommand(name='ninja check 2', |
| 769 | command=ninja_check_cmd, |
| 770 | haltOnFailure=not runTestSuite, |
| 771 | description=["checking stage 2"], |
| 772 | descriptionDone=["stage 2 checked"], |
| 773 | workdir=stage2_build, |
| 774 | env=env)) |
| 775 | |
| 776 | ############# TEST SUITE |
| 777 | ## Test-Suite (stage 2 if built, stage 1 otherwise) |
| 778 | if runTestSuite: |
| 779 | compiler_path = stage1_install |
| 780 | if useTwoStage: |
| 781 | compiler_path=stage2_install |
Galina Kistanova | 49cbd60 | 2017-04-14 23:46:03 +0000 | [diff] [blame] | 782 | f.addStep(ShellCommand(name='clean stage 2 install', |
| 783 | command=['rm','-rf',stage2_install], |
| 784 | warnOnFailure=True, |
| 785 | description='cleaning stage 2 install', |
| 786 | descriptionDone='clean', |
| 787 | workdir='.')) |
Renato Golin | 61aed7f | 2015-06-17 19:12:50 +0000 | [diff] [blame] | 788 | f.addStep(ShellCommand(name='install stage 2', |
| 789 | command=ninja_install_cmd, |
| 790 | description='ninja install 2', |
Renato Golin | cfbd570 | 2014-09-06 19:09:16 +0000 | [diff] [blame] | 791 | workdir=stage2_build, |
| 792 | env=env)) |
Renato Golin | e402f58 | 2014-09-04 19:25:24 +0000 | [diff] [blame] | 793 | |
Renato Golin | 61aed7f | 2015-06-17 19:12:50 +0000 | [diff] [blame] | 794 | # Get generated python, lnt |
| 795 | python = WithProperties('%(workdir)s/test/sandbox/bin/python') |
| 796 | lnt = WithProperties('%(workdir)s/test/sandbox/bin/lnt') |
| 797 | lnt_setup = WithProperties('%(workdir)s/test/lnt/setup.py') |
| 798 | |
| 799 | # Paths |
| 800 | sandbox = WithProperties('%(workdir)s/test/sandbox') |
| 801 | test_suite_dir = WithProperties('%(workdir)s/test/test-suite') |
| 802 | |
| 803 | # Get latest built Clang (stage1 or stage2) |
| 804 | cc = WithProperties('%(workdir)s/'+compiler_path+'/bin/'+cc) |
| 805 | cxx = WithProperties('%(workdir)s/'+compiler_path+'/bin/'+cxx) |
| 806 | |
Renato Golin | 593e0d6 | 2016-09-21 17:24:56 +0000 | [diff] [blame] | 807 | # LNT Command line (don't pass -jN. Users need to pass both --threads |
Kristof Beyls | f4639b5 | 2017-08-10 08:53:52 +0000 | [diff] [blame] | 808 | # and --build-threads in nt_flags/test_suite_flags to get the same effect) |
| 809 | use_runtest_testsuite = len(nt_flags) == 0 |
| 810 | if not use_runtest_testsuite: |
| 811 | test_suite_cmd = [python, lnt, 'runtest', 'nt', |
| 812 | '--no-timestamp', |
| 813 | '--sandbox', sandbox, |
| 814 | '--test-suite', test_suite_dir, |
| 815 | '--cc', cc, |
| 816 | '--cxx', cxx] |
| 817 | # Append any option provided by the user |
| 818 | test_suite_cmd.extend(nt_flags) |
| 819 | else: |
| 820 | lit = WithProperties('%(workdir)s/'+stage1_build+'/bin/llvm-lit') |
| 821 | test_suite_cmd = [python, lnt, 'runtest', 'test-suite', |
| 822 | '--no-timestamp', |
| 823 | '--sandbox', sandbox, |
| 824 | '--test-suite', test_suite_dir, |
| 825 | '--cc', cc, |
| 826 | '--cxx', cxx, |
| 827 | '--use-lit', lit] |
| 828 | # Append any option provided by the user |
| 829 | test_suite_cmd.extend(testsuite_flags) |
| 830 | |
Renato Golin | 61aed7f | 2015-06-17 19:12:50 +0000 | [diff] [blame] | 831 | # Only submit if a URL has been specified |
| 832 | if submitURL is not None: |
| 833 | if not isinstance(submitURL, list): |
| 834 | submitURL = [submitURL] |
| 835 | for url in submitURL: |
| 836 | test_suite_cmd.extend(['--submit', url]) |
Kristof Beyls | f4639b5 | 2017-08-10 08:53:52 +0000 | [diff] [blame] | 837 | # lnt runtest test-suite doesn't understand --no-machdep-info: |
| 838 | if testerName and not use_runtest_testsuite: |
Renato Golin | 61aed7f | 2015-06-17 19:12:50 +0000 | [diff] [blame] | 839 | test_suite_cmd.extend(['--no-machdep-info', testerName]) |
| 840 | # CC and CXX are needed as env for build-tools |
Renato Golin | e6c1b3b | 2015-07-01 15:52:22 +0000 | [diff] [blame] | 841 | test_suite_env = copy.deepcopy(env) |
Renato Golin | 61aed7f | 2015-06-17 19:12:50 +0000 | [diff] [blame] | 842 | test_suite_env['CC'] = cc |
| 843 | test_suite_env['CXX'] = cxx |
| 844 | |
| 845 | # Steps to prepare, build and run LNT |
| 846 | f.addStep(ShellCommand(name='clean sandbox', |
| 847 | command=['rm', '-rf', 'sandbox'], |
| 848 | haltOnFailure=True, |
| 849 | description='removing sandbox directory', |
| 850 | workdir='test', |
| 851 | env=env)) |
| 852 | f.addStep(ShellCommand(name='recreate sandbox', |
| 853 | command=['virtualenv', 'sandbox'], |
| 854 | haltOnFailure=True, |
| 855 | description='recreating sandbox', |
| 856 | workdir='test', |
| 857 | env=env)) |
| 858 | f.addStep(ShellCommand(name='setup lit', |
| 859 | command=[python, lnt_setup, 'develop'], |
| 860 | haltOnFailure=True, |
| 861 | description='setting up LNT in sandbox', |
| 862 | workdir='test/sandbox', |
| 863 | env=env)) |
| 864 | f.addStep(commands.LitTestCommand.LitTestCommand( |
| 865 | name='test-suite', |
| 866 | command=test_suite_cmd, |
| 867 | haltOnFailure=True, |
| 868 | description=['running the test suite'], |
| 869 | workdir='test/sandbox', |
| 870 | logfiles={'configure.log' : 'build/configure.log', |
| 871 | 'build-tools.log' : 'build/build-tools.log', |
| 872 | 'test.log' : 'build/test.log', |
| 873 | 'report.json' : 'build/report.json'}, |
| 874 | env=test_suite_env)) |
| 875 | |
Renato Golin | e402f58 | 2014-09-04 19:25:24 +0000 | [diff] [blame] | 876 | return f |
| 877 | |
Daniel Dunbar | 7363d03 | 2011-02-27 03:22:35 +0000 | [diff] [blame] | 878 | def addClangGCCTests(f, ignores={}, install_prefix="%(builddir)s/llvm.install", |
| 879 | languages = ('gcc', 'g++', 'objc', 'obj-c++')): |
Daniel Dunbar | 22d594a | 2010-07-31 05:29:16 +0000 | [diff] [blame] | 880 | make_vars = [WithProperties( |
Daniel Dunbar | 2b67e8f | 2011-02-11 21:03:41 +0000 | [diff] [blame] | 881 | 'CC_UNDER_TEST=%s/bin/clang' % install_prefix), |
Daniel Dunbar | 22d594a | 2010-07-31 05:29:16 +0000 | [diff] [blame] | 882 | WithProperties( |
Daniel Dunbar | 2b67e8f | 2011-02-11 21:03:41 +0000 | [diff] [blame] | 883 | 'CXX_UNDER_TEST=%s/bin/clang++' % install_prefix)] |
David Blaikie | 0551733 | 2013-12-19 23:29:12 +0000 | [diff] [blame] | 884 | f.addStep(SVN(name='svn-clang-gcc-tests', mode='update', |
Daniel Dunbar | 22d594a | 2010-07-31 05:29:16 +0000 | [diff] [blame] | 885 | baseURL='http://llvm.org/svn/llvm-project/clang-tests/', |
| 886 | defaultBranch='trunk', workdir='clang-tests')) |
| 887 | gcc_dg_ignores = ignores.get('gcc-4_2-testsuite', {}) |
Daniel Dunbar | 2b67e8f | 2011-02-11 21:03:41 +0000 | [diff] [blame] | 888 | for lang in languages: |
Michael Gottesman | a6b5be8 | 2013-06-28 21:57:20 +0000 | [diff] [blame] | 889 | f.addStep(commands.SuppressionDejaGNUCommand.SuppressionDejaGNUCommand( |
Daniel Dunbar | 22d594a | 2010-07-31 05:29:16 +0000 | [diff] [blame] | 890 | name='test-gcc-4_2-testsuite-%s' % lang, |
| 891 | command=["make", "-k", "check-%s" % lang] + make_vars, |
| 892 | description="gcc-4_2-testsuite (%s)" % lang, |
| 893 | workdir='clang-tests/gcc-4_2-testsuite', |
David Dean | 2bd0c3a | 2011-10-18 16:36:28 +0000 | [diff] [blame] | 894 | logfiles={ 'dg.sum' : 'obj/%s/%s.sum' % (lang, lang), |
| 895 | '%s.log' % lang : 'obj/%s/%s.log' % (lang, lang)}, |
Daniel Dunbar | 22d594a | 2010-07-31 05:29:16 +0000 | [diff] [blame] | 896 | ignore=gcc_dg_ignores.get(lang, []))) |
Daniel Dunbar | 2b67e8f | 2011-02-11 21:03:41 +0000 | [diff] [blame] | 897 | |
Daniel Dunbar | 7363d03 | 2011-02-27 03:22:35 +0000 | [diff] [blame] | 898 | def addClangGDBTests(f, ignores={}, install_prefix="%(builddir)s/llvm.install"): |
| 899 | make_vars = [WithProperties( |
| 900 | 'CC_UNDER_TEST=%s/bin/clang' % install_prefix), |
| 901 | WithProperties( |
| 902 | 'CXX_UNDER_TEST=%s/bin/clang++' % install_prefix)] |
David Blaikie | 0551733 | 2013-12-19 23:29:12 +0000 | [diff] [blame] | 903 | f.addStep(SVN(name='svn-clang-gdb-tests', mode='update', |
Daniel Dunbar | 7363d03 | 2011-02-27 03:22:35 +0000 | [diff] [blame] | 904 | baseURL='http://llvm.org/svn/llvm-project/clang-tests/', |
| 905 | defaultBranch='trunk', workdir='clang-tests')) |
Michael Gottesman | a6b5be8 | 2013-06-28 21:57:20 +0000 | [diff] [blame] | 906 | f.addStep(commands.SuppressionDejaGNUCommand.SuppressionDejaGNUCommand( |
Daniel Dunbar | 7363d03 | 2011-02-27 03:22:35 +0000 | [diff] [blame] | 907 | name='test-gdb-1472-testsuite', |
| 908 | command=["make", "-k", "check"] + make_vars, |
| 909 | description="gdb-1472-testsuite", |
| 910 | workdir='clang-tests/gdb-1472-testsuite', |
David Blaikie | 7ec695f | 2012-10-09 22:17:09 +0000 | [diff] [blame] | 911 | logfiles={ 'dg.sum' : 'obj/filtered.gdb.sum', |
David Blaikie | 624f439 | 2012-11-05 22:34:35 +0000 | [diff] [blame] | 912 | 'gdb.log' : 'obj/gdb.log' })) |
Daniel Dunbar | 7363d03 | 2011-02-27 03:22:35 +0000 | [diff] [blame] | 913 | |
David Blaikie | 41d09c3 | 2013-01-02 21:11:09 +0000 | [diff] [blame] | 914 | def addModernClangGDBTests(f, jobs, install_prefix): |
David Blaikie | 1bc5c37 | 2012-12-05 05:29:12 +0000 | [diff] [blame] | 915 | make_vars = [WithProperties('RUNTESTFLAGS=CC_FOR_TARGET=\'{0}/bin/clang\' ' |
| 916 | 'CXX_FOR_TARGET=\'{0}/bin/clang++\' ' |
David Blaikie | 759bb75 | 2013-04-18 23:13:11 +0000 | [diff] [blame] | 917 | 'CFLAGS_FOR_TARGET=\'-w -fno-limit-debug-info\'' |
David Blaikie | f89877b | 2013-01-29 23:46:26 +0000 | [diff] [blame] | 918 | .format(install_prefix))] |
David Blaikie | 0551733 | 2013-12-19 23:29:12 +0000 | [diff] [blame] | 919 | f.addStep(SVN(name='svn-clang-modern-gdb-tests', mode='update', |
David Blaikie | f3f300b | 2012-11-17 01:13:41 +0000 | [diff] [blame] | 920 | svnurl='http://llvm.org/svn/llvm-project/clang-tests-external/trunk/gdb/7.5', |
David Blaikie | dad03d5 | 2012-11-16 22:37:12 +0000 | [diff] [blame] | 921 | workdir='clang-tests/src')) |
David Blaikie | b83bfdf | 2012-12-05 04:33:42 +0000 | [diff] [blame] | 922 | f.addStep(Configure(command='../src/configure', |
David Blaikie | f3f300b | 2012-11-17 01:13:41 +0000 | [diff] [blame] | 923 | workdir='clang-tests/build/')) |
David Blaikie | b83bfdf | 2012-12-05 04:33:42 +0000 | [diff] [blame] | 924 | f.addStep(WarningCountingShellCommand(name='gdb-75-build', |
| 925 | command=['make', WithProperties('-j%s' % jobs)], |
| 926 | haltOnFailure=True, |
| 927 | workdir='clang-tests/build')) |
Michael Gottesman | a6b5be8 | 2013-06-28 21:57:20 +0000 | [diff] [blame] | 928 | f.addStep(commands.DejaGNUCommand.DejaGNUCommand( |
David Blaikie | dad03d5 | 2012-11-16 22:37:12 +0000 | [diff] [blame] | 929 | name='gdb-75-check', |
David Blaikie | b83bfdf | 2012-12-05 04:33:42 +0000 | [diff] [blame] | 930 | command=['make', '-k', WithProperties('-j%s' % jobs), 'check'] + make_vars, |
David Blaikie | dad03d5 | 2012-11-16 22:37:12 +0000 | [diff] [blame] | 931 | workdir='clang-tests/build', |
David Blaikie | 1bc5c37 | 2012-12-05 05:29:12 +0000 | [diff] [blame] | 932 | logfiles={'dg.sum':'gdb/testsuite/gdb.sum', |
| 933 | 'gdb.log':'gdb/testsuite/gdb.log'})) |
David Blaikie | dad03d5 | 2012-11-16 22:37:12 +0000 | [diff] [blame] | 934 | |
| 935 | |
| 936 | |
Daniel Dunbar | 7363d03 | 2011-02-27 03:22:35 +0000 | [diff] [blame] | 937 | # FIXME: Deprecated. |
| 938 | addClangTests = addClangGCCTests |
| 939 | |
Daniel Dunbar | 2b67e8f | 2011-02-11 21:03:41 +0000 | [diff] [blame] | 940 | def getClangTestsIgnoresFromPath(path, key): |
| 941 | def readList(path): |
| 942 | if not os.path.exists(path): |
| 943 | return [] |
| 944 | |
| 945 | f = open(path) |
| 946 | lines = [ln.strip() for ln in f] |
| 947 | f.close() |
| 948 | return lines |
| 949 | |
| 950 | ignores = {} |
| 951 | |
| 952 | gcc_dg_ignores = {} |
| 953 | for lang in ('gcc', 'g++', 'objc', 'obj-c++'): |
| 954 | lang_path = os.path.join(path, 'gcc-4_2-testsuite', 'expected_results', |
| 955 | key, lang) |
| 956 | gcc_dg_ignores[lang] = ( |
| 957 | readList(os.path.join(lang_path, 'FAIL.txt')) + |
| 958 | readList(os.path.join(lang_path, 'UNRESOLVED.txt')) + |
| 959 | readList(os.path.join(lang_path, 'XPASS.txt'))) |
| 960 | ignores['gcc-4_2-testsuite' ] = gcc_dg_ignores |
| 961 | |
Daniel Dunbar | 7363d03 | 2011-02-27 03:22:35 +0000 | [diff] [blame] | 962 | ignores_path = os.path.join(path, 'gdb-1472-testsuite', 'expected_results', |
| 963 | key) |
| 964 | gdb_dg_ignores = ( |
| 965 | readList(os.path.join(ignores_path, 'FAIL.txt')) + |
| 966 | readList(os.path.join(ignores_path, 'UNRESOLVED.txt')) + |
| 967 | readList(os.path.join(ignores_path, 'XPASS.txt'))) |
| 968 | ignores['gdb-1472-testsuite' ] = gdb_dg_ignores |
| 969 | |
Daniel Dunbar | 2b67e8f | 2011-02-11 21:03:41 +0000 | [diff] [blame] | 970 | return ignores |