2 # ex: set syntax=python:
4 from buildbot
.process
import factory
5 from buildbot
.steps
import source
, shell
, slave
6 from datetime
import date
8 xapian_config_arg
= 'XAPIAN_CONFIG=../xapian-core/xapian-config'
10 get_tarballs_url
= 'https://raw.githubusercontent.com/xapian/xapian/master/xapian-maintainer-tools/buildbot/scripts/get_tarballs.py'
13 return shell
.ShellCommand(
16 description
= ["bootstrapping"],
17 descriptionDone
= ["bootstrap"],
18 command
= ["./bootstrap"],
22 return shell
.ShellCommand(
23 name
= "cleaninstall",
25 description
= ["cleaninstall"],
26 descriptionDone
= ["cleaninstall"],
27 command
= ['rm', '-rf', 'install'],
31 return shell
.ShellCommand(
34 description
= ["install"],
35 descriptionDone
= ["install"],
36 command
= ['make', 'install'],
41 Step which ensures that the permissions are writable on all
44 return shell
.ShellCommand(
45 name
= "make writable",
47 description
= ["making writable"],
48 descriptionDone
= ["made writable"],
49 command
= ["chmod", "-R", "+w", "."],
52 def core_factory(repourl
, usedocs
=False, configure
=None, audit
=False,
53 clean
=False, nocheck
= False, configure_opts
=None):
54 f
= factory
.BuildFactory()
57 #f.addStep(MakeWritable, workdir='.')
58 f
.addStep(shell
.ShellCommand(command
= ["chmod", "-R", "+w", "."], workdir
='.'))
60 f
.addStep(source
.Git(repourl
=repourl
, mode
=mode
))
62 f
.addStep(shell
.ShellCommand(command
= ["python", 'audit.py'], workdir
='build/xapian-maintainer-tools'))
63 f
.addStep(shell
.ShellCommand(command
= ["chmod", '644', 'copyright.csv', 'fixmes.csv'], workdir
='build/xapian-maintainer-tools'))
64 f
.addStep(shell
.ShellCommand(command
= ["mv", 'copyright.csv', 'fixmes.csv', '/var/www/'], workdir
='build/xapian-maintainer-tools'))
66 f
.addStep(Bootstrap())
68 f
.addStep(shell
.Configure(command
=configure
))
70 if configure_opts
is None:
73 configure_opts
.append("--disable-documentation")
75 f
.addStep(shell
.Configure(command
=["sh", "configure"] + configure_opts
))
77 f
.addStep(shell
.Configure())
79 f
.addStep(shell
.Compile())
81 f
.addStep(shell
.Test(name
="check", command
=["make", "check", "XAPIAN_TESTSUITE_OUTPUT=plain", "VALGRIND="]))
84 def gen_git_updated_factory(repourl
, usedocs
=False, clean
=False):
86 Make a factory for doing build from git master, but without cleaning
87 first. This build is intended to catch commonly made mistakes quickly.
89 return core_factory(repourl
=repourl
, usedocs
=usedocs
, clean
=clean
)
91 def gen_git_updated_factory_llvm(repourl
):
93 Make a factory for doing build from git master, but without cleaning
94 first. This build is intended to catch commonly made mistakes quickly.
96 return core_factory(repourl
=repourl
, configure_opts
=["CXX=/Developer/usr/llvm-gcc-4.2/bin/llvm-g++-4.2", "CC=/Developer/usr/llvm-gcc-4.2/bin/llvm-gcc-4.2"])
98 def gen_git_updated_factory2(repourl
, configure_opts
=[]):
100 Make a factory for doing build from git master, but without cleaning
101 first. This build is intended to catch commonly made mistakes quickly.
102 This factory also runs audit.py and publishes the result.
104 return core_factory(repourl
=repourl
, usedocs
=False, audit
=True,
105 configure_opts
=configure_opts
)
107 def gen_git_updated_factory3(repourl
):
109 Make a factory for doing build from git master, but without cleaning
110 first. This build is intended to catch commonly made mistakes quickly.
111 This build runs with --disable-documentation, so the documentation building
112 tools aren't required.
114 return core_factory(repourl
=repourl
, usedocs
=False)
116 def gen_git_gccsnapshot_updated_factory(repourl
):
118 Make a factory for doing build from git master, but without cleaning
119 first, using gcc snapshot. Also uses compiles with logging and assertions.
121 return core_factory(repourl
=repourl
,
122 configure_opts
=["--enable-assertions", "--enable-log", "CXX=/usr/lib/gcc-snapshot/bin/g++", "CC=/usr/lib/gcc-snapshot/bin/gcc",
125 def gen_git_debug_updated_factory(repourl
, opts
, nocheck
=False):
127 Make a factory for doing a debug build from git master, but without cleaning
128 first. This build is intended to catch commonly made mistakes quickly.
130 f
= factory
.BuildFactory()
131 f
.addStep(source
.Git(repourl
=repourl
, mode
="update"))
132 f
.addStep(Bootstrap())
133 opts
.append("--disable-documentation")
134 f
.addStep(shell
.Configure(command
= ["sh", "configure", ] + opts
))
135 f
.addStep(shell
.Compile())
137 f
.addStep(shell
.Test(name
="check", command
= ["make", "check", "XAPIAN_TESTSUITE_OUTPUT=plain", "VALGRIND="]))
140 def gen_tarball_updated_factory(rooturl
, nocheck
=False, omega
=True, bindings
=True, configure_opts
=[]):
142 Make a factory for doing builds from tarballs.
144 configure_cmd
= ["sh", "configure", ] + configure_opts
145 f
= factory
.BuildFactory()
146 f
.addStep(shell
.ShellCommand(command
= ["python", "-c", "try: import urllib2 as u\nexcept: import urllib.request as u\nopen('get_tarballs.py', 'wb').write(u.urlopen('%s').read())" %
147 get_tarballs_url
], workdir
='.', haltOnFailure
=True))
148 f
.addStep(shell
.ShellCommand(command
= ["python", 'get_tarballs.py', rooturl
], workdir
='.', haltOnFailure
=True))
149 f
.addStep(shell
.Configure(workdir
='build/xapian-core', command
=configure_cmd
))
150 f
.addStep(shell
.Compile(workdir
='build/xapian-core'))
152 f
.addStep(shell
.Test(workdir
='build/xapian-core', name
="check", command
= ["make", "check", "XAPIAN_TESTSUITE_OUTPUT=plain", "VALGRIND="]))
154 f
.addStep(shell
.Configure(workdir
='build/xapian-omega', command
= ["./configure", xapian_config_arg
] + configure_opts
))
155 f
.addStep(shell
.Compile(workdir
='build/xapian-omega'))
157 f
.addStep(shell
.Test(workdir
='build/xapian-omega', name
="check", command
= ["make", "check", "XAPIAN_TESTSUITE_OUTPUT=plain", "VALGRIND="]))
159 f
.addStep(shell
.Configure(workdir
='build/xapian-bindings', command
= ["./configure", xapian_config_arg
] + configure_opts
))
160 f
.addStep(shell
.Compile(workdir
='build/xapian-bindings', command
= ["make"]))
162 f
.addStep(shell
.Test(workdir
='build/xapian-bindings', name
="check", command
= ["make", "check", "XAPIAN_TESTSUITE_OUTPUT=plain", "VALGRIND="]))
163 # If everything passed, there's not much point keeping the build - we'd
164 # delete the old build tree and download new tarballs next time anyway.
165 f
.addStep(slave
.RemoveDirectory('build'))
168 def gen_git_updated_valgrind_factory(repourl
, configure_opts
=[]):
170 Factory for doing build from git master, without cleaning first, and using
171 valgrind to check. This one is much more expensive, so should be run with
172 a higher stable time.
174 f
= factory
.BuildFactory()
175 f
.addStep(source
.Git(repourl
=repourl
, mode
="update"))
176 f
.addStep(Bootstrap())
177 configure_opts
.append("--disable-documentation")
178 f
.addStep(shell
.Configure(command
= ["sh", "configure", "CXXFLAGS=-O0 -g"] + configure_opts
))
179 f
.addStep(shell
.Compile())
181 f
.addStep(shell
.Test(name
="check", command
= ["make", "check", "XAPIAN_TESTSUITE_OUTPUT=plain"], workdir
='build/xapian-core'))
185 def gen_git_updated_lcov_factory(repourl
, configure_opts
=[]):
187 Factory for doing build from git master, without cleaning first, and using
188 lcov to generate a coverage report. This one is much more expensive, so
189 should be run with a higher stable time.
191 f
= factory
.BuildFactory()
192 f
.addStep(source
.Git(repourl
=repourl
, mode
="update"))
193 f
.addStep(Bootstrap())
194 f
.addStep(shell
.Configure(command
= ["sh", "configure", "--enable-maintainer-mode", "--disable-shared", "--disable-documentation", "CXXFLAGS=-O0 --coverage", "VALGRIND=", "CCACHE_DISABLE=1"] + configure_opts
, workdir
="build/xapian-core"))
195 f
.addStep(shell
.Compile(workdir
="build/xapian-core"))
196 f
.addStep(shell
.ShellCommand(command
= ["make", "coverage-check", "GENHTML_ARGS=--html-gzip"], workdir
="build/xapian-core", haltOnFailure
=True))
197 f
.addStep(shell
.ShellCommand(command
= ["chmod", "-R", "a+rX", "lcov"], workdir
="build/xapian-core", haltOnFailure
=True))
198 f
.addStep(shell
.ShellCommand(command
= 'NOW=`date -u +%Y-%m-%d`; cp -a lcov/. /var/www/"$NOW" && ln -sfT "$NOW" /var/www/latest', workdir
="build/xapian-core", haltOnFailure
=True))
202 #### FIXME: factories beyond here not updated
204 def gen_git_clean_dist_factory(repourl
):
206 Factory for doing build from a clean checkout of git master. This build also
207 performs a "make distcheck", so should catch problems with files which have
208 been missed from the distribution. This one is much more expensive, so
209 should be run with a higher stable time.
211 f
= factory
.BuildFactory()
212 f
.addStep(MakeWritable
, workdir
='.')
213 f
.addStep(source
.Git(repourl
=repourl
, mode
="clobber"))
214 f
.addStep(Bootstrap())
215 f
.addStep(step
.Configure
, command
= ["xapian-maintainer-tools/buildbot/scripts/configure_with_prefix.sh"])
217 "XAPIAN_TESTSUITE_OUTPUT=plain", "VALGRIND="
219 f
.addStep(step
.Compile
, command
= ["make",] + extraargs
)
220 # Don't bother running check as a separate step - all the checks will be
221 # done by distcheck, anyway. (Running it as a separate step _does_ check
222 # that the tests work in a non-VPATH build, but this is tested by other
223 # factories, anyway.)
224 #f.addStep(step.Test, name="check", command = ["make", "check"] + extraargs)
225 f
.addStep(step
.Test
, name
="distcheck", command
= ["make", "distcheck"] + extraargs
, workdir
='build/xapian-core')
226 f
.addStep(step
.Test
, name
="distcheck", command
= ["make", "distcheck"] + extraargs
, workdir
='build/xapian-applications/omega')
228 # Have to install the core for distcheck to pass on the bindings.
229 f
.addStep(step
.Test
, name
="install", command
= ["make", "install"] + extraargs
, workdir
='build/xapian-core')
230 f
.addStep(step
.Test
, name
="distcheck", command
= ["make", "distcheck"] + extraargs
, workdir
='build/xapian-bindings')
233 def gen_git_updated_win_factory(repourl
):
235 Factory for doing a windows build from git, without cleaning first.
237 f
= factory
.BuildFactory()
238 f
.addStep(step
.Git(repourl
=repourl
, mode
="update"))
239 f
.addStep(step
.ShellCommand
, command
="xapian-maintainer-tools\\buildbot\\scripts\\prepare_build.bat")
241 # Compile core: we use a .bat file to get vsvars32.bat to run before the
244 f
.addStep(step
.Compile
, workdir
="build/xapian-core/win32",
245 command
="..\\..\\xapian-maintainer-tools\\buildbot\\scripts\\compile_with_vc7.bat",
250 def gen_tarball_updated_win_factory(rooturl
):
251 """Make a factory for doing builds from tarballs on windows.
254 f
= factory
.BuildFactory()
255 f
.addStep(shell
.ShellCommand(command
= ["python", "-c", "try: import urllib2 as u\nexcept: import urllib.request as u\nopen('get_tarballs.py', 'wb').write(u.urlopen('%s').read())" %
256 get_tarballs_url
], workdir
='.', haltOnFailure
=True))
257 f
.addStep(shell
.ShellCommand
, command
= ["python", 'get_tarballs.py', rooturl
], workdir
='.', haltOnFailure
=True)
258 f
.addStep(shell
.Compile
, workdir
='build/xapian-core/win32', command
= ["compile_with_vc7.bat"])
263 if gen
.startswith('gen_'):
265 locals()[gen
[4:]] = locals()[gen
]