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 | 235aa41 | 2009-07-18 07:16:15 +0000 | [diff] [blame] | 13 | |
Daniel Dunbar | 8a89a6f | 2009-11-25 04:27:32 +0000 | [diff] [blame^] | 14 | from Util import getConfigArgs |
| 15 | |
| 16 | def getClangBuildFactory(triple=None, clean=True, test=True, run_cxx_tests=False, |
| 17 | valgrind=False, useTwoStage=False, |
| 18 | make='make', jobs="%(jobs)s", |
| 19 | stage1_config='Debug', stage2_config='Release', |
| 20 | extra_configure_args=[]): |
| 21 | # Don't use in-dir builds with a two stage build process. |
| 22 | inDir = not useTwoStage |
| 23 | if inDir: |
| 24 | llvm_srcdir = "llvm" |
| 25 | llvm_1_objdir = "llvm" |
| 26 | llvm_1_installdir = None |
| 27 | else: |
| 28 | llvm_srcdir = "llvm.src" |
| 29 | llvm_1_objdir = "llvm.obj" |
| 30 | llvm_1_installdir = "llvm.install.1" |
| 31 | llvm_2_objdir = "llvm.obj.2" |
| 32 | |
Daniel Dunbar | 235aa41 | 2009-07-18 07:16:15 +0000 | [diff] [blame] | 33 | f = buildbot.process.factory.BuildFactory() |
Daniel Dunbar | b51f6ab | 2009-11-09 03:09:23 +0000 | [diff] [blame] | 34 | |
| 35 | # Determine the build directory. |
| 36 | f.addStep(buildbot.steps.shell.SetProperty(name="get_builddir", |
| 37 | command=["pwd"], |
| 38 | property="builddir", |
| 39 | description="set build dir", |
| 40 | workdir=".")) |
| 41 | |
| 42 | # Checkout sources. |
Daniel Dunbar | 235aa41 | 2009-07-18 07:16:15 +0000 | [diff] [blame] | 43 | f.addStep(SVN(name='svn-llvm', |
| 44 | mode='update', baseURL='http://llvm.org/svn/llvm-project/llvm/', |
| 45 | defaultBranch='trunk', |
Daniel Dunbar | 8a89a6f | 2009-11-25 04:27:32 +0000 | [diff] [blame^] | 46 | workdir=llvm_srcdir)) |
Daniel Dunbar | 235aa41 | 2009-07-18 07:16:15 +0000 | [diff] [blame] | 47 | f.addStep(SVN(name='svn-clang', |
Daniel Dunbar | 7e959c8 | 2009-09-28 04:01:19 +0000 | [diff] [blame] | 48 | mode='update', baseURL='http://llvm.org/svn/llvm-project/cfe/', |
Daniel Dunbar | 235aa41 | 2009-07-18 07:16:15 +0000 | [diff] [blame] | 49 | defaultBranch='trunk', |
Daniel Dunbar | 8a89a6f | 2009-11-25 04:27:32 +0000 | [diff] [blame^] | 50 | workdir='%s/tools/clang' % llvm_srcdir)) |
Daniel Dunbar | fa0e022 | 2009-11-09 06:08:28 +0000 | [diff] [blame] | 51 | |
Daniel Dunbar | 8a89a6f | 2009-11-25 04:27:32 +0000 | [diff] [blame^] | 52 | # Clean up llvm (stage 1); unless in-dir. |
| 53 | if clean and llvm_srcdir != llvm_1_objdir: |
| 54 | f.addStep(ShellCommand(name="rm-llvm.obj.stage1", |
| 55 | command=["rm", "-rf", llvm_1_objdir], |
| 56 | haltOnFailure=True, |
| 57 | description=["rm build dir", "llvm"], |
| 58 | workdir=".")) |
| 59 | |
Daniel Dunbar | fa0e022 | 2009-11-09 06:08:28 +0000 | [diff] [blame] | 60 | # 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^] | 61 | base_configure_args = [WithProperties("%%(builddir)s/%s/configure" % llvm_srcdir), |
| 62 | WithProperties("--prefix=%%(builddir)s/%s" % llvm_1_installdir), |
| 63 | '--disable-bindings'] |
| 64 | base_configure_args += extra_configure_args |
Daniel Dunbar | fa0e022 | 2009-11-09 06:08:28 +0000 | [diff] [blame] | 65 | if triple: |
Daniel Dunbar | 8a89a6f | 2009-11-25 04:27:32 +0000 | [diff] [blame^] | 66 | base_configure_args += ['--build=%s' % triple, |
| 67 | '--host=%s' % triple, |
| 68 | '--target=%s' % triple] |
| 69 | args = base_configure_args + ["--without-llvmgcc", "--without-llvmgxx"] |
| 70 | args += getConfigArgs(stage1_config) |
| 71 | f.addStep(Configure(command=args, |
| 72 | workdir=llvm_1_objdir, |
| 73 | description=['configuring',stage1_config], |
| 74 | descriptionDone=['configure',stage1_config])) |
| 75 | |
| 76 | # Make clean if using in-dir builds. |
| 77 | if clean and llvm_srcdir == llvm_1_objdir: |
Daniel Dunbar | b51f6ab | 2009-11-09 03:09:23 +0000 | [diff] [blame] | 78 | f.addStep(WarningCountingShellCommand(name="clean-llvm", |
Daniel Dunbar | d20468a | 2009-11-24 18:27:23 +0000 | [diff] [blame] | 79 | command=[make, "clean"], |
Daniel Dunbar | b51f6ab | 2009-11-09 03:09:23 +0000 | [diff] [blame] | 80 | haltOnFailure=True, |
| 81 | description="cleaning llvm", |
| 82 | descriptionDone="clean llvm", |
Daniel Dunbar | 8a89a6f | 2009-11-25 04:27:32 +0000 | [diff] [blame^] | 83 | workdir=llvm_1_objdir)) |
| 84 | |
Daniel Dunbar | 7e959c8 | 2009-09-28 04:01:19 +0000 | [diff] [blame] | 85 | f.addStep(WarningCountingShellCommand(name="compile", |
Daniel Dunbar | d20468a | 2009-11-24 18:27:23 +0000 | [diff] [blame] | 86 | command=['nice', '-n', '10', |
| 87 | make, WithProperties("-j%s" % jobs)], |
Daniel Dunbar | 7e959c8 | 2009-09-28 04:01:19 +0000 | [diff] [blame] | 88 | haltOnFailure=True, |
Daniel Dunbar | 8a89a6f | 2009-11-25 04:27:32 +0000 | [diff] [blame^] | 89 | description=["compiling", stage1_config], |
| 90 | descriptionDone=["compile", stage1_config], |
| 91 | workdir=llvm_1_objdir)) |
Daniel Dunbar | fa0e022 | 2009-11-09 06:08:28 +0000 | [diff] [blame] | 92 | clangTestArgs = '-v' |
| 93 | if valgrind: |
| 94 | clangTestArgs += ' --vg ' |
| 95 | clangTestArgs += ' --vg-arg --leak-check=no' |
| 96 | clangTestArgs += ' --vg-arg --suppressions=%(builddir)s/llvm/tools/clang/utils/valgrind/x86_64-pc-linux-gnu_gcc-4.3.3.supp' |
| 97 | extraTestDirs = '' |
| 98 | if run_cxx_tests: |
| 99 | extraTestDirs += '%(builddir)s/llvm/tools/clang/utils/C++Tests' |
Daniel Dunbar | b51f6ab | 2009-11-09 03:09:23 +0000 | [diff] [blame] | 100 | if test: |
| 101 | f.addStep(ClangTestCommand(name='test-llvm', |
Daniel Dunbar | d20468a | 2009-11-24 18:27:23 +0000 | [diff] [blame] | 102 | command=[make, "check-lit", "VERBOSE=1"], |
Daniel Dunbar | b51f6ab | 2009-11-09 03:09:23 +0000 | [diff] [blame] | 103 | description=["testing", "llvm"], |
| 104 | descriptionDone=["test", "llvm"], |
Daniel Dunbar | 8a89a6f | 2009-11-25 04:27:32 +0000 | [diff] [blame^] | 105 | workdir=llvm_1_objdir)) |
Daniel Dunbar | 44abe74 | 2009-07-19 01:59:03 +0000 | [diff] [blame] | 106 | f.addStep(ClangTestCommand(name='test-clang', |
Daniel Dunbar | d20468a | 2009-11-24 18:27:23 +0000 | [diff] [blame] | 107 | command=[make, 'test', WithProperties('TESTARGS=%s' % clangTestArgs), |
Daniel Dunbar | fa0e022 | 2009-11-09 06:08:28 +0000 | [diff] [blame] | 108 | WithProperties('EXTRA_TESTDIRS=%s' % extraTestDirs)], |
Daniel Dunbar | 8a89a6f | 2009-11-25 04:27:32 +0000 | [diff] [blame^] | 109 | workdir='%s/tools/clang' % llvm_1_objdir)) |
| 110 | |
| 111 | # Install llvm and clang. |
| 112 | if llvm_1_installdir: |
| 113 | f.addStep(WarningCountingShellCommand(name="install.llvm.1", |
| 114 | command=['nice', '-n', '10', |
| 115 | make, WithProperties("-j%s" % jobs), |
| 116 | 'install'], |
| 117 | haltOnFailure=True, |
| 118 | description=["install", "llvm & clang"], |
| 119 | workdir=llvm_1_objdir)) |
| 120 | |
| 121 | if not useTwoStage: |
| 122 | return f |
| 123 | |
| 124 | # Clean up llvm (stage 2). |
| 125 | if clean: |
| 126 | f.addStep(ShellCommand(name="rm-llvm.obj.stage2", |
| 127 | command=["rm", "-rf", llvm_2_objdir], |
| 128 | haltOnFailure=True, |
| 129 | description=["rm build dir", "llvm", "(stage 2)"], |
| 130 | workdir=".")) |
| 131 | |
| 132 | # Configure llvm (stage 2). |
| 133 | args = base_configure_args + ["--without-llvmgcc", "--without-llvmgxx"] |
| 134 | args += getConfigArgs(stage2_config) |
| 135 | f.addStep(Configure(name="configure.llvm.stage2", |
| 136 | command=args, |
| 137 | env={'CC' : WithProperties("%%(builddir)s/%s/bin/clang" % llvm_1_installdir), |
| 138 | 'CXX' : WithProperties("%%(builddir)s/%s/bin/clang++" % llvm_1_installdir),}, |
| 139 | haltOnFailure=True, |
| 140 | workdir=llvm_2_objdir, |
| 141 | description=["configure", "llvm", "(stage 2)", |
| 142 | stage2_config])) |
| 143 | |
| 144 | # Build llvm (stage 2). |
| 145 | f.addStep(WarningCountingShellCommand(name="compile.llvm.stage2", |
| 146 | command=['nice', '-n', '10', |
| 147 | make, WithProperties("-j%s" % jobs)], |
| 148 | haltOnFailure=True, |
| 149 | description=["compiling", "(stage 2)", |
| 150 | stage2_config], |
| 151 | descriptionDone=["compile", "(stage 2)", |
| 152 | stage2_config], |
| 153 | workdir=llvm_2_objdir)) |
| 154 | |
| 155 | if test: |
| 156 | f.addStep(ClangTestCommand(name='test-llvm', |
| 157 | command=[make, "check-lit", "VERBOSE=1"], |
| 158 | description=["testing", "llvm"], |
| 159 | descriptionDone=["test", "llvm"], |
| 160 | workdir=llvm_2_objdir)) |
| 161 | f.addStep(ClangTestCommand(name='test-clang', |
| 162 | command=[make, 'test', WithProperties('TESTARGS=%s' % clangTestArgs), |
| 163 | WithProperties('EXTRA_TESTDIRS=%s' % extraTestDirs)], |
| 164 | workdir='%s/tools/clang' % llvm_2_objdir)) |
| 165 | |
Daniel Dunbar | 235aa41 | 2009-07-18 07:16:15 +0000 | [diff] [blame] | 166 | return f |
Daniel Dunbar | 44abe74 | 2009-07-19 01:59:03 +0000 | [diff] [blame] | 167 | |
Daniel Dunbar | b51f6ab | 2009-11-09 03:09:23 +0000 | [diff] [blame] | 168 | def getClangMSVCBuildFactory(update=True, clean=True, vcDrive='c', jobs=1): |
Daniel Dunbar | 44abe74 | 2009-07-19 01:59:03 +0000 | [diff] [blame] | 169 | f = buildbot.process.factory.BuildFactory() |
| 170 | |
Daniel Dunbar | b51f6ab | 2009-11-09 03:09:23 +0000 | [diff] [blame] | 171 | if update: |
Daniel Dunbar | 44abe74 | 2009-07-19 01:59:03 +0000 | [diff] [blame] | 172 | f.addStep(SVN(name='svn-llvm', |
| 173 | mode='update', baseURL='http://llvm.org/svn/llvm-project/llvm/', |
| 174 | defaultBranch='trunk', |
| 175 | workdir='llvm')) |
| 176 | |
Daniel Dunbar | b51f6ab | 2009-11-09 03:09:23 +0000 | [diff] [blame] | 177 | if update: |
Daniel Dunbar | 44abe74 | 2009-07-19 01:59:03 +0000 | [diff] [blame] | 178 | f.addStep(SVN(name='svn-clang', |
Daniel Dunbar | 7e959c8 | 2009-09-28 04:01:19 +0000 | [diff] [blame] | 179 | mode='update', baseURL='http://llvm.org/svn/llvm-project/cfe/', |
Daniel Dunbar | 44abe74 | 2009-07-19 01:59:03 +0000 | [diff] [blame] | 180 | defaultBranch='trunk', |
| 181 | workdir='llvm/tools/clang')) |
| 182 | |
| 183 | # Full & fast clean. |
Daniel Dunbar | b51f6ab | 2009-11-09 03:09:23 +0000 | [diff] [blame] | 184 | if clean: |
Daniel Dunbar | 44abe74 | 2009-07-19 01:59:03 +0000 | [diff] [blame] | 185 | f.addStep(ShellCommand(name='clean-1', |
| 186 | command=['del','/s/q','build'], |
Daniel Dunbar | 7e959c8 | 2009-09-28 04:01:19 +0000 | [diff] [blame] | 187 | warnOnFailure=True, |
Daniel Dunbar | 44abe74 | 2009-07-19 01:59:03 +0000 | [diff] [blame] | 188 | description='cleaning', |
| 189 | descriptionDone='clean', |
| 190 | workdir='llvm')) |
| 191 | f.addStep(ShellCommand(name='clean-2', |
| 192 | command=['rmdir','/s/q','build'], |
Daniel Dunbar | 7e959c8 | 2009-09-28 04:01:19 +0000 | [diff] [blame] | 193 | warnOnFailure=True, |
Daniel Dunbar | 44abe74 | 2009-07-19 01:59:03 +0000 | [diff] [blame] | 194 | description='cleaning', |
| 195 | descriptionDone='clean', |
| 196 | workdir='llvm')) |
| 197 | |
| 198 | # Create the project files. |
Daniel Dunbar | 7e959c8 | 2009-09-28 04:01:19 +0000 | [diff] [blame] | 199 | |
Daniel Dunbar | b51f6ab | 2009-11-09 03:09:23 +0000 | [diff] [blame] | 200 | # Use batch files instead of ShellCommand directly, Windows quoting is |
| 201 | # borked. FIXME: See buildbot ticket #595 and buildbot ticket #377. |
| 202 | f.addStep(BatchFileDownload(name='cmakegen', |
| 203 | command=[r"c:\Program Files\CMake 2.6\bin\cmake", |
| 204 | "-DLLVM_TARGETS_TO_BUILD:=X86", |
| 205 | "-G", |
| 206 | "Visual Studio 9 2008", |
| 207 | ".."], |
| 208 | workdir="llvm\\build")) |
Daniel Dunbar | 44abe74 | 2009-07-19 01:59:03 +0000 | [diff] [blame] | 209 | f.addStep(ShellCommand(name='cmake', |
| 210 | command=['cmakegen.bat'], |
Daniel Dunbar | 7e959c8 | 2009-09-28 04:01:19 +0000 | [diff] [blame] | 211 | haltOnFailure=True, |
Daniel Dunbar | 44abe74 | 2009-07-19 01:59:03 +0000 | [diff] [blame] | 212 | description='cmake gen', |
| 213 | workdir='llvm\\build')) |
| 214 | |
| 215 | # Build it. |
Daniel Dunbar | b51f6ab | 2009-11-09 03:09:23 +0000 | [diff] [blame] | 216 | f.addStep(BatchFileDownload(name='vcbuild', |
| 217 | command=[vcDrive + r""":\Program Files\Microsoft Visual Studio 9.0\VC\VCPackages\vcbuild.exe""", |
| 218 | "/M%d" % jobs, |
| 219 | "LLVM.sln", |
| 220 | "Debug|Win32"], |
| 221 | workdir="llvm\\build")) |
Daniel Dunbar | 44abe74 | 2009-07-19 01:59:03 +0000 | [diff] [blame] | 222 | f.addStep(WarningCountingShellCommand(name='vcbuild', |
| 223 | command=['vcbuild.bat'], |
Daniel Dunbar | 7e959c8 | 2009-09-28 04:01:19 +0000 | [diff] [blame] | 224 | haltOnFailure=True, |
Daniel Dunbar | 44abe74 | 2009-07-19 01:59:03 +0000 | [diff] [blame] | 225 | description='vcbuild', |
| 226 | workdir='llvm\\build', |
| 227 | warningPattern=" warning C.*:")) |
Daniel Dunbar | b51f6ab | 2009-11-09 03:09:23 +0000 | [diff] [blame] | 228 | |
| 229 | # Build clang-test project. |
| 230 | f.addStep(BatchFileDownload(name='vcbuild_test', |
| 231 | command=[vcDrive + r""":\Program Files\Microsoft Visual Studio 9.0\VC\VCPackages\vcbuild.exe""", |
| 232 | "clang-test.vcproj", |
| 233 | "Debug|Win32"], |
| 234 | workdir="llvm\\build\\tools\\clang\\test")) |
| 235 | f.addStep(ClangTestCommand(name='test-clang', |
| 236 | command=["vcbuild_test.bat"], |
| 237 | workdir="llvm\\build\\tools\\clang\\test")) |
| 238 | |
Daniel Dunbar | 44abe74 | 2009-07-19 01:59:03 +0000 | [diff] [blame] | 239 | return f |