Meson ()
is a software tool for
automating the building (compiling) of software. The overall goal for Meson is to promote programmer productivity.
Meson is
free and open-source software
Free and open-source software (FOSS) is a term used to refer to groups of software consisting of both free software and open-source software where anyone is freely licensed to use, copy, study, and change the software in any way, and the source ...
written in
Python, under the
Apache License 2.0.
Interoperability
Being written in Python, Meson runs on
Unix
Unix (; trademarked as UNIX) is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, a ...
-like operating systems, including
macOS
macOS (; previously OS X and originally Mac OS X) is a Unix operating system developed and marketed by Apple Inc. since 2001. It is the primary operating system for Apple's Mac (computer), Mac computers. Within the market of ...
, as well as
Microsoft Windows and on other operating systems.
Meson supports the
C,
C++,
CUDA
CUDA (or Compute Unified Device Architecture) is a parallel computing platform and application programming interface (API) that allows software to use certain types of graphics processing units (GPUs) for general purpose processing, an approach ...
,
D,
Objective-C
Objective-C is a general-purpose, object-oriented programming language that adds Smalltalk-style messaging to the C programming language. Originally developed by Brad Cox and Tom Love in the early 1980s, it was selected by NeXT for its N ...
,
Fortran,
Java
Java (; id, Jawa, ; jv, ꦗꦮ; su, ) is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea to the north. With a population of 151.6 million people, Java is the world's mo ...
,
C#,
Rust
Rust is an iron oxide, a usually reddish-brown oxide formed by the reaction of iron and oxygen in the catalytic presence of water or air moisture. Rust consists of hydrous iron(III) oxides (Fe2O3·nH2O) and iron(III) oxide-hydroxide (FeO(OH), ...
, and
Vala languages, and has a mechanism for handling dependencies called Wrap.
Meson supports
GNU Compiler Collection
The GNU Compiler Collection (GCC) is an optimizing compiler produced by the GNU Project supporting various programming languages, hardware architectures and operating systems. The Free Software Foundation (FSF) distributes GCC as free sof ...
,
Clang
Clang is a compiler front end for the C, C++, Objective-C, and Objective-C++ programming languages, as well as the OpenMP, OpenCL, RenderScript, CUDA, and HIP frameworks. It acts as a drop-in replacement for the GNU Compiler Collection ...
,
Microsoft Visual C++
Microsoft Visual C++ (MSVC) is a compiler for the C, C++ and C++/CX programming languages by Microsoft. MSVC is proprietary software; it was originally a standalone product but later became a part of Visual Studio and made available in both tr ...
and other compilers, including non-traditional compilers such as
Emscripten
Emscripten is an LLVM/Clang-based compiler that compiles C and C++ source code to WebAssembly (or to a subset of JavaScript known as asm.js, its original compilation target before the advent of WebAssembly in 2017), primarily for execution in ...
and
Cython
Cython () is a programming language that aims to be a superset of the Python programming language, designed to give C-like performance with code that is written mostly in Python with optional additional C-inspired syntax.
Cython is a compil ...
. The project uses
ninja
A or was a covert agent or mercenary in feudal Japan. The functions of a ninja included reconnaissance, espionage, infiltration, deception, ambush, bodyguarding and their fighting skills in martial arts, including ninjutsu.Kawakami, pp ...
as the primary backend buildsystem, but can also use
Microsoft Visual Studio
Visual Studio is an integrated development environment (IDE) from Microsoft. It is used to develop computer programs including web site, websites, web apps, web services and mobile apps. Visual Studio uses Microsoft software development platfor ...
or
Xcode
Xcode is Apple's integrated development environment (IDE) for macOS, used to develop software for macOS, iOS, iPadOS, watchOS, and tvOS. It was initially released in late 2003; the latest stable release is version 14.2, released on December 13, ...
backends.
Language
The syntax of Meson's build description files (the Meson language) borrows from
Python, but is not Python: It is designed such that it can be reimplemented in any other language;
for example, muon is a C implementation and Meson++ is a C++ implementation – the dependency on Python is an implementation detail.
The Meson language is intentionally not
Turing complete
Alan Mathison Turing (; 23 June 1912 – 7 June 1954) was an English mathematician, computer scientist, logician, cryptanalyst, philosopher, and theoretical biologist. Turing was highly influential in the development of theoretical co ...
, and can therefore not express an arbitrary program.
Instead, arbitrary build steps beyond compiling supported languages can be represented as custom targets.
The Meson language is
strongly typed
In computer programming, one of the many ways that programming languages are colloquially classified is whether the language's type system makes it strongly typed or weakly typed (loosely typed). However, there is no precise technical definition o ...
, such that builtin types like library, executable, string, and lists thereof, are non-interchangeable.
In particular, unlike Make, the list type does not split strings on whitespace.
Thus, whitespace and other characters in filenames and program arguments are handled cleanly.
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.
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.
Meson uses
ccache
Ccache is a software development
Software development is the process of conceiving, specifying, designing, programming, documenting, testing, and bug fixing involved in creating and maintaining applications, frameworks, or other software co ...
automatically if installed. It also detects changes to
symbol table
In computer science, a symbol table is a data structure used by a language translator such as a compiler or interpreter, where each identifier (or symbols), constants, procedures and functions in a program's source code is associated with inf ...
s of
shared libraries
In computer science, a library is a collection of non-volatile resources used by computer programs, often for software development. These may include configuration data, documentation, help data, message templates, pre-written code and su ...
to skip relinking executables against the library when there are no
ABI changes.
Precompiled headers
In computer programming, a precompiled header (PCH) is a ( C or C++) header file that is compiled into an intermediate form that is faster to process for the compiler. Usage of precompiled headers may significantly reduce compilation time, espe ...
are supported, but requires configuration. Debug builds are without optimization by default.
Features
A stated goal of Meson is to facilitate modern development practices. As such, Meson knows how to do
unity builds In software engineering, a unity build (also known as unified build or jumbo build) is a method used in C and C++ software development to speed up the compilation of projects by combining multiple translation units into a single one, usually ach ...
, build with
test coverage,
link time optimization etc without the programmer having to write support for this.
Subprojects
Meson can automatically find and use external dependencies via
pkg-config
pkg-config is a computer program that defines and supports a unified interface for querying installed libraries for the purpose of compiling software that depends on them. It allows programmers and installation scripts to work without explicit kn ...
, CMake, and project-specific lookups, but this only finds installed dependencies, which Meson can not do anything about.
Alternatively, or as a fallback, a dependency can be provided as a ''subproject'' – a Meson project within another, either contained or as a download link, possibly with patches.
This lets Meson resolve
dependency hell Dependency hell is a colloquial term for the frustration of some software users who have installed software packages which have dependencies on specific versions of other software packages.
The dependency issue arises when several packages have ...
for the convenience of casual users who want to compile the project, but may contribute to
software bloat
Software bloat is a process whereby successive versions of a computer program become perceptibly slower, use more memory, disk space or processing power, or have higher hardware requirements than the previous version, while making only dubious us ...
if a common installed dependency could have been used instead. The mode favored by
Linux packagers is therefore fallback.
Meson supports Meson and CMake subprojects. A Meson build file may also refer to the WrapDB service.
;Comparison of dependency resolution use cases in different build systems:
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.
Adopters
GNOME has made it a goal to port its projects to Meson.
As of late 2017,
GNOME Shell
GNOME Shell is the graphical shell of the GNOME desktop environment starting with version 3, which was released on April 6, 2011. It provides basic functions like launching applications, switching between windows and is also a widget engine. ...
itself exclusively requires Meson after abandoning Autotools, and central components like
GTK+
GTK (formerly GIMP ToolKit and GTK+) is a free and open-source cross-platform widget toolkit for creating graphical user interfaces (GUIs). It is licensed under the terms of the GNU Lesser General Public License, allowing both free and prop ...
,
Clutter-GTK,
GLib
GLib is a bundle of three (formerly five) low-level system libraries written in C and developed mainly by GNOME. GLib's code was separated from GTK, so it can be used by software other than GNOME and has been developed in parallel ever si ...
and
GStreamer
GStreamer is a pipeline-based multimedia framework that links together a wide variety of media processing systems to complete complex workflows. For instance, GStreamer can be used to build a system that reads files in one format, processes the ...
can be built with Meson.
Many
freedesktop.org projects have switched to Meson.
Systemd relies on Meson since dropping Autotools in version 234, and also
X.Org and
Mesa
A mesa is an isolated, flat-topped elevation, ridge or hill, which is bounded from all sides by steep escarpments and stands distinctly above a surrounding plain. Mesas characteristically consist of flat-lying soft sedimentary rocks capped by a ...
were ported to Meson.
Meson's support for
Fortran and
Cython
Cython () is a programming language that aims to be a superset of the Python programming language, designed to give C-like performance with code that is written mostly in Python with optional additional C-inspired syntax.
Cython is a compil ...
was improved to help various scientific projects in their switch from to Meson, for example
SciPy.
Meson can also be used as a
PEP517 backend to build Python ''wheels'', via the package.
Other notable projects using Meson include
QEMU
QEMU is a free and open-source emulator (Quick EMUlator). It emulates the machine's processor through dynamic binary translation and provides a set of different hardware and device models for the machine, enabling it to run a variety of g ...
and
Libvirt
libvirt is an open-source API, daemon and management tool for managing platform virtualization. It can be used to manage KVM, Xen, VMware ESXi, QEMU and other virtualization technologies. These APIs are widely used in the orchestration layer ...
; the Meson homepage lists further projects using Meson.
See also
*
References
External links
*
{{DEFAULTSORT:Meson
Build automation
Compiling tools
Free software programmed in Python
Meson build system
Software using the Apache license