Christian Egli | f70f4e0 | 2011-01-03 15:09:06 +0000 | [diff] [blame] | 1 | This HACKING file describes the development environment. -*- org -*- |
Christian Egli | 5510e4a | 2009-11-05 09:55:30 +0000 | [diff] [blame] | 2 | |
Christian Egli | 311d52b | 2013-01-11 16:19:23 +0000 | [diff] [blame] | 3 | Copyright (C) 2008, 2009, 2011 ViewPlus Technologies, Inc. and Abilitiessoft, Inc. |
Christian Egli | 71647d6 | 2014-05-20 09:20:28 +0200 | [diff] [blame] | 4 | Copyright (C) 2012, 2013, 2014 Swiss Library for the Blind, Visually Impaired and Print Disabled |
Christian Egli | 311d52b | 2013-01-11 16:19:23 +0000 | [diff] [blame] | 5 | |
Christian Egli | 5510e4a | 2009-11-05 09:55:30 +0000 | [diff] [blame] | 6 | Copying and distribution of this file, with or without modification, |
| 7 | are permitted in any medium without royalty provided the copyright |
Christian Egli | 741b007 | 2014-09-18 11:08:45 +0200 | [diff] [blame] | 8 | notice and this notice are preserved. This file is offered as-is, |
| 9 | without any warranty. |
Christian Egli | eddc466 | 2009-03-09 13:27:20 +0000 | [diff] [blame] | 10 | |
| 11 | This file attempts to describe the maintainer-specific notes to follow |
| 12 | when hacking liblouis. |
| 13 | |
Christian Egli | 5510e4a | 2009-11-05 09:55:30 +0000 | [diff] [blame] | 14 | * Developing |
| 15 | ** Where to get it |
Christian Egli | 71647d6 | 2014-05-20 09:20:28 +0200 | [diff] [blame] | 16 | The development sources are available through git at github.com: |
Christian Egli | 5510e4a | 2009-11-05 09:55:30 +0000 | [diff] [blame] | 17 | |
Christian Egli | 71647d6 | 2014-05-20 09:20:28 +0200 | [diff] [blame] | 18 | https://github.com/liblouis/liblouis |
Christian Egli | 5510e4a | 2009-11-05 09:55:30 +0000 | [diff] [blame] | 19 | |
| 20 | ** Build requirements |
| 21 | This distribution uses Automake, Autoconf, and Libtool. If you are |
Christian Egli | 71647d6 | 2014-05-20 09:20:28 +0200 | [diff] [blame] | 22 | getting the sources from git (or change configure.ac), you'll need to |
Christian Egli | 5510e4a | 2009-11-05 09:55:30 +0000 | [diff] [blame] | 23 | have these tools installed to (re)build. Optionally (if you want to |
| 24 | generate man pages) you'll also need help2man. All of these programs |
| 25 | are available from ftp://ftp.gnu.org/gnu. |
| 26 | |
Bert Frees | 34df6a6 | 2015-04-10 16:10:21 +0200 | [diff] [blame^] | 27 | On Mac OS, the programs can be optained with Homebrew (http://brew.sh): |
Bert Frees | d41c9ac | 2015-03-25 14:42:43 +0100 | [diff] [blame] | 28 | |
Bert Frees | 34df6a6 | 2015-04-10 16:10:21 +0200 | [diff] [blame^] | 29 | brew install automake libtool pkg-config texinfo |
| 30 | |
| 31 | Note that if you are using Homebrew to install liblouis (see below), |
| 32 | the build dependencies are installed automatically. |
Bert Frees | d41c9ac | 2015-03-25 14:42:43 +0100 | [diff] [blame] | 33 | |
Christian Egli | 5510e4a | 2009-11-05 09:55:30 +0000 | [diff] [blame] | 34 | ** Gnulib |
Christian Egli | 71647d6 | 2014-05-20 09:20:28 +0200 | [diff] [blame] | 35 | This distribution also uses Gnulib (http://www.gnu.org/software/gnulib). If |
| 36 | you want to update from the current gnulib, install gnulib, and then run |
| 37 | gnulib-tool --import in the top-level directory. |
Christian Egli | 5510e4a | 2009-11-05 09:55:30 +0000 | [diff] [blame] | 38 | |
| 39 | For the record, the first time invocation was |
| 40 | gnulib-tool --import --lib=libgnu --source-base=gnulib \ |
| 41 | --m4-base=gnulib/m4 --aux-dir=build-aux --libtool \ |
| 42 | --macro-prefix=gl getopt-gnu progname version-etc |
| 43 | More modules might have been added since. The currently-used gnulib |
| 44 | modules and other gnulib information are recorded in |
| 45 | gnulib/m4/gnulib-cache.m4. Given a source checkout of gnulib, you can |
| 46 | update the files with gnulib-tool --import. |
| 47 | |
| 48 | ** How to build |
Christian Egli | 71647d6 | 2014-05-20 09:20:28 +0200 | [diff] [blame] | 49 | After getting the sources from git, with |
Christian Egli | 81b0481 | 2009-11-05 11:07:17 +0000 | [diff] [blame] | 50 | |
Christian Egli | 71647d6 | 2014-05-20 09:20:28 +0200 | [diff] [blame] | 51 | git clone https://github.com/liblouis/liblouis.git |
Christian Egli | 81b0481 | 2009-11-05 11:07:17 +0000 | [diff] [blame] | 52 | |
| 53 | and installing the tools above, change to the liblouis directory and |
| 54 | and bootstrap the project with the following command |
| 55 | |
| 56 | ./autogen.sh |
| 57 | |
| 58 | to do a fresh build. Then run configure as usual: |
| 59 | |
| 60 | ./configure |
| 61 | |
| 62 | You have the choice to compile liblouis for either 16- or 32-bit |
| 63 | Unicode. By default it is compiled for the former. To get 32-bit |
| 64 | Unicode run configure with --enable-ucs4 . |
| 65 | |
| 66 | After running configure run "make" and then "make install". You must |
| 67 | have root privileges for the installation step. |
Christian Egli | 5510e4a | 2009-11-05 09:55:30 +0000 | [diff] [blame] | 68 | |
Bert Frees | 34df6a6 | 2015-04-10 16:10:21 +0200 | [diff] [blame^] | 69 | ** Install with Homebrew |
| 70 | Homebrew (http://brew.sh) is a package manager for Mac OS X that |
| 71 | installs software from source. There is nothing special about the |
| 72 | installation process in the sense that under the hood it happens |
| 73 | exactly as described above, with the only difference that Homebrew |
| 74 | automates it completely. |
| 75 | |
| 76 | First, use the ~brew tap~ command to add the repository that includes |
| 77 | the liblouis formula: |
| 78 | |
| 79 | brew tap liblouis/liblouis |
| 80 | |
| 81 | Now you are ready to install liblouis: |
| 82 | |
| 83 | brew install liblouis |
| 84 | |
Bert Frees | d41c9ac | 2015-03-25 14:42:43 +0100 | [diff] [blame] | 85 | ** Docker |
Bert Frees | 34df6a6 | 2015-04-10 16:10:21 +0200 | [diff] [blame^] | 86 | Docker (https://www.docker.com) can be useful both for creating a |
| 87 | development environment for liblouis, and for shipping the |
| 88 | application. |
Bert Frees | d41c9ac | 2015-03-25 14:42:43 +0100 | [diff] [blame] | 89 | |
Bert Frees | 34df6a6 | 2015-04-10 16:10:21 +0200 | [diff] [blame^] | 90 | Setting up a developer environment can take long and can be |
| 91 | problematic especially for Windows. Thanks to Docker we can set up the |
| 92 | environment for you, we can easily distribute it as an image, which |
| 93 | can be run by anybody and will behave exactly the same for everybody. |
Bert Frees | d41c9ac | 2015-03-25 14:42:43 +0100 | [diff] [blame] | 94 | |
Bert Frees | 34df6a6 | 2015-04-10 16:10:21 +0200 | [diff] [blame^] | 95 | Docker images of liblouis are being built automatically each time |
| 96 | something changes in the code (see https://registry.hub.docker.com/repos/liblouis). |
| 97 | In order to use them, first get Docker at |
| 98 | http://docs.docker.com/introduction/get-docker. Download the latest |
| 99 | liblouis image with: |
Bert Frees | d41c9ac | 2015-03-25 14:42:43 +0100 | [diff] [blame] | 100 | |
| 101 | docker pull liblouis/libouis |
Bert Frees | 34df6a6 | 2015-04-10 16:10:21 +0200 | [diff] [blame^] | 102 | |
| 103 | Then, enter the development environment by running the image in a |
| 104 | Docker container: |
| 105 | |
| 106 | docker run -it liblouis/libouis bash |
| 107 | |
| 108 | Local files and directories can be "mounted" inside the container, in |
| 109 | order to make it easier to edit files and to persist changes across |
| 110 | runs. For example, to use local table files: |
| 111 | |
| 112 | docker run -it -v $(pwd)/tables:/tmp/liblouis/tables liblouis/liblouis bash |
| 113 | |
| 114 | See the Docker documentation for more info. |
| 115 | |
| 116 | The same Docker image can be used as a development environment and as |
| 117 | the application itself. For example, to run the lou_translate tool |
| 118 | from inside a Docker container: |
| 119 | |
Bert Frees | d41c9ac | 2015-03-25 14:42:43 +0100 | [diff] [blame] | 120 | docker run -it liblouis/libouis lou_translate en-us-g1.ctb |
| 121 | |
Bert Frees | 34df6a6 | 2015-04-10 16:10:21 +0200 | [diff] [blame^] | 122 | To rebuild the image yourself, run the following command in the root |
| 123 | directory of the liblouis source: |
Bert Frees | d41c9ac | 2015-03-25 14:42:43 +0100 | [diff] [blame] | 124 | |
| 125 | docker build -t liblouis/liblouis |
| 126 | |
| 127 | ** How to run tests |
Bert Frees | 34df6a6 | 2015-04-10 16:10:21 +0200 | [diff] [blame^] | 128 | Tests are run with |
Bert Frees | d41c9ac | 2015-03-25 14:42:43 +0100 | [diff] [blame] | 129 | |
Bert Frees | 34df6a6 | 2015-04-10 16:10:21 +0200 | [diff] [blame^] | 130 | make check |
| 131 | |
| 132 | This however doesn't include the harness tests. Running the harness |
| 133 | tests requires Python and nose (https://nose.readthedocs.org). Also, |
| 134 | you need to have compiled with --enable-ucs4. To run all harness |
| 135 | tests, go into the tests/harness directory and run: |
| 136 | |
| 137 | make runall |
| 138 | |
| 139 | To run a single test: |
| 140 | |
| 141 | make <name of harness file> |
Bert Frees | d41c9ac | 2015-03-25 14:42:43 +0100 | [diff] [blame] | 142 | |
Christian Egli | f70f4e0 | 2011-01-03 15:09:06 +0000 | [diff] [blame] | 143 | ** How to debug |
Christian Egli | 45b3d32 | 2013-01-17 09:51:56 +0000 | [diff] [blame] | 144 | First you have to build liblouis with debugging info enabled. |
| 145 | |
| 146 | $ ./configure CFLAGS='-g -O0 -Wall -Wextra' |
| 147 | $ make |
| 148 | |
Christian Egli | f70f4e0 | 2011-01-03 15:09:06 +0000 | [diff] [blame] | 149 | Starting the programs under the tools directory within gdb is a little |
| 150 | tricky as they are linked with libtool. See the info page of libtool |
| 151 | for more information. To start lou_checktable for table wiskunde.ctb |
| 152 | for example you'd have to issue the following commands: |
| 153 | |
| 154 | $ libtool --mode=execute gdb ./tools/lou_checktable |
| 155 | (gdb) run tables/wiskunde.ctb |
| 156 | |
Christian Egli | c77a589 | 2012-05-11 12:11:26 +0000 | [diff] [blame] | 157 | ** How to find memory leaks |
| 158 | Valgrind is a tool that can be used to find memory errors. It is |
| 159 | recommended that you compile liblouis without any optimizations and |
| 160 | with all warnings enabled before running it through Valgrind: |
| 161 | |
| 162 | $ ./configure CFLAGS='-g -O0 -Wall' |
| 163 | $ make |
| 164 | |
| 165 | Then use Valgrind to analyze liblouis. For example you can run |
| 166 | lou_translate trough Valgrind: |
| 167 | |
| 168 | $ libtool --mode=execute valgrind -v --tool=memcheck \ |
| 169 | --leak-check=full --leak-resolution=high --log-file=valgrind.log \ |
| 170 | ./tools/lou_translate en-us-g2.ctb |
| 171 | |
| 172 | Type a few words at the prompt, check translation and terminate |
| 173 | lou_translate. Now open the file valgrind.log and see if there are any |
| 174 | memory leaks reported. |
| 175 | |
| 176 | You can also just run lou_checktable for example: |
| 177 | |
| 178 | $ libtool --mode=execute valgrind -v --tool=memcheck \ |
| 179 | --leak-check=full --leak-resolution=high --log-file=valgrind.log \ |
| 180 | ./tools/lou_checktable tables/nl-BE-g1.ctb |
| 181 | |
| 182 | Again open valgrind.log to see if any memory leaks were reported. |
| 183 | |
Christian Egli | ae43532 | 2012-05-14 10:00:36 +0000 | [diff] [blame] | 184 | For the full experience run lou_allround under Valgrind: |
| 185 | |
| 186 | $ libtool --mode=execute valgrind -v --tool=memcheck \ |
| 187 | --leak-check=full --show-reachable=yes \ |
| 188 | --leak-resolution=high --track-origins=yes \ |
| 189 | --log-file=valgrind.log ./tools/lou_allround |
| 190 | |
Christian Egli | 6eb6334 | 2013-06-03 10:03:54 +0000 | [diff] [blame] | 191 | ** How to analyze performance |
| 192 | Gprof helps you analyze the performance of programs. You have to |
| 193 | compile liblouis as follows: |
| 194 | |
| 195 | $ ./configure --disable-shared |
| 196 | $ make clean all CFLAGS='-g -O0 -pg' LDFLAGS='-all-static' |
| 197 | |
| 198 | Then translate some stuff with a large table: |
| 199 | |
| 200 | $ ./tools/lou_translate tests/tables/large.ctb |
| 201 | |
| 202 | Finally look at the call profile: |
| 203 | |
| 204 | $ libtool --mode=execute gprof ./tools/lou_translate gmon.out |
| 205 | |
Christian Egli | 35f4aeb | 2010-08-19 11:58:07 +0000 | [diff] [blame] | 206 | ** How to build for win32 |
Christian Egli | 311d52b | 2013-01-11 16:19:23 +0000 | [diff] [blame] | 207 | See the README.windows file and the windows subdirectory. |
Christian Egli | 75cd569 | 2012-05-16 08:00:37 +0000 | [diff] [blame] | 208 | |
Bert Frees | 34df6a6 | 2015-04-10 16:10:21 +0200 | [diff] [blame^] | 209 | *** How to cross-compile for Windows |
| 210 | To compile for win32, use the MinGW win32 cross-compiler as shown |
| 211 | below. Use the prefix option to install the binaries to a temporary |
| 212 | place where you can create a zip file. |
Christian Egli | 75cd569 | 2012-05-16 08:00:37 +0000 | [diff] [blame] | 213 | |
Christian Egli | daaf7e3 | 2013-06-21 14:27:14 +0000 | [diff] [blame] | 214 | ./configure --build i686-pc-linux-gnu --host i586-mingw32msvc --prefix=/tmp/liblouis-mingw32msvc |
Christian Egli | 75cd569 | 2012-05-16 08:00:37 +0000 | [diff] [blame] | 215 | make |
Christian Egli | daaf7e3 | 2013-06-21 14:27:14 +0000 | [diff] [blame] | 216 | make install |
| 217 | zip -r liblouis-mingw32msvc.zip /tmp/liblouis-mingw32msvc |
Christian Egli | 75cd569 | 2012-05-16 08:00:37 +0000 | [diff] [blame] | 218 | |
Bert Frees | 34df6a6 | 2015-04-10 16:10:21 +0200 | [diff] [blame^] | 219 | To compile for win64, use the MinGW-w64 cross-compiler: |
| 220 | |
| 221 | ./configure --host x86_64-w64-mingw32 --prefix=/tmp/liblouis-w64-mingw32 |
| 222 | make |
| 223 | make install |
| 224 | zip -r liblouis-w64-mingw32.zip /tmp/liblouis-w64-mingw32 |
| 225 | |
| 226 | *** TODO How to build for Windows using Cygwin |
| 227 | (possibly use a Vagrantfile as demonstration + explain that Cygwin |
| 228 | binaries can not be used outside the Cygwin environment) |
| 229 | |
| 230 | *** TODO How to build for Windows using MinGW |
| 231 | (possibly use a Vagrant file as demonstration) |
| 232 | |
Christian Egli | 75cd569 | 2012-05-16 08:00:37 +0000 | [diff] [blame] | 233 | |
Christian Egli | eddc466 | 2009-03-09 13:27:20 +0000 | [diff] [blame] | 234 | * Release Procedure |
| 235 | These steps describe what a maintainer does to make a release; they |
| 236 | are not needed for ordinary patch submission. |
| 237 | |
| 238 | ** Set the version number |
| 239 | Update the version number in NEWS (with version, date, and release |
| 240 | type), ChangeLog and configure.ac. |
| 241 | |
Christian Egli | d1f5718 | 2011-05-18 07:16:46 +0000 | [diff] [blame] | 242 | Don't forget to update the libtool versioning info in configure.ac, |
| 243 | i.e. LIBLOUIS_REVISION and possibly LIBLOUIS_CURRENT and LIBLOUIS_AGE. |
| 244 | |
Christian Egli | eddc466 | 2009-03-09 13:27:20 +0000 | [diff] [blame] | 245 | ** Commit and tag |
| 246 | Commit the changes and tag this version |
| 247 | |
Christian Egli | 5f9c03f | 2014-09-01 14:01:41 +0200 | [diff] [blame] | 248 | git tag -s v2.6.0 -m "Release 2.6.0" |
| 249 | git push origin v2.6.0 |
Christian Egli | eddc466 | 2009-03-09 13:27:20 +0000 | [diff] [blame] | 250 | |
| 251 | If you know the exact version number that needs to be tagged use |
| 252 | |
Christian Egli | 5f9c03f | 2014-09-01 14:01:41 +0200 | [diff] [blame] | 253 | git tag -s v2.6.0 -m "Release 2.6.0" <commit> |
| 254 | git push origin v2.6.0 |
Christian Egli | eddc466 | 2009-03-09 13:27:20 +0000 | [diff] [blame] | 255 | |
| 256 | ** Make the release |
| 257 | Check out a clean copy in a different directory, like /tmp. Run |
| 258 | autogen.sh and configure with no special prefixes. Run make distcheck. |
| 259 | This will make sure that all needed files are present, and do a |
| 260 | general sanity check. Run make dist. This will produce a tarball. |
| 261 | |
Christian Egli | 9a3b3ce | 2009-05-27 13:46:37 +0000 | [diff] [blame] | 262 | ./autogen.sh && ./configure && make && make distcheck && make dist |
Christian Egli | eddc466 | 2009-03-09 13:27:20 +0000 | [diff] [blame] | 263 | |
| 264 | ** Upload |
Christian Egli | 71647d6 | 2014-05-20 09:20:28 +0200 | [diff] [blame] | 265 | Add the tarball to the liblouis web site, i.e. add it under |
Christian Egli | 5f9c03f | 2014-09-01 14:01:41 +0200 | [diff] [blame] | 266 | $WEBSITE/downloads and add a link to it in $WEBSITE/downloads/index.md. |
Christian Egli | 71647d6 | 2014-05-20 09:20:28 +0200 | [diff] [blame] | 267 | See below for instructions on how to update the web site. |
Christian Egli | eddc466 | 2009-03-09 13:27:20 +0000 | [diff] [blame] | 268 | |
Christian Egli | 2ed702e | 2009-03-12 13:06:39 +0000 | [diff] [blame] | 269 | ** Online documentation |
Christian Egli | 71647d6 | 2014-05-20 09:20:28 +0200 | [diff] [blame] | 270 | The online documentation is part of the liblouis web site. To add it to the |
| 271 | site simply copy doc/liblouis.html to $WEBSITE/documentation/liblouis.html. |
| 272 | Make sure you add the proper YAML front matter. Again see below for |
| 273 | instructions on how to update the web site. |
Christian Egli | 2ed702e | 2009-03-12 13:06:39 +0000 | [diff] [blame] | 274 | |
Christian Egli | 71647d6 | 2014-05-20 09:20:28 +0200 | [diff] [blame] | 275 | ** Web site maintenance |
| 276 | The liblouis web site at liblouis.org is maintained with the help of |
| 277 | github pages (https://pages.github.com/). To edit the site just check |
| 278 | out the repo at https://github.com/liblouis/liblouis.github.io. You'll |
| 279 | need to know a few things about Jekyll (http://jekyllrb.com/) and |
| 280 | textile (http://redcloth.org/textile/) the markup that is used to edit |
| 281 | the content. In order to update the site simply edit, commit and push. |
Christian Egli | 2ed702e | 2009-03-12 13:06:39 +0000 | [diff] [blame] | 282 | |
Christian Egli | 71647d6 | 2014-05-20 09:20:28 +0200 | [diff] [blame] | 283 | For the new release update the project web site. Add a post containing |
| 284 | the current NEWS to the _posts directory. |
Christian Egli | 2ed702e | 2009-03-12 13:06:39 +0000 | [diff] [blame] | 285 | |
Christian Egli | 2541973 | 2011-05-09 07:38:14 +0000 | [diff] [blame] | 286 | ** Announce |
| 287 | Send an announcement to the liblouis list |
| 288 | liblouis-liblouisxml@freelists.org. See ANNOUNCEMENT for an example. |
| 289 | |