@ -10,7 +10,7 @@ The basic tool for this is a script called `mesonintrospect.py`. Some distro pac
The first thing to do when setting up a Meson project in an IDE is to select the source and build directories. For this example we assume that the source resides in an Eclipse-like directory called `workspace/project` and the build tree is nested inside it as `workspace/project/build`. First we initialise Meson by running the following command in the source directory.
The first thing to do when setting up a Meson project in an IDE is to select the source and build directories. For this example we assume that the source resides in an Eclipse-like directory called `workspace/project` and the build tree is nested inside it as `workspace/project/build`. First we initialise Meson by running the following command in the source directory.
meson build
meson builddir
For the remainder of the document we assume that all commands are executed inside the build directory unless otherwise specified.
For the remainder of the document we assume that all commands are executed inside the build directory unless otherwise specified.
@ -36,7 +36,7 @@ The next thing to display is the list of options that can be set. These include
To set the options, use the `mesonconf.py` binary.
To set the options, use the `mesonconf.py` binary.
Compilation and unit tests are done as usual by running the `ninja` and `ninja test` commands. A JSON formatted result log can be found in `workspace/project/build/meson-logs/testlog.json`.
Compilation and unit tests are done as usual by running the `ninja` and `ninja test` commands. A JSON formatted result log can be found in `workspace/project/builddir/meson-logs/testlog.json`.
When these tests fail, the user probably wants to run the failing test in a debugger. To make this as integrated as possible, extract the test test setups with this command.
When these tests fail, the user probably wants to run the failing test in a debugger. To make this as integrated as possible, extract the test test setups with this command.
@ -78,7 +78,7 @@ At this point we can return to the pkg-config generator line. All shared librari
With these four files we are done. To configure, build and run the test suite, we just need to execute the following commands (starting at source tree root directory).
With these four files we are done. To configure, build and run the test suite, we just need to execute the following commands (starting at source tree root directory).
The command line switch `--buildtype=plain` tells Meson not to add its own flags to the command line. This gives the packager total control on used flags.
The command line switch `--buildtype=plain` tells Meson not to add its own flags to the command line. This gives the packager total control on used flags.
@ -15,8 +15,8 @@ Let us assume that we have a source tree that has a Meson build system. This mea
cd /path/to/source/root
cd /path/to/source/root
mkdir build
mkdir builddir
cd build
cd builddir
meson ..
meson ..
First we create a directory to hold all files generated during the build. Then we go into it and invoke Meson, giving it the location of the source root.
First we create a directory to hold all files generated during the build. Then we go into it and invoke Meson, giving it the location of the source root.
That is all. We are now ready to build our application. First we need to initialise the build by going into the source directory and issuing the following commands.
That is all. We are now ready to build our application. First we need to initialise the build by going into the source directory and issuing the following commands.
```console
```console
$ meson build
$ meson builddir
```
```
We create a separate build directory to hold all of the compiler output. Meson is different from some other build systems in that it does not permit in-source builds. You must always create a separate build directory. Common convention is to put the default build directory in a subdirectory of your toplevel source directory.
We create a separate build directory to hold all of the compiler output. Meson is different from some other build systems in that it does not permit in-source builds. You must always create a separate build directory. Common convention is to put the default build directory in a subdirectory of your toplevel source directory.
@ -40,7 +40,7 @@ When Meson is run it prints the following output.
The Meson build system
The Meson build system
version: 0.13.0-research
version: 0.13.0-research
Source dir: /home/jpakkane/mesontutorial
Source dir: /home/jpakkane/mesontutorial
Build dir: /home/jpakkane/mesontutorial/build
Build dir: /home/jpakkane/mesontutorial/builddir
Build type: native build
Build type: native build
Project name is "tutorial".
Project name is "tutorial".
Using native c compiler "ccache cc". (gcc 4.8.2)
Using native c compiler "ccache cc". (gcc 4.8.2)
@ -49,7 +49,7 @@ When Meson is run it prints the following output.
Now we are ready to build our code.
Now we are ready to build our code.
```
```
$ cd build
$ cd builddir
$ ninja
$ ninja
```
```
@ -102,7 +102,7 @@ Once you have set up your build directory the first time, you don't ever need to
@ -14,8 +14,8 @@ Since a build directory is fully self contained and treats the source tree as a
The first thing to do is to set up the default build, that is, the one we are going to use over 90% of the time. In this we use the system compiler and build with debug enabled and no optimizations so it builds as fast as possible. This is the default project type for Meson, so setting it up is simple.
The first thing to do is to set up the default build, that is, the one we are going to use over 90% of the time. In this we use the system compiler and build with debug enabled and no optimizations so it builds as fast as possible. This is the default project type for Meson, so setting it up is simple.
mkdir build
mkdir builddir
meson build
meson builddir
Another common setup is to build with debug and optimizations to, for example, run performance tests. Setting this up is just as simple.
Another common setup is to build with debug and optimizations to, for example, run performance tests. Setting this up is just as simple.
If you wish to use the Ninja backend instead of vs2015, pass `--backend ninja`. At the time of writing the Ninja backend is more mature than the VS backend so you might want to use it for serious work.
If you wish to use the Ninja backend instead of vs2015, pass `--backend ninja`. At the time of writing the Ninja backend is more mature than the VS backend so you might want to use it for serious work.