Meson (software)

Meson
Developer(s) Jussi Pakkanen
Initial release March 2, 2013 (2013-03-02)
Stable release
0.48.0[1] / September 22, 2018 (2018-09-22)
Repository Edit this at Wikidata
Written in Python
Operating system Cross-platform
Type Software development tools
License Apache 2.0 License
Website mesonbuild.com

Meson (/ˈmɛ.sɒn/[2]) is a software tool for automating the building (compiling) of software. The overall goal for Meson is to promote programmer productivity.[3]

Meson is free and open-source software written in Python 3 and subject to the terms of the Apache 2.0 License.[4]

Interoperability

Being written in Python, Meson runs natively on Unix-like operating systems, including macOS, as well as Microsoft Windows and on other operating systems.

Meson supports the C, C++, D, Fortran, Java, Rust and Vala languages,[5] and has a mechanism for handling dependencies called Wrap.

Meson supports GNU Compiler Collection, Clang, Microsoft Visual Studio and others.

Usage

Meson is like CMake in that it does not build software directly, but rather sets up a backend build system such as ninja on Linux, MSBuild on Windows or Xcode on macOS. The user then invokes the backend buildsystem. Because only out-of-tree builds are supported, like in CMake, it requires the user to create a build directory for this backend buildsystem and its outputs. The basic usage difference is that CMake defaults to make as a backend instead of ninja, but cmake -G Ninja behaves like Meson in this regard.

Language

The syntax of Meson's build description files (the Meson language) borrows from Python, but is not Python: It is designed to be reimplementable in any other language[6] – the dependency on Python is an implementation detail.

The Meson language is intentionally not Turing complete, and can therefore not express an arbitrary program.[6] Instead, arbitrary build steps beyond compiling supported languages can be represented as custom targets.

The Meson language is strongly typed, such that builtin types like library, executable, string, and lists thereof, are non-interchangeable.[7] In particular, unlike Make, the list type does not split strings on whitespace.[6] Thus, whitespace and other characters in filenames and program arguments are handled cleanly.

MesonCMakeMake
DatatypesYesNoNo
List datatypeYessemicolon delimited stringwhitespace delimited string
File globbingNoYesYes
Extensible via custom functionsNoYesYes
Can read output of arbitrary commands (at configure time)run_commandYesYes
Can run arbitrary commands at build time as recipes of custom targetsYesYesYes

Speed and correctness

As with any typical buildsystem, correct incremental builds is the most significant speed feature (because all incremental progress is discarded whenever the user is forced to do a clean build).

Unlike bare Make, the separate configure step ensures that changes to arguments, environment variables and command output are not partially applied in subsequent builds, which would lead to a stale build.

Like Ninja, Meson does not support globbing of source files.[6] By requiring all source files to be listed in the build definition files, the build definition file timestamps are sufficient to determine if the set of source files has changed, thereby ensuring that removed source files are detected. CMake supports globbing, but recommends against it for the same reason.[8]

Meson uses ccache automatically if installed. It also detects changes to symbol tables of shared libraries to skip relinking executables against the library when there are no ABI changes. Precompiled headers are supported, but requires configuration. Debug builds are without optimization by default.

speed featureMesonCMakeMake
Prohibits stale builds (partial rebuild against input change)Yes (unless there are bugs)If not globbing source filesRecursive Make (an idiomatic pattern) is broken in this respect[9]
CcacheAutomaticTrivial to addTrivial to add
Distcc?Trivial to addTrivial to add
Symbol table aware relinkingYesDo it yourselfDo it yourself
Precompiled headersOptionalBroken solutions exist[10][2]Do it yourself

Features

A stated goal of Meson is to facilitate modern development practices. As such, Meson knows how to do unity builds, build with test coverage, link time optimization etc without the programmer having to write support for this.

MesonCMakeAutotools
Generate a configure scriptNoNomake dist
Set correct library installation directory on x86_64 UnixAutomaticNot standardized./configure --libdir=/usr/lib64

Subprojects

Like CMake,CMake package Meson primarily uses pkg-config to find dependencies that are external to the project. This is not a solution to dependency hell, as the job of satisfying missing dependencies is on the user. Alternatively, the dependency can be internalized as a subproject – a Meson project within another – either contained or as a link.[11] This has the drawback of contributing to software bloat in the case of common dependencies. The compromise favored by Linux packagers is to use the subproject as a fallback for the external dependency.[12]

A problem is that Meson only supports Meson subprojects. For common dependencies, this is solved by patching in a Meson build file from the WrapDB service.[11]

Comparison of dependency resolution use cases in different build systems
use caseMesonCMakeCargo
Finding installed dependenciespkg-configCMake module, pkg-config?
Downloading dependencies automaticallysubprojectNoCargo dependency
Finding installed dependencies, with download fallbackpkg-config + subprojectNo?
pkg-config file generatorYesNoNo
Facilitate use as an auto-downloadable dependencyCan be used as a Meson subprojectNoWith registration to crates.io
Notes
^CMake package CMake can use either CMake packages or pkg-config, but as the table shows, both are for finding installed dependencies.

Cross compilation

Cross compilation requires extra configuration, which Meson supports in the form of a separate cross file, which can be external to the Meson project.[13]

Adopters

GNOME has made it a goal to port its projects to Meson.[14] As of late 2017, GNOME Shell itself exclusively requires Meson after abandoning Autotools,[15] and central components like GTK+, Clutter-GTK, GLib and GStreamer can be built with Meson.[14]

Systemd relies on Meson since dropping Autotools in version 234.[16]

Efforts are made to port Xorg[17] and Mesa[18] to Meson.

The Meson homepage lists further projects using Meson.[19]

See also

References

  1. "Releases - mesonbuild/meson". Retrieved 26 September 2018 via GitHub.
  2. 1 2 "Making build systems not suck (linux.conf.au video)".
  3. "High productivity build system". Meson aims to optimize programmer productivity by providing simple, out-of-the-box support for modern software development tools and practices, such as unit tests, coverage reports, Valgrind, CCache and the like.
  4. "mesonbuild/meson: The Meson Build System". GitHub. Retrieved 13 April 2016.
  5. "Reference manual".
  6. 1 2 3 4 "Meson Frequently Asked Questions".
  7. "Meson Syntax".
  8. "CMake FILE command". Note: We do not recommend using GLOB to collect a list of source files from your source tree. If no CMakeLists.txt file changes when a source is added or removed, the generated build system cannot know when to ask CMake to regenerate.
  9. "Non-recursive Make Considered Harmful" (PDF). Recursive Make is considered harmful for very good reasons (Miller 1998); it is not possible to accurately track dependencies when the build system is constructed of separate components that invoke each other.
  10. "CMake support for precompiled headers". Retrieved 13 March 2018.
  11. 1 2 "Wrap dependency system manual".
  12. "Meson and 3rd party dependencies. Only one correct way".
  13. "Cross compilation".
  14. 1 2 "GNOME Goal: Port modules to use Meson build system".
  15. "GNOME 3.26 Beta Debuts: More Meson Porting, Wayland Action".
  16. "Drop support for autotools".
  17. "The Meson Build System Is Being Fitted For The X.Org Server".
  18. "Meson-ized Mesa Now Supports More Drivers".
  19. "List of projects using Meson".
This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.