D support for the Meson build system

Matthias Klumpp via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Sun Aug 21 12:08:59 PDT 2016


Hi!
Last week I was at this year's GUADEC conference and listened to 
a very interesting talk on the Meson build system[2] which is 
designed for very fast builds and as a much more modern 
replacement for Automake with a simple syntax.
In the past few days I added support for D (all three major 
compilers) to the Meson build system, with some great results-

While dub is awesome for simple and small projects, you usually 
want a bit more for bigger projects, especially if you are mixing 
D code with C bits or are linking against libraries written in C 
(which is what pretty much all the D code I write does 
excessively).
You also make the life of Linux distribution packagers much 
easier with this, since dub isn't really working well for us in 
that usecase (only one D package in Debian uses it at time, and 
only for an experiment I made to check whether using dub is 
viable. At time, dub is pretty high up on my D complaints 
list[3]).

So, should you consider adding Meson support for your project? 
That depends.
A few highlights of Meson include:
  * Very fast builds using the Ninja[4] build tool (which is also 
used by projects like Google Chrome) - for a project like 
Terminix, dub with LDC builds in 8.6s, while Meson and ninja take 
only 6s here. The change is even more dramatic with a lot more D 
source files.

  * Support for installing files, and generally good support for 
Linux distributions.

  * Mixing in parts written in C or C++ is very simple.

  * Depending on system libraries (Cairo, Libarchive, GTK+) is 
really easy, and you can also version the dependencies.

  * You can configure files at build time and also run arbitrary 
commands to e.g. generate additional code to compile in or to 
compile additional resources, which is needed for a lot of 
applications.

If you want to see a real world example on how to use Meson, 
check out my example patch for Terminix:
https://github.com/gnunn1/terminix/commit/01d11dcff7da4626a91cf0344897c4ff1783a69e

For simpler examples, check out the D unit tests for Meson:
https://github.com/mesonbuild/meson/tree/master/test%20cases/d

Meson supports building files for Visual Studio and is supposed 
to work on Windows as well. I developed the D pieces solely on 
Linux and couldn't test anything on Windows yet (but it would be 
interesting to know if this works).

D support will be available in Meson with the upcoming 0.34 
release, which is when it will show up in Linux distributions 
like Ubuntu and Debian.
Until then, it's really easy to try Meson from Git master[5].

I hope you find this as useful as I do :-)

Cheers,
     Matthias

[1]: 
https://en.wikipedia.org/wiki/GNOME_Users_And_Developers_European_Conference
[2]: http://mesonbuild.com/
[3]: 
https://gist.github.com/ximion/77dda83a9926f892c9a4fa0074d6bf2b
[4]: https://ninja-build.org/
[5]: https://github.com/mesonbuild/meson



More information about the Digitalmars-d-announce mailing list