Meson is a build system designed to optimize programmer productivity. It aims to do this 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.
The main Meson executable provides many subcommands to access all the functionality.
Using Meson is simple and follows the common two-phase process of most build systems. First you run Meson to configure your build:
meson setup [ options ] [ build directory ] [ source directory ]
Note that the build directory must be different from the source directory. Meson does not support building inside the source directory and attempting to do that leads to an error.
After a successful configuration step you can build the source by running the actual build command in the build directory. The default backend of Meson is Ninja, which can be invoked like this.
ninja [ target ]
You only need to run the Meson command once: when you first configure your build dir. After that you just run the build command. Meson will autodetect changes in your source tree and regenerate all files needed to build the project.
The setup command is the default operation. If no actual command is specified, Meson will assume you meant to do a setup. That means that you can set up a build directory without the setup command like this:
meson [ options ] [ build directory ] [ source directory ]
meson configure provides a way to configure a Meson project from the command line. Its usage is simple:
meson configure [ build directory ] [ options to set ]
If build directory is omitted, the current directory is used instead.
If no parameters are set, meson configure will print the value of all build options to the console.
To set values, use the -D command line argument like this.
meson configure -Dopt1=value1 -Dopt2=value2
Meson introspect is a command designed to make it simple to integrate with other tools, such as IDEs. The output of this command is in JSON.
meson introspect [ build directory ] [ option ]
If build directory is omitted, the current directory is used instead.
meson test is a helper tool for running test suites of projects using Meson. The default way of running tests is to invoke the default build command:
ninja [ test ]
meson test provides a richer set of tools for invoking tests.
meson test automatically rebuilds the necessary targets to run tests when used with the Ninja backend. Upon build failure, meson test will return an exit code of 125. This return code tells git bisect run to skip the current commit. Thus bisecting using git can be done conveniently like this.
git bisect run meson test -C build_dir
Wraptool is a helper utility to manage source dependencies using the online wrapdb service.
meson wrap < command > [ options ]
You should run this command in the top level source directory of your project.
https://wrapdb.mesonbuild.com/