Daniel Dunbar | 44abe74 | 2009-07-19 01:59:03 +0000 | [diff] [blame] | 1 | import os |
| 2 | |
Daniel Dunbar | 235aa41 | 2009-07-18 07:16:15 +0000 | [diff] [blame] | 3 | import buildbot |
| 4 | import buildbot.process.factory |
| 5 | from buildbot.steps.source import SVN |
Daniel Dunbar | 44abe74 | 2009-07-19 01:59:03 +0000 | [diff] [blame] | 6 | from buildbot.steps.shell import Configure, ShellCommand |
| 7 | from buildbot.steps.shell import WarningCountingShellCommand |
| 8 | from buildbot.steps.transfer import FileDownload |
Daniel Dunbar | 235aa41 | 2009-07-18 07:16:15 +0000 | [diff] [blame] | 9 | from buildbot.process.properties import WithProperties |
| 10 | |
Daniel Dunbar | 235aa41 | 2009-07-18 07:16:15 +0000 | [diff] [blame] | 11 | from zorg.buildbot.commands.ClangTestCommand import ClangTestCommand |
Daniel Dunbar | b51f6ab | 2009-11-09 03:09:23 +0000 | [diff] [blame] | 12 | from zorg.buildbot.commands.BatchFileDownload import BatchFileDownload |
Daniel Dunbar | 22d594a | 2010-07-31 05:29:16 +0000 | [diff] [blame] | 13 | from zorg.buildbot.commands import DejaGNUCommand |
Daniel Dunbar | 235aa41 | 2009-07-18 07:16:15 +0000 | [diff] [blame] | 14 | |
Daniel Dunbar | 2b67e8f | 2011-02-11 21:03:41 +0000 | [diff] [blame] | 15 | from zorg.buildbot.builders.Util import getConfigArgs |
Daniel Dunbar | 8a89a6f | 2009-11-25 04:27:32 +0000 | [diff] [blame] | 16 | |
Galina Kistanova | f4d7935 | 2011-10-20 20:46:52 +0000 | [diff] [blame] | 17 | def getClangBuildFactory( |
| 18 | triple=None, |
| 19 | clean=True, |
| 20 | test=True, |
| 21 | package_dst=None, |
| 22 | run_cxx_tests=False, |
| 23 | examples=False, |
| 24 | valgrind=False, |
| 25 | valgrindLeakCheck=False, |
| 26 | outOfDir=False, |
| 27 | useTwoStage=False, |
| 28 | completely_clean=False, |
| 29 | always_install=False, |
| 30 | make='make', |
| 31 | jobs="%(jobs)s", |
| 32 | stage1_config='Debug+Asserts', |
| 33 | stage2_config='Release+Asserts', |
| 34 | env={}, # Environmental variables for all steps. |
| 35 | extra_configure_args=[], |
| 36 | use_pty_in_tests=False, |
Peter Collingbourne | d49ac28 | 2011-10-25 14:38:45 +0000 | [diff] [blame] | 37 | trunk_revision=None, |
| 38 | force_checkout=False, |
Peter Collingbourne | 7a95b0c | 2011-10-26 16:40:17 +0000 | [diff] [blame^] | 39 | extra_clean_step=None, |
Galina Kistanova | f4d7935 | 2011-10-20 20:46:52 +0000 | [diff] [blame] | 40 | checkout_compiler_rt=False): |
| 41 | # Prepare environmental variables. Set here all env we want everywhere. |
| 42 | merged_env = { |
| 43 | 'TERM' : 'dumb' # Make sure Clang doesn't use color escape sequences. |
| 44 | } |
| 45 | if env is not None: |
| 46 | # Overwrite pre-set items with the given ones, so user can set anything. |
| 47 | merged_env.update(env) |
| 48 | |
Daniel Dunbar | 8a89a6f | 2009-11-25 04:27:32 +0000 | [diff] [blame] | 49 | # Don't use in-dir builds with a two stage build process. |
Daniel Dunbar | 3efb782 | 2010-02-26 19:20:00 +0000 | [diff] [blame] | 50 | inDir = not outOfDir and not useTwoStage |
Daniel Dunbar | 8a89a6f | 2009-11-25 04:27:32 +0000 | [diff] [blame] | 51 | if inDir: |
| 52 | llvm_srcdir = "llvm" |
| 53 | llvm_1_objdir = "llvm" |
Daniel Dunbar | 9870de3 | 2010-03-28 22:25:31 +0000 | [diff] [blame] | 54 | if always_install: |
| 55 | llvm_1_installdir = "llvm.install" |
| 56 | else: |
| 57 | llvm_1_installdir = None |
Daniel Dunbar | 8a89a6f | 2009-11-25 04:27:32 +0000 | [diff] [blame] | 58 | else: |
| 59 | llvm_srcdir = "llvm.src" |
| 60 | llvm_1_objdir = "llvm.obj" |
| 61 | llvm_1_installdir = "llvm.install.1" |
| 62 | llvm_2_objdir = "llvm.obj.2" |
Daniel Dunbar | 22d594a | 2010-07-31 05:29:16 +0000 | [diff] [blame] | 63 | llvm_2_installdir = "llvm.install" |
Daniel Dunbar | 8a89a6f | 2009-11-25 04:27:32 +0000 | [diff] [blame] | 64 | |
Daniel Dunbar | 235aa41 | 2009-07-18 07:16:15 +0000 | [diff] [blame] | 65 | f = buildbot.process.factory.BuildFactory() |
Daniel Dunbar | b51f6ab | 2009-11-09 03:09:23 +0000 | [diff] [blame] | 66 | |
| 67 | # Determine the build directory. |
| 68 | f.addStep(buildbot.steps.shell.SetProperty(name="get_builddir", |
| 69 | command=["pwd"], |
| 70 | property="builddir", |
| 71 | description="set build dir", |
Galina Kistanova | f4d7935 | 2011-10-20 20:46:52 +0000 | [diff] [blame] | 72 | workdir=".", |
| 73 | env=merged_env)) |
Daniel Dunbar | b51f6ab | 2009-11-09 03:09:23 +0000 | [diff] [blame] | 74 | |
Daniel Dunbar | 06b20f1 | 2010-04-08 18:29:38 +0000 | [diff] [blame] | 75 | # Blow away completely, if requested. |
| 76 | if completely_clean: |
| 77 | f.addStep(ShellCommand(name="rm-llvm.src", |
| 78 | command=["rm", "-rf", llvm_srcdir], |
| 79 | haltOnFailure=True, |
| 80 | description=["rm src dir", "llvm"], |
Galina Kistanova | f4d7935 | 2011-10-20 20:46:52 +0000 | [diff] [blame] | 81 | workdir=".", |
| 82 | env=merged_env)) |
Daniel Dunbar | 06b20f1 | 2010-04-08 18:29:38 +0000 | [diff] [blame] | 83 | |
Daniel Dunbar | b51f6ab | 2009-11-09 03:09:23 +0000 | [diff] [blame] | 84 | # Checkout sources. |
Peter Collingbourne | d49ac28 | 2011-10-25 14:38:45 +0000 | [diff] [blame] | 85 | if trunk_revision: |
| 86 | # The SVN build step provides no mechanism to check out a specific revision |
| 87 | # based on a property, so just run the commands directly here. |
| 88 | svn_co = ['svn', 'checkout'] |
| 89 | if force_checkout: |
| 90 | svn_co += ['--force'] |
| 91 | svn_co += ['--revision', WithProperties(trunk_revision)] |
| 92 | |
| 93 | svn_co_llvm = svn_co + \ |
| 94 | [WithProperties('http://llvm.org/svn/llvm-project/llvm/trunk@%s' % |
| 95 | trunk_revision), |
| 96 | llvm_srcdir] |
| 97 | svn_co_clang = svn_co + \ |
| 98 | [WithProperties('http://llvm.org/svn/llvm-project/cfe/trunk@%s' % |
| 99 | trunk_revision), |
| 100 | '%s/tools/clang' % llvm_srcdir] |
| 101 | |
| 102 | f.addStep(ShellCommand(name='svn-llvm', |
| 103 | command=svn_co_llvm, |
| 104 | haltOnFailure=True, |
| 105 | workdir='.')) |
| 106 | f.addStep(ShellCommand(name='svn-clang', |
| 107 | command=svn_co_clang, |
| 108 | haltOnFailure=True, |
| 109 | workdir='.')) |
| 110 | else: |
| 111 | f.addStep(SVN(name='svn-llvm', |
Daniel Dunbar | f4e23eb | 2010-09-20 21:13:02 +0000 | [diff] [blame] | 112 | mode='update', |
Peter Collingbourne | d49ac28 | 2011-10-25 14:38:45 +0000 | [diff] [blame] | 113 | baseURL='http://llvm.org/svn/llvm-project/llvm/', |
Daniel Dunbar | f4e23eb | 2010-09-20 21:13:02 +0000 | [diff] [blame] | 114 | defaultBranch='trunk', |
Peter Collingbourne | d49ac28 | 2011-10-25 14:38:45 +0000 | [diff] [blame] | 115 | workdir=llvm_srcdir)) |
| 116 | f.addStep(SVN(name='svn-clang', |
| 117 | mode='update', |
| 118 | baseURL='http://llvm.org/svn/llvm-project/cfe/', |
| 119 | defaultBranch='trunk', |
| 120 | workdir='%s/tools/clang' % llvm_srcdir)) |
| 121 | if checkout_compiler_rt: |
| 122 | f.addStep(SVN(name='svn-compiler-rt', |
| 123 | mode='update', |
| 124 | baseURL='http://llvm.org/svn/llvm-project/compiler-rt/', |
| 125 | defaultBranch='trunk', |
| 126 | workdir='%s/projects/compiler-rt' % llvm_srcdir)) |
Daniel Dunbar | fa0e022 | 2009-11-09 06:08:28 +0000 | [diff] [blame] | 127 | |
Daniel Dunbar | 8a89a6f | 2009-11-25 04:27:32 +0000 | [diff] [blame] | 128 | # Clean up llvm (stage 1); unless in-dir. |
| 129 | if clean and llvm_srcdir != llvm_1_objdir: |
| 130 | f.addStep(ShellCommand(name="rm-llvm.obj.stage1", |
| 131 | command=["rm", "-rf", llvm_1_objdir], |
| 132 | haltOnFailure=True, |
| 133 | description=["rm build dir", "llvm"], |
Galina Kistanova | f4d7935 | 2011-10-20 20:46:52 +0000 | [diff] [blame] | 134 | workdir=".", |
| 135 | env=merged_env)) |
Andrew Trick | 70fa9d2 | 2011-08-25 23:38:51 +0000 | [diff] [blame] | 136 | |
Daniel Dunbar | fa0e022 | 2009-11-09 06:08:28 +0000 | [diff] [blame] | 137 | # Force without llvm-gcc so we don't run afoul of Frontend test failures. |
Daniel Dunbar | 8a89a6f | 2009-11-25 04:27:32 +0000 | [diff] [blame] | 138 | base_configure_args = [WithProperties("%%(builddir)s/%s/configure" % llvm_srcdir), |
Daniel Dunbar | 8a89a6f | 2009-11-25 04:27:32 +0000 | [diff] [blame] | 139 | '--disable-bindings'] |
| 140 | base_configure_args += extra_configure_args |
Daniel Dunbar | fa0e022 | 2009-11-09 06:08:28 +0000 | [diff] [blame] | 141 | if triple: |
Andrew Trick | 70fa9d2 | 2011-08-25 23:38:51 +0000 | [diff] [blame] | 142 | base_configure_args += ['--build=%s' % triple, |
Daniel Dunbar | 8a89a6f | 2009-11-25 04:27:32 +0000 | [diff] [blame] | 143 | '--host=%s' % triple, |
| 144 | '--target=%s' % triple] |
| 145 | args = base_configure_args + ["--without-llvmgcc", "--without-llvmgxx"] |
Daniel Dunbar | 3efb782 | 2010-02-26 19:20:00 +0000 | [diff] [blame] | 146 | args.append(WithProperties("--prefix=%%(builddir)s/%s" % llvm_1_installdir)) |
Daniel Dunbar | 8a89a6f | 2009-11-25 04:27:32 +0000 | [diff] [blame] | 147 | args += getConfigArgs(stage1_config) |
| 148 | f.addStep(Configure(command=args, |
| 149 | workdir=llvm_1_objdir, |
| 150 | description=['configuring',stage1_config], |
Galina Kistanova | f4d7935 | 2011-10-20 20:46:52 +0000 | [diff] [blame] | 151 | descriptionDone=['configure',stage1_config], |
| 152 | env=merged_env)) |
Daniel Dunbar | 8a89a6f | 2009-11-25 04:27:32 +0000 | [diff] [blame] | 153 | |
| 154 | # Make clean if using in-dir builds. |
| 155 | if clean and llvm_srcdir == llvm_1_objdir: |
Daniel Dunbar | b51f6ab | 2009-11-09 03:09:23 +0000 | [diff] [blame] | 156 | f.addStep(WarningCountingShellCommand(name="clean-llvm", |
Daniel Dunbar | d20468a | 2009-11-24 18:27:23 +0000 | [diff] [blame] | 157 | command=[make, "clean"], |
Daniel Dunbar | b51f6ab | 2009-11-09 03:09:23 +0000 | [diff] [blame] | 158 | haltOnFailure=True, |
| 159 | description="cleaning llvm", |
| 160 | descriptionDone="clean llvm", |
Galina Kistanova | f4d7935 | 2011-10-20 20:46:52 +0000 | [diff] [blame] | 161 | workdir=llvm_1_objdir, |
Peter Collingbourne | 7a95b0c | 2011-10-26 16:40:17 +0000 | [diff] [blame^] | 162 | doStepIf=clean, |
Galina Kistanova | f4d7935 | 2011-10-20 20:46:52 +0000 | [diff] [blame] | 163 | env=merged_env)) |
Daniel Dunbar | 8a89a6f | 2009-11-25 04:27:32 +0000 | [diff] [blame] | 164 | |
Peter Collingbourne | 7a95b0c | 2011-10-26 16:40:17 +0000 | [diff] [blame^] | 165 | if extra_clean_step: |
| 166 | f.addStep(extra_clean_step) |
| 167 | |
Daniel Dunbar | 7e959c8 | 2009-09-28 04:01:19 +0000 | [diff] [blame] | 168 | f.addStep(WarningCountingShellCommand(name="compile", |
Daniel Dunbar | d20468a | 2009-11-24 18:27:23 +0000 | [diff] [blame] | 169 | command=['nice', '-n', '10', |
| 170 | make, WithProperties("-j%s" % jobs)], |
Daniel Dunbar | 7e959c8 | 2009-09-28 04:01:19 +0000 | [diff] [blame] | 171 | haltOnFailure=True, |
Daniel Dunbar | 8a89a6f | 2009-11-25 04:27:32 +0000 | [diff] [blame] | 172 | description=["compiling", stage1_config], |
| 173 | descriptionDone=["compile", stage1_config], |
Galina Kistanova | f4d7935 | 2011-10-20 20:46:52 +0000 | [diff] [blame] | 174 | workdir=llvm_1_objdir, |
| 175 | env=merged_env)) |
Daniel Dunbar | 256fed4 | 2009-11-25 21:11:08 +0000 | [diff] [blame] | 176 | |
| 177 | if examples: |
| 178 | f.addStep(WarningCountingShellCommand(name="compile.examples", |
| 179 | command=['nice', '-n', '10', |
| 180 | make, WithProperties("-j%s" % jobs), |
| 181 | "BUILD_EXAMPLES=1"], |
| 182 | haltOnFailure=True, |
| 183 | description=["compilinge", stage1_config, "examples"], |
| 184 | descriptionDone=["compile", stage1_config, "examples"], |
Galina Kistanova | f4d7935 | 2011-10-20 20:46:52 +0000 | [diff] [blame] | 185 | workdir=llvm_1_objdir, |
| 186 | env=merged_env)) |
Daniel Dunbar | 256fed4 | 2009-11-25 21:11:08 +0000 | [diff] [blame] | 187 | |
Daniel Dunbar | 93f828a | 2010-06-23 17:42:14 +0000 | [diff] [blame] | 188 | clangTestArgs = llvmTestArgs = '-v -j %s' % jobs |
Daniel Dunbar | fa0e022 | 2009-11-09 06:08:28 +0000 | [diff] [blame] | 189 | if valgrind: |
Daniel Dunbar | 89184b9 | 2010-04-18 19:09:32 +0000 | [diff] [blame] | 190 | clangTestArgs += ' --vg' |
Daniel Dunbar | a1bebce | 2010-03-21 01:24:00 +0000 | [diff] [blame] | 191 | if valgrindLeakCheck: |
| 192 | clangTestArgs += ' --vg-leak' |
Nick Lewycky | 8d26e47 | 2011-08-27 21:18:56 +0000 | [diff] [blame] | 193 | 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] | 194 | extraTestDirs = '' |
| 195 | if run_cxx_tests: |
| 196 | extraTestDirs += '%(builddir)s/llvm/tools/clang/utils/C++Tests' |
Daniel Dunbar | b51f6ab | 2009-11-09 03:09:23 +0000 | [diff] [blame] | 197 | if test: |
| 198 | f.addStep(ClangTestCommand(name='test-llvm', |
Daniel Dunbar | 93f828a | 2010-06-23 17:42:14 +0000 | [diff] [blame] | 199 | command=[make, "check-lit", "VERBOSE=1", |
| 200 | WithProperties("LIT_ARGS=%s" % llvmTestArgs)], |
Daniel Dunbar | b51f6ab | 2009-11-09 03:09:23 +0000 | [diff] [blame] | 201 | description=["testing", "llvm"], |
| 202 | descriptionDone=["test", "llvm"], |
Daniel Dunbar | 469e8ca | 2010-05-19 21:26:48 +0000 | [diff] [blame] | 203 | workdir=llvm_1_objdir, |
Galina Kistanova | f4d7935 | 2011-10-20 20:46:52 +0000 | [diff] [blame] | 204 | usePTY=use_pty_in_tests, |
| 205 | env=merged_env)) |
Daniel Dunbar | 44abe74 | 2009-07-19 01:59:03 +0000 | [diff] [blame] | 206 | f.addStep(ClangTestCommand(name='test-clang', |
Daniel Dunbar | d20468a | 2009-11-24 18:27:23 +0000 | [diff] [blame] | 207 | command=[make, 'test', WithProperties('TESTARGS=%s' % clangTestArgs), |
Daniel Dunbar | fa0e022 | 2009-11-09 06:08:28 +0000 | [diff] [blame] | 208 | WithProperties('EXTRA_TESTDIRS=%s' % extraTestDirs)], |
Daniel Dunbar | 469e8ca | 2010-05-19 21:26:48 +0000 | [diff] [blame] | 209 | workdir='%s/tools/clang' % llvm_1_objdir, |
Galina Kistanova | f4d7935 | 2011-10-20 20:46:52 +0000 | [diff] [blame] | 210 | usePTY=use_pty_in_tests, |
| 211 | env=merged_env)) |
Daniel Dunbar | 8a89a6f | 2009-11-25 04:27:32 +0000 | [diff] [blame] | 212 | |
| 213 | # Install llvm and clang. |
| 214 | if llvm_1_installdir: |
Daniel Dunbar | 9870de3 | 2010-03-28 22:25:31 +0000 | [diff] [blame] | 215 | f.addStep(ShellCommand(name="rm-install.clang.stage1", |
| 216 | command=["rm", "-rf", llvm_1_installdir], |
| 217 | haltOnFailure=True, |
| 218 | description=["rm install dir", "clang"], |
Galina Kistanova | f4d7935 | 2011-10-20 20:46:52 +0000 | [diff] [blame] | 219 | workdir=".", |
| 220 | env=merged_env)) |
Daniel Dunbar | 9870de3 | 2010-03-28 22:25:31 +0000 | [diff] [blame] | 221 | f.addStep(WarningCountingShellCommand(name="install.clang.stage1", |
| 222 | command = ['nice', '-n', '10', |
| 223 | make, 'install-clang'], |
Daniel Dunbar | 8a89a6f | 2009-11-25 04:27:32 +0000 | [diff] [blame] | 224 | haltOnFailure=True, |
Daniel Dunbar | 9870de3 | 2010-03-28 22:25:31 +0000 | [diff] [blame] | 225 | description=["install", "clang", |
| 226 | stage1_config], |
Galina Kistanova | f4d7935 | 2011-10-20 20:46:52 +0000 | [diff] [blame] | 227 | workdir=llvm_1_objdir, |
| 228 | env=merged_env)) |
Daniel Dunbar | 8a89a6f | 2009-11-25 04:27:32 +0000 | [diff] [blame] | 229 | |
| 230 | if not useTwoStage: |
Daniel Dunbar | dedf657 | 2010-11-13 00:23:34 +0000 | [diff] [blame] | 231 | if package_dst: |
| 232 | name = WithProperties( |
| 233 | "%(builddir)s/" + llvm_1_objdir + |
| 234 | "/clang-r%(got_revision)s-b%(buildnumber)s.tgz") |
| 235 | f.addStep(ShellCommand(name='pkg.tar', |
| 236 | description="tar root", |
| 237 | command=["tar", "zcvf", name, "./"], |
| 238 | workdir=llvm_1_installdir, |
| 239 | warnOnFailure=True, |
| 240 | flunkOnFailure=False, |
Galina Kistanova | f4d7935 | 2011-10-20 20:46:52 +0000 | [diff] [blame] | 241 | haltOnFailure=False, |
| 242 | env=merged_env)) |
Daniel Dunbar | dedf657 | 2010-11-13 00:23:34 +0000 | [diff] [blame] | 243 | f.addStep(ShellCommand(name='pkg.upload', |
Andrew Trick | 70fa9d2 | 2011-08-25 23:38:51 +0000 | [diff] [blame] | 244 | description="upload root", |
Daniel Dunbar | dedf657 | 2010-11-13 00:23:34 +0000 | [diff] [blame] | 245 | command=["scp", name, |
| 246 | WithProperties( |
| 247 | package_dst + "/%(buildername)s")], |
| 248 | workdir=".", |
| 249 | warnOnFailure=True, |
| 250 | flunkOnFailure=False, |
Galina Kistanova | f4d7935 | 2011-10-20 20:46:52 +0000 | [diff] [blame] | 251 | haltOnFailure=False, |
| 252 | env=merged_env)) |
Daniel Dunbar | dedf657 | 2010-11-13 00:23:34 +0000 | [diff] [blame] | 253 | |
Daniel Dunbar | 8a89a6f | 2009-11-25 04:27:32 +0000 | [diff] [blame] | 254 | return f |
| 255 | |
| 256 | # Clean up llvm (stage 2). |
| 257 | if clean: |
| 258 | f.addStep(ShellCommand(name="rm-llvm.obj.stage2", |
| 259 | command=["rm", "-rf", llvm_2_objdir], |
| 260 | haltOnFailure=True, |
| 261 | description=["rm build dir", "llvm", "(stage 2)"], |
Galina Kistanova | f4d7935 | 2011-10-20 20:46:52 +0000 | [diff] [blame] | 262 | workdir=".", |
| 263 | env=merged_env)) |
Daniel Dunbar | 8a89a6f | 2009-11-25 04:27:32 +0000 | [diff] [blame] | 264 | |
| 265 | # Configure llvm (stage 2). |
| 266 | args = base_configure_args + ["--without-llvmgcc", "--without-llvmgxx"] |
Daniel Dunbar | 3efb782 | 2010-02-26 19:20:00 +0000 | [diff] [blame] | 267 | args.append(WithProperties("--prefix=%(builddir)s/" + llvm_2_installdir)) |
Daniel Dunbar | 8a89a6f | 2009-11-25 04:27:32 +0000 | [diff] [blame] | 268 | args += getConfigArgs(stage2_config) |
Galina Kistanova | f4d7935 | 2011-10-20 20:46:52 +0000 | [diff] [blame] | 269 | local_env = dict(merged_env).update({ |
| 270 | 'CC' : WithProperties("%%(builddir)s/%s/bin/clang" % llvm_1_installdir), |
| 271 | 'CXX' : WithProperties("%%(builddir)s/%s/bin/clang++" % llvm_1_installdir)}) |
| 272 | |
Daniel Dunbar | 8a89a6f | 2009-11-25 04:27:32 +0000 | [diff] [blame] | 273 | f.addStep(Configure(name="configure.llvm.stage2", |
| 274 | command=args, |
Daniel Dunbar | 8a89a6f | 2009-11-25 04:27:32 +0000 | [diff] [blame] | 275 | haltOnFailure=True, |
| 276 | workdir=llvm_2_objdir, |
| 277 | description=["configure", "llvm", "(stage 2)", |
Galina Kistanova | f4d7935 | 2011-10-20 20:46:52 +0000 | [diff] [blame] | 278 | stage2_config], |
| 279 | env=local_env)) |
Daniel Dunbar | 8a89a6f | 2009-11-25 04:27:32 +0000 | [diff] [blame] | 280 | |
| 281 | # Build llvm (stage 2). |
| 282 | f.addStep(WarningCountingShellCommand(name="compile.llvm.stage2", |
| 283 | command=['nice', '-n', '10', |
| 284 | make, WithProperties("-j%s" % jobs)], |
| 285 | haltOnFailure=True, |
| 286 | description=["compiling", "(stage 2)", |
| 287 | stage2_config], |
| 288 | descriptionDone=["compile", "(stage 2)", |
| 289 | stage2_config], |
Galina Kistanova | f4d7935 | 2011-10-20 20:46:52 +0000 | [diff] [blame] | 290 | workdir=llvm_2_objdir, |
| 291 | env=merged_env)) |
Daniel Dunbar | 8a89a6f | 2009-11-25 04:27:32 +0000 | [diff] [blame] | 292 | |
| 293 | if test: |
| 294 | f.addStep(ClangTestCommand(name='test-llvm', |
Daniel Dunbar | 93f828a | 2010-06-23 17:42:14 +0000 | [diff] [blame] | 295 | command=[make, "check-lit", "VERBOSE=1", |
| 296 | WithProperties("LIT_ARGS=%s" % llvmTestArgs)], |
Daniel Dunbar | 8a89a6f | 2009-11-25 04:27:32 +0000 | [diff] [blame] | 297 | description=["testing", "llvm"], |
| 298 | descriptionDone=["test", "llvm"], |
Daniel Dunbar | 469e8ca | 2010-05-19 21:26:48 +0000 | [diff] [blame] | 299 | workdir=llvm_2_objdir, |
Galina Kistanova | f4d7935 | 2011-10-20 20:46:52 +0000 | [diff] [blame] | 300 | usePTY=use_pty_in_tests, |
| 301 | env=merged_env)) |
Daniel Dunbar | 8a89a6f | 2009-11-25 04:27:32 +0000 | [diff] [blame] | 302 | f.addStep(ClangTestCommand(name='test-clang', |
| 303 | command=[make, 'test', WithProperties('TESTARGS=%s' % clangTestArgs), |
| 304 | WithProperties('EXTRA_TESTDIRS=%s' % extraTestDirs)], |
Daniel Dunbar | 469e8ca | 2010-05-19 21:26:48 +0000 | [diff] [blame] | 305 | workdir='%s/tools/clang' % llvm_2_objdir, |
Galina Kistanova | f4d7935 | 2011-10-20 20:46:52 +0000 | [diff] [blame] | 306 | usePTY=use_pty_in_tests, |
| 307 | env=merged_env)) |
Daniel Dunbar | 8a89a6f | 2009-11-25 04:27:32 +0000 | [diff] [blame] | 308 | |
Daniel Dunbar | 3efb782 | 2010-02-26 19:20:00 +0000 | [diff] [blame] | 309 | # Install clang (stage 2). |
Daniel Dunbar | 9870de3 | 2010-03-28 22:25:31 +0000 | [diff] [blame] | 310 | f.addStep(ShellCommand(name="rm-install.clang.stage2", |
| 311 | command=["rm", "-rf", llvm_2_installdir], |
| 312 | haltOnFailure=True, |
| 313 | description=["rm install dir", "clang"], |
Galina Kistanova | f4d7935 | 2011-10-20 20:46:52 +0000 | [diff] [blame] | 314 | workdir=".", |
| 315 | env=merged_env)) |
Daniel Dunbar | 3efb782 | 2010-02-26 19:20:00 +0000 | [diff] [blame] | 316 | f.addStep(WarningCountingShellCommand(name="install.clang.stage2", |
| 317 | command = ['nice', '-n', '10', |
| 318 | make, 'install-clang'], |
| 319 | haltOnFailure=True, |
| 320 | description=["install", "clang", |
| 321 | "(stage 2)"], |
Galina Kistanova | f4d7935 | 2011-10-20 20:46:52 +0000 | [diff] [blame] | 322 | workdir=llvm_2_objdir, |
| 323 | env=merged_env)) |
Daniel Dunbar | 3efb782 | 2010-02-26 19:20:00 +0000 | [diff] [blame] | 324 | |
| 325 | if package_dst: |
| 326 | name = WithProperties( |
| 327 | "%(builddir)s/" + llvm_2_objdir + |
| 328 | "/clang-r%(got_revision)s-b%(buildnumber)s.tgz") |
| 329 | f.addStep(ShellCommand(name='pkg.tar', |
| 330 | description="tar root", |
| 331 | command=["tar", "zcvf", name, "./"], |
| 332 | workdir=llvm_2_installdir, |
| 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 | f.addStep(ShellCommand(name='pkg.upload', |
Andrew Trick | 70fa9d2 | 2011-08-25 23:38:51 +0000 | [diff] [blame] | 338 | description="upload root", |
Daniel Dunbar | 3efb782 | 2010-02-26 19:20:00 +0000 | [diff] [blame] | 339 | command=["scp", name, |
| 340 | WithProperties( |
| 341 | package_dst + "/%(buildername)s")], |
| 342 | workdir=".", |
| 343 | warnOnFailure=True, |
| 344 | flunkOnFailure=False, |
Galina Kistanova | f4d7935 | 2011-10-20 20:46:52 +0000 | [diff] [blame] | 345 | haltOnFailure=False, |
| 346 | env=merged_env)) |
Daniel Dunbar | 3efb782 | 2010-02-26 19:20:00 +0000 | [diff] [blame] | 347 | |
Daniel Dunbar | 235aa41 | 2009-07-18 07:16:15 +0000 | [diff] [blame] | 348 | return f |
Daniel Dunbar | 44abe74 | 2009-07-19 01:59:03 +0000 | [diff] [blame] | 349 | |
Daniel Dunbar | c51a59e | 2010-09-23 14:57:45 +0000 | [diff] [blame] | 350 | def getClangMSVCBuildFactory(update=True, clean=True, vcDrive='c', jobs=1, cmake=r"cmake"): |
Daniel Dunbar | 44abe74 | 2009-07-19 01:59:03 +0000 | [diff] [blame] | 351 | f = buildbot.process.factory.BuildFactory() |
| 352 | |
Daniel Dunbar | b51f6ab | 2009-11-09 03:09:23 +0000 | [diff] [blame] | 353 | if update: |
Daniel Dunbar | 44abe74 | 2009-07-19 01:59:03 +0000 | [diff] [blame] | 354 | f.addStep(SVN(name='svn-llvm', |
| 355 | mode='update', baseURL='http://llvm.org/svn/llvm-project/llvm/', |
| 356 | defaultBranch='trunk', |
| 357 | workdir='llvm')) |
| 358 | |
Daniel Dunbar | b51f6ab | 2009-11-09 03:09:23 +0000 | [diff] [blame] | 359 | if update: |
Daniel Dunbar | 44abe74 | 2009-07-19 01:59:03 +0000 | [diff] [blame] | 360 | f.addStep(SVN(name='svn-clang', |
Daniel Dunbar | 7e959c8 | 2009-09-28 04:01:19 +0000 | [diff] [blame] | 361 | mode='update', baseURL='http://llvm.org/svn/llvm-project/cfe/', |
Daniel Dunbar | 44abe74 | 2009-07-19 01:59:03 +0000 | [diff] [blame] | 362 | defaultBranch='trunk', |
| 363 | workdir='llvm/tools/clang')) |
| 364 | |
| 365 | # Full & fast clean. |
Daniel Dunbar | b51f6ab | 2009-11-09 03:09:23 +0000 | [diff] [blame] | 366 | if clean: |
Daniel Dunbar | 44abe74 | 2009-07-19 01:59:03 +0000 | [diff] [blame] | 367 | f.addStep(ShellCommand(name='clean-1', |
| 368 | command=['del','/s/q','build'], |
Daniel Dunbar | 7e959c8 | 2009-09-28 04:01:19 +0000 | [diff] [blame] | 369 | warnOnFailure=True, |
Daniel Dunbar | 44abe74 | 2009-07-19 01:59:03 +0000 | [diff] [blame] | 370 | description='cleaning', |
| 371 | descriptionDone='clean', |
| 372 | workdir='llvm')) |
| 373 | f.addStep(ShellCommand(name='clean-2', |
| 374 | command=['rmdir','/s/q','build'], |
Daniel Dunbar | 7e959c8 | 2009-09-28 04:01:19 +0000 | [diff] [blame] | 375 | warnOnFailure=True, |
Daniel Dunbar | 44abe74 | 2009-07-19 01:59:03 +0000 | [diff] [blame] | 376 | description='cleaning', |
| 377 | descriptionDone='clean', |
| 378 | workdir='llvm')) |
| 379 | |
| 380 | # Create the project files. |
Daniel Dunbar | 7e959c8 | 2009-09-28 04:01:19 +0000 | [diff] [blame] | 381 | |
Daniel Dunbar | b51f6ab | 2009-11-09 03:09:23 +0000 | [diff] [blame] | 382 | # Use batch files instead of ShellCommand directly, Windows quoting is |
| 383 | # borked. FIXME: See buildbot ticket #595 and buildbot ticket #377. |
| 384 | f.addStep(BatchFileDownload(name='cmakegen', |
Daniel Dunbar | 06b20f1 | 2010-04-08 18:29:38 +0000 | [diff] [blame] | 385 | command=[cmake, |
Daniel Dunbar | b51f6ab | 2009-11-09 03:09:23 +0000 | [diff] [blame] | 386 | "-DLLVM_TARGETS_TO_BUILD:=X86", |
Daniel Dunbar | 1ddedce | 2010-09-24 19:57:34 +0000 | [diff] [blame] | 387 | "-DLLVM_INCLUDE_EXAMPLES:=OFF", |
| 388 | "-DLLVM_INCLUDE_TESTS:=OFF", |
| 389 | "-DLLVM_TARGETS_TO_BUILD:=X86", |
Daniel Dunbar | b51f6ab | 2009-11-09 03:09:23 +0000 | [diff] [blame] | 390 | "-G", |
| 391 | "Visual Studio 9 2008", |
| 392 | ".."], |
| 393 | workdir="llvm\\build")) |
Daniel Dunbar | 44abe74 | 2009-07-19 01:59:03 +0000 | [diff] [blame] | 394 | f.addStep(ShellCommand(name='cmake', |
| 395 | command=['cmakegen.bat'], |
Daniel Dunbar | 7e959c8 | 2009-09-28 04:01:19 +0000 | [diff] [blame] | 396 | haltOnFailure=True, |
Daniel Dunbar | 44abe74 | 2009-07-19 01:59:03 +0000 | [diff] [blame] | 397 | description='cmake gen', |
| 398 | workdir='llvm\\build')) |
| 399 | |
| 400 | # Build it. |
Daniel Dunbar | b51f6ab | 2009-11-09 03:09:23 +0000 | [diff] [blame] | 401 | f.addStep(BatchFileDownload(name='vcbuild', |
| 402 | command=[vcDrive + r""":\Program Files\Microsoft Visual Studio 9.0\VC\VCPackages\vcbuild.exe""", |
| 403 | "/M%d" % jobs, |
| 404 | "LLVM.sln", |
| 405 | "Debug|Win32"], |
| 406 | workdir="llvm\\build")) |
Daniel Dunbar | 44abe74 | 2009-07-19 01:59:03 +0000 | [diff] [blame] | 407 | f.addStep(WarningCountingShellCommand(name='vcbuild', |
| 408 | command=['vcbuild.bat'], |
Daniel Dunbar | 7e959c8 | 2009-09-28 04:01:19 +0000 | [diff] [blame] | 409 | haltOnFailure=True, |
Daniel Dunbar | 44abe74 | 2009-07-19 01:59:03 +0000 | [diff] [blame] | 410 | description='vcbuild', |
| 411 | workdir='llvm\\build', |
| 412 | warningPattern=" warning C.*:")) |
Daniel Dunbar | b51f6ab | 2009-11-09 03:09:23 +0000 | [diff] [blame] | 413 | |
| 414 | # Build clang-test project. |
| 415 | f.addStep(BatchFileDownload(name='vcbuild_test', |
| 416 | command=[vcDrive + r""":\Program Files\Microsoft Visual Studio 9.0\VC\VCPackages\vcbuild.exe""", |
| 417 | "clang-test.vcproj", |
| 418 | "Debug|Win32"], |
| 419 | workdir="llvm\\build\\tools\\clang\\test")) |
| 420 | f.addStep(ClangTestCommand(name='test-clang', |
| 421 | command=["vcbuild_test.bat"], |
| 422 | workdir="llvm\\build\\tools\\clang\\test")) |
| 423 | |
Daniel Dunbar | 44abe74 | 2009-07-19 01:59:03 +0000 | [diff] [blame] | 424 | return f |
Daniel Dunbar | 22d594a | 2010-07-31 05:29:16 +0000 | [diff] [blame] | 425 | |
Daniel Dunbar | 7363d03 | 2011-02-27 03:22:35 +0000 | [diff] [blame] | 426 | def addClangGCCTests(f, ignores={}, install_prefix="%(builddir)s/llvm.install", |
| 427 | languages = ('gcc', 'g++', 'objc', 'obj-c++')): |
Daniel Dunbar | 22d594a | 2010-07-31 05:29:16 +0000 | [diff] [blame] | 428 | make_vars = [WithProperties( |
Daniel Dunbar | 2b67e8f | 2011-02-11 21:03:41 +0000 | [diff] [blame] | 429 | 'CC_UNDER_TEST=%s/bin/clang' % install_prefix), |
Daniel Dunbar | 22d594a | 2010-07-31 05:29:16 +0000 | [diff] [blame] | 430 | WithProperties( |
Daniel Dunbar | 2b67e8f | 2011-02-11 21:03:41 +0000 | [diff] [blame] | 431 | 'CXX_UNDER_TEST=%s/bin/clang++' % install_prefix)] |
Daniel Dunbar | 22d594a | 2010-07-31 05:29:16 +0000 | [diff] [blame] | 432 | f.addStep(SVN(name='svn-clang-tests', mode='update', |
| 433 | baseURL='http://llvm.org/svn/llvm-project/clang-tests/', |
| 434 | defaultBranch='trunk', workdir='clang-tests')) |
| 435 | gcc_dg_ignores = ignores.get('gcc-4_2-testsuite', {}) |
Daniel Dunbar | 2b67e8f | 2011-02-11 21:03:41 +0000 | [diff] [blame] | 436 | for lang in languages: |
Daniel Dunbar | 22d594a | 2010-07-31 05:29:16 +0000 | [diff] [blame] | 437 | f.addStep(DejaGNUCommand.DejaGNUCommand( |
| 438 | name='test-gcc-4_2-testsuite-%s' % lang, |
| 439 | command=["make", "-k", "check-%s" % lang] + make_vars, |
| 440 | description="gcc-4_2-testsuite (%s)" % lang, |
| 441 | workdir='clang-tests/gcc-4_2-testsuite', |
David Dean | 2bd0c3a | 2011-10-18 16:36:28 +0000 | [diff] [blame] | 442 | logfiles={ 'dg.sum' : 'obj/%s/%s.sum' % (lang, lang), |
| 443 | '%s.log' % lang : 'obj/%s/%s.log' % (lang, lang)}, |
Daniel Dunbar | 22d594a | 2010-07-31 05:29:16 +0000 | [diff] [blame] | 444 | ignore=gcc_dg_ignores.get(lang, []))) |
Daniel Dunbar | 2b67e8f | 2011-02-11 21:03:41 +0000 | [diff] [blame] | 445 | |
Daniel Dunbar | 7363d03 | 2011-02-27 03:22:35 +0000 | [diff] [blame] | 446 | def addClangGDBTests(f, ignores={}, install_prefix="%(builddir)s/llvm.install"): |
| 447 | make_vars = [WithProperties( |
| 448 | 'CC_UNDER_TEST=%s/bin/clang' % install_prefix), |
| 449 | WithProperties( |
| 450 | 'CXX_UNDER_TEST=%s/bin/clang++' % install_prefix)] |
| 451 | f.addStep(SVN(name='svn-clang-tests', mode='update', |
| 452 | baseURL='http://llvm.org/svn/llvm-project/clang-tests/', |
| 453 | defaultBranch='trunk', workdir='clang-tests')) |
| 454 | gdb_dg_ignores = ignores.get('gdb-1472-testsuite', {}) |
| 455 | f.addStep(DejaGNUCommand.DejaGNUCommand( |
| 456 | name='test-gdb-1472-testsuite', |
| 457 | command=["make", "-k", "check"] + make_vars, |
| 458 | description="gdb-1472-testsuite", |
| 459 | workdir='clang-tests/gdb-1472-testsuite', |
| 460 | logfiles={ 'dg.sum' : 'obj/gdb.sum' }, |
| 461 | ignore=gdb_dg_ignores)) |
| 462 | |
| 463 | # FIXME: Deprecated. |
| 464 | addClangTests = addClangGCCTests |
| 465 | |
Daniel Dunbar | 2b67e8f | 2011-02-11 21:03:41 +0000 | [diff] [blame] | 466 | def getClangTestsIgnoresFromPath(path, key): |
| 467 | def readList(path): |
| 468 | if not os.path.exists(path): |
| 469 | return [] |
| 470 | |
| 471 | f = open(path) |
| 472 | lines = [ln.strip() for ln in f] |
| 473 | f.close() |
| 474 | return lines |
| 475 | |
| 476 | ignores = {} |
| 477 | |
| 478 | gcc_dg_ignores = {} |
| 479 | for lang in ('gcc', 'g++', 'objc', 'obj-c++'): |
| 480 | lang_path = os.path.join(path, 'gcc-4_2-testsuite', 'expected_results', |
| 481 | key, lang) |
| 482 | gcc_dg_ignores[lang] = ( |
| 483 | readList(os.path.join(lang_path, 'FAIL.txt')) + |
| 484 | readList(os.path.join(lang_path, 'UNRESOLVED.txt')) + |
| 485 | readList(os.path.join(lang_path, 'XPASS.txt'))) |
| 486 | ignores['gcc-4_2-testsuite' ] = gcc_dg_ignores |
| 487 | |
Daniel Dunbar | 7363d03 | 2011-02-27 03:22:35 +0000 | [diff] [blame] | 488 | ignores_path = os.path.join(path, 'gdb-1472-testsuite', 'expected_results', |
| 489 | key) |
| 490 | gdb_dg_ignores = ( |
| 491 | readList(os.path.join(ignores_path, 'FAIL.txt')) + |
| 492 | readList(os.path.join(ignores_path, 'UNRESOLVED.txt')) + |
| 493 | readList(os.path.join(ignores_path, 'XPASS.txt'))) |
| 494 | ignores['gdb-1472-testsuite' ] = gdb_dg_ignores |
| 495 | |
Daniel Dunbar | 2b67e8f | 2011-02-11 21:03:41 +0000 | [diff] [blame] | 496 | return ignores |