All Aboard The Meson Future Hype Train

Choo Choo

If you thought we’d dropped off the face of the planet, you probably missed it: we have moved away from Medium and started publishing on our faster, open source, and privacy-respecting blog at blog.elementary.io. We’ve kept this blog post unlisted here on Medium for posterity, but all recent and future posts as of November, 2019 are exclusively hosted there.

When developers on elementary OS want to make a new app, they need something called a build system to take all of their source code (stuff that humans can read) and turn it into an executable binary (stuff computers can read). The build system also handles things like installing files that we need to describe your app in AppCenter, show it in the Applications menu, and more (metadata). For quite a while now, the build system that we’ve endorsed at elementary has been CMake. CMake does a pretty decent job at being legible and we’ve provided a number of modules to make sure that it can do all of the things we need it to do without developers having to spend a lot of time writing build system code. Let’s face it, build system code is boring and spending time writing it is time spent away from actually making your app more awesome. That’s why I’m excited to say that the new hotness is here and it sure is new and hot.

Just Show Me The Comparison

Let’s get this right out the way and take a look at a typical CMake file versus a Meson file. First up is CMake:

An example CMake build file

And here’s Meson:

An example Meson build file

One big difference you should notice immediately is that installing files is just an argument instead of a whole new method and Meson is generally smart about knowing where certain files (like executables) should be installed to. You should also notice that things are a little more automatic regarding dependency handling and Meson has built-in variables for things like the system data directory. In general, we’ve noticed that Meson build files are shorter and easier to read than CMake, which makes writing and maintaining them much faster and easier.

What you won’t see here is that this CMake file actually depends on a repository with a few hundred extra lines of CMake to add support for things like internationalization and GResource. Meson is ready to go without extra dependencies and has upstream modules to support these functions. It also automatically provides some other niceties like uninstall targets and builds run in parallel by default without having to add arguments like make -j9 .

Meson has great documentation, and many well known projects like Gtk+ and Systemd have made the switch so you know it can handle complex build system tasks. We’re also excited about the active development community around Meson and we’ve committed fixes upstream for better Vala support and easier translation updates.

Coming to Juno

We’ve already begun migrating many of our projects to Meson, but like our big naming switch it will take a while to transition. From now on, all new elementary code will be built with Meson.

Meson is available already for developers to use in Loki, but it does require a bit of extra work on the Deb packaging side. In Juno, we’ll have a new version of Debhelper that makes packaging a Meson-built project just as automatic as CMake is today.

We’re pretty excited about making our platform more approachable for our 3rd party developer community, so you can expect our documentation to be updated as soon as the first preview builds of Juno become available to developers.