1 Instructions for hacking on Xapian
2 ==================================
4 .. contents:: Table of contents
8 Before reading the contents of this file, you should look at
9 `the Xapian developer guide`_. If you want, you can `grab
10 it from github`_ and build it locally.
12 The bulk of the previous contents of this file now live in the developer
13 guide, and it is likely that the rest will follow in due course.
15 .. _the Xapian developer guide: https://xapian-developer-guide.readthedocs.io/
16 .. _grab it from github: https://github.com/xapian/xapian-developer-guide
22 If you want to try unreleased Xapian code, you can fetch it from our git
23 repository. For convenience, we also provide bootstrapped tarballs (much like
24 the sourcecode download for any release version) which get built every 20
25 minutes if there have been any changes checked in. These tarballs need to
26 pass "make distcheck" to be automatically uploaded, so using them will help
27 to assure that you don't pick a "bad" version. The snapshots are available
28 from the "Bleeding Edge" page of the Xapian website.
33 When building from a git checkout, we *strongly* recommend that you use
34 the ``bootstrap`` script in the top level directory to set up the tree ready
35 for building. This script will check which directories you have checked out,
36 so you can bootstrap a partial tree. You can also ``touch .nobootstrap`` in
37 a subdirectory to tell bootstrap to ignore it.
39 You will need the following tools installed to build from git:
41 * GNU m4 >= 4.6 (for autoconf)
42 * perl >= 5.6 (for automake; also for various maintainer scripts)
43 * python >= 3.3 (for generating the Python bindings)
44 * GNU make (or another make which support VPATH for explicit rules)
45 * GNU bison (for building SWIG, used for generating the bindings)
46 * Tcl (to generate unicode/unicode-data.cc)
48 For a recent version of Debian or Ubuntu, this command should ensure you have
49 all the necessary tools and libraries::
51 apt-get install build-essential m4 perl python3 zlib1g-dev uuid-dev wget bison tcl
53 If you want to build Omega, you'll also need::
55 apt-get install libpcre2-dev libmagic-dev
57 On Fedora, the uuid library can be installed by doing::
59 yum install libuuid-devel
61 On macOS, if you're using macports you'll want the following:
63 * file (magic.h in configure)
65 If you're using homebrew you'll want the following::
67 brew install libmagic pcre2
69 If you're doing much development work, you'll probably also want the following
72 * valgrind for better testsuite error finding
73 * ccache for faster rebuilds
74 * eatmydata for faster testsuite runs
76 The repository does not contain any automatically generated files
77 (such as configure, Makefile.in, Snowball-generated stemmers, Lemon-generated
78 parsers, SWIG-generated code, etc) because experience shows it's best to keep
79 these out of version control. To avoid requiring you to install the correct
80 versions of the tools required, we either include the source to these tools in
81 the repo directly (in the case of Snowball and Lemon), or the bootstrap script
82 will download them as tarballs (autoconf, automake, libtool) or
83 from git (SWIG), build them, and install them within the source tree.
85 To download source tarballs, bootstrap will use wget, curl or lwp-request if
86 installed. If not, it will give an error telling you the URL to download from
87 by hand and where to copy the file to.
89 Bootstrap will then run autoreconf on each of the checked-out subdirectories,
90 and generate a top-level configure script. This configure script allows you to
91 configure xapian-core and any other modules you've checked out with single
92 simple command, such that the other modules link against the uninstalled
93 xapian-core (which is very handy for development work and a bit fiddly to set
94 up by hand). It automatically passes --enable-maintainer-mode to the
95 subprojects so that the autotools will be rerun if configure.ac, Makefile.am,
98 The bootstrap script doesn't care what the current directory is. The top-level
99 configure script generated by it supports building in a separate directory to
100 the sources: simply create the directory you want to build in, and then run the
101 configure script from inside that directory. For example, to build in a
102 directory called "build" (starting in the top level source directory)::
109 When running bootstrap, if you need to add any extra macro directories to the
110 path searched by aclocal (which is part of automake), you can do this by
111 specifying these in the ACLOCAL_FLAGS environment variable, e.g.::
113 ACLOCAL_FLAGS=-I/extra/macro/directory ./bootstrap
115 If you wish to prevent bootstrap from downloading and building the autotools
116 pass the --without-autotools option. You can force it to delete the downloaded
117 and installed versions by passing --clean.
119 If you are tracking development in git, there will sometimes be changes
120 to the build system sources which require regeneration of the generated
121 makefiles and associated machinery. We aim to make the build system
122 automatically regenerate the necessary files, but in the event that a build
123 fails after an update, it may be worth re-running the bootstrap script to
124 regenerate the build system from scratch, before looking for the cause of the
127 Tools required to build documentation
128 -------------------------------------
130 If you want to be able to build distribution tarballs (with "make dist") then
131 you'll also need some further tools. If you don't want to have to install all
132 these tools, then pass --disable-documentation to configure to disable these
133 rules (the default state of this follows the setting of
134 --enable-maintainer-mode, so in a non-maintainer-mode tree, you can pass
135 --enable-documentation to enable these rules). Without the documentation,
136 "make dist" will fail (to prevent accidentally distributing tarballs without
137 documentation), but you can configure and build.
139 The documentation tools are:
141 * doxygen (v1.8.8 is used for 1.3.x snapshots and releases; 1.7.6.1 fails to
142 process trunk after PL2Weight was added).
143 * dot (part of Graphviz. Doxygen's DOT_MULTI_TARGETS option apparently needs
146 * rst2html or rst2html.py (in python3-docutils on Debian/Ubuntu)
147 * pngcrush (optional - used to reduce the size of PNG files in the HTML
149 * sphinx-doc (in python3-sphinx on Debian/Ubuntu, or as sphinx via pip install)
151 For a recent version of Debian or Ubuntu, this command should install all the
152 required documentation tools::
154 apt-get install doxygen graphviz help2man python-docutils pngcrush python-sphinx python3-sphinx
156 Documentation builds on macOS
157 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
159 On macOS, if you're using homebrew, you'll want the following::
161 brew install doxygen help2man graphviz pngcrush
163 (Ensure you're up to date with brew, as earlier packaging of graphviz
164 didn't properly install dot.)
166 You also need sphinx and docutils, which are python packages; you can
167 install them via pip::
169 pip3 install sphinx docutils
171 You may find it easier to use homebrew to install python first, so
172 these packages are separate from the system python::
176 On macOS, if you're using macports you'll want the following:
178 * texlive (pdflatex during build)
179 * texlive-basic (for makeindex in configure)
180 * texlive-latex-extra (latex style)
182 The homebrew texlive package only supports 32 bit systems, so even if you're
183 using homebrew, you'll probably want to install MacTeX from
184 https://www.tug.org/mactex/ instead.
186 As of 1.3.2, we no longer build PDF versions of the API docs by default, but
187 you can build them yourself with::
189 make -C docs apidoc.pdf
194 * autoconf 2.69 is used to generate snapshots and releases.
196 autoconf 2.64 is a hard minimum requirement.
198 autoconf 2.60 is required for docdir support and AC_TYPE_SSIZE_T.
200 autoconf 2.62 generates faster configure scripts and warns about unrecognised
201 options passed to configure.
203 autoconf 2.63 fixes a regression in AC_C_BIGENDIAN introduced in 2.62
204 (Omega uses this macro).
206 autoconf 2.64 generates smaller configure scripts by using shell functions.
208 * automake 1.16.1 is used to generate snapshots and releases.
210 automake 1.13 is a hard minimum requirement, needed for
211 `AC_CONFIG_MACRO_DIRS`.
213 * libtool 2.4.6 is used to generate snapshots and releases.
215 libtool 2.2.8 is the current hard minimum requirement.
217 libtool 2.2 is required for us to be able to override link_all_deplibs_CXX
218 and sys_lib_dlsearch_path_spec in configure. It also fixes some
219 long-standing issues and is significantly faster.
221 Please tell us if you find that newer versions of any of these tools work or
224 There is a good GNU autotools tutorial at
225 <https://www.lrde.epita.fr/~adl/autotools.html>.
227 Building from git on Windows with MSVC
228 --------------------------------------
230 Building using MSVC is now supported by the autotools build system. You need
231 to install a set of Unix-like tools first - we recommended MSYS2:
232 https://www.msys2.org/
234 For details of how to specify MSVC to ``configure`` see the "INSTALL" document.
236 When building from git, by default you'll need some extra tools to generate
237 Unicode tables (Tcl) and build documentation (doxygen, help2man, sphinx-doc).
238 We don't currently have detailed advice on how to do this (if you can provide
239 some then please send a patch).
241 You can avoid needing Tcl by copying ``xapian-core/unicode/unicode-data.cc``
242 from another platform or a release which uses the same Unicode version. You
243 can avoid needing most of the documentation tools by running configure with
244 the ``--disable-documentation`` option.
250 If you have a patch to fix a problem in Xapian, or to add a new feature,
251 please send it to us for inclusion. Any major changes should be discussed
252 on the xapian-devel mailing list first:
253 <https://xapian.org/lists>
255 Also, please read the following section on licensing of patches before
258 If you're working from a tarball, you can unpack a second clean copy of the
259 files and compare the two versions with "diff -pruN" (-p reports the function
260 name for each chunk, -r acts recursively, -u does a unified diff, and -N shows
261 new files in the diff). Alternatively "ptardiff" (which comes with perl, at
262 least on Debian and Ubuntu) can diff against the original tarball, unpacking
265 Please try to follow the style of the existing code.
267 We will do our best to give credit where credit is due - if we have used
268 patches from you, or received helpful reports or advice, we will add your name
269 to the AUTHORS file (unless you specifically request us not to). If you see we
270 have forgotten to do this, please draw it to our attention so that we can
271 address the omission.
274 Tips for Submitting a Good Patch
275 ================================
277 Make sure the tests are right
278 -----------------------------
280 * If you're adding a feature, also add feature tests for it. These both
281 ensure that the feature isn't broken to start with and detect if later
282 changes stop it working as intended.
284 * If you've fixed a bug, make sure there's a regression test which
285 fails on the existing code and succeeds after your changes.
287 * If you're adding a new testcase to demonstrate an existing bug, and not
288 checking a fix in at the same time, mark the testcase as a known failure (by
289 calling ``XFAIL("explanatory message")`` at the start of your testcase (if
290 necessary this can be conditional on backend or other factors - the backend
291 case has explicit support via ``XFAIL_FOR_BACKEND("backend", "message")``).
293 This will mean that this testcase failing will be reported as "XFAIL" which
294 won't cause the test run to fail. If such a testcase in fact passes, that
295 gets reported as "XPASS" and *will* cause the test run to fail. A testcase
296 should not be flagged as "XFAIL" for a long time, but it can be useful to be
297 able to add such testcases during development. It also allows a patch
298 series which fixes a bug to first demonstrate the bug via a new testcase
299 marked as "XFAIL", then fix the bug and remove the "XFAIL" - this makes it
300 clear that the regression test actually failed before the fix.
302 Note that failures which are due to valgrind errors or leaked fds are not
303 affected by this macro - such errors are inherently not suitable for "XFAIL"
304 as they go away when the testsuite is run without valgrind or on a platform
305 where our fd leak detector code isn't supported.
307 * Make sure all existing tests continue to pass.
309 If you don't know how to write tests using the Xapian test rig, then
310 ask. It's reasonably simple once you've done it once. There is a brief
311 introduction to the Xapian test system in ``docs/tests.html``.
317 If there's a related trac ticket, update it (if the issue is completely
318 addressed by the changes you've made, then close it).
320 Update the release notes for the most recent release with a copy of the
321 patch. If the commit from git applies cleanly, you can just link to
322 it. If it fails to apply, please attach an adjusted patch which does.
323 If there are conflicts in test cases which aren't easy to resolve, it is
324 acceptable to just drop those changes from the patch if we can still be
325 confident that the issue is actually fixed by the patch.
331 If there's a trac ticket or other reference for the bug, mention it in the
332 commit message - it's a great help to future developers trying to work out
333 why a change was made.