| 1 |
--- |
| 2 |
title: Release 0.40 |
| 3 |
short-description: Release notes for 0.40 |
| 4 |
... |
| 5 |
|
| 6 |
# New features |
| 7 |
|
| 8 |
## Outputs of generators can be used in custom targets in the VS backend |
| 9 |
|
| 10 |
This has been possible with the Ninja backend for a long time but now |
| 11 |
the Visual Studio backend works too. |
| 12 |
|
| 13 |
## `compute_int` method in the compiler objects |
| 14 |
|
| 15 |
This method can be used to evaluate the value of an expression. As an |
| 16 |
example: |
| 17 |
|
| 18 |
```meson |
| 19 |
cc = meson.get_compiler('c') |
| 20 |
two = cc.compute_int('1 + 1') # A very slow way of adding two numbers. |
| 21 |
``` |
| 22 |
|
| 23 |
## Visual Studio 2017 support |
| 24 |
|
| 25 |
There is now a VS2017 backend (`--backend=vs2017`) as well as a |
| 26 |
generic VS backend (`--backend=vs`) that autodetects the currently |
| 27 |
active VS version. |
| 28 |
|
| 29 |
## Automatic initialization of subprojects that are git submodules |
| 30 |
|
| 31 |
If you have a directory inside your subprojects directory (usually |
| 32 |
`subprojects/`) that is a git submodule, Meson will automatically |
| 33 |
initialize it if your build files refer to it. This will be done |
| 34 |
without needing a wrap file since git contains all the information |
| 35 |
needed. |
| 36 |
|
| 37 |
## No download mode for wraps |
| 38 |
|
| 39 |
Added a new option `wrap-mode` that can be toggled to prevent Meson |
| 40 |
from downloading dependency projects. Attempting to do so will cause |
| 41 |
an error. This is useful for distro packagers and other cases where |
| 42 |
you must explicitly enforce that nothing is downloaded from the net |
| 43 |
during configuration or build. |
| 44 |
|
| 45 |
## Overriding options per target |
| 46 |
|
| 47 |
Build targets got a new keyword argument `override_options` that can |
| 48 |
be used to override system options. As an example if you have a target |
| 49 |
that you know can't be built with `-Werror` enabled you can override |
| 50 |
the value of the option like this: |
| 51 |
|
| 52 |
```meson |
| 53 |
executable('foo', 'foo.c', override_options : ['werror=false']) |
| 54 |
``` |
| 55 |
|
| 56 |
Note that this does not affect project options, only those options |
| 57 |
that come from Meson (language standards, unity builds etc). |
| 58 |
|
| 59 |
## Compiler object get define |
| 60 |
|
| 61 |
Compiler objects got a new method `get_define()` that returns the |
| 62 |
given preprocessor symbol as a string. |
| 63 |
|
| 64 |
```meson |
| 65 |
cc = meson.get_compiler('c') |
| 66 |
one = cc.get_define('__linux__') # returns '1' on Linux hosts |
| 67 |
``` |
| 68 |
|
| 69 |
## Cygwin support |
| 70 |
|
| 71 |
Meson now works under Cygwin and we have added it to our CI test |
| 72 |
matrix. |
| 73 |
|
| 74 |
## Multiple install directories |
| 75 |
|
| 76 |
Custom targets can produce many output files. Previously it was only |
| 77 |
possible to install all of them in the same directory, but now you can |
| 78 |
install each output in its own directory like this: |
| 79 |
|
| 80 |
```meson |
| 81 |
custom_target('two_out', |
| 82 |
output : ['diff.h', 'diff.sh'], |
| 83 |
command : [creator, '@OUTDIR@'], |
| 84 |
install : true, |
| 85 |
install_dir : ['dir1', 'dir2']) |
| 86 |
``` |
| 87 |
|
| 88 |
For backwards compatibility and for conciseness, if you only specify |
| 89 |
one directory all outputs will be installed into it. |
| 90 |
|
| 91 |
The same feature is also available for Vala build targets. For |
| 92 |
instance, to install a shared library built by valac, the generated |
| 93 |
header, and the generated VAPI (respectively) into the default |
| 94 |
locations, you can do: |
| 95 |
|
| 96 |
```meson |
| 97 |
shared_library('valalib', 'mylib.vala', |
| 98 |
install : true, |
| 99 |
install_dir : [true, true, true]) |
| 100 |
``` |
| 101 |
|
| 102 |
To install any of the three in a custom directory, just pass it as a |
| 103 |
string instead of `true`. To not install it, pass `false`. You can |
| 104 |
also pass a single string (as before) and it will cause only the |
| 105 |
library to be installed, so this is a backwards-compatible change. |
| 106 |
|
| 107 |
## Can specify method of obtaining dependencies |
| 108 |
|
| 109 |
Some dependencies have many ways of being provided. As an example Qt |
| 110 |
can either be detected via `pkg-config` or `qmake`. Until now Meson |
| 111 |
has had a heuristic for selecting which method to choose but sometimes |
| 112 |
it does the wrong thing. This can now be overridden with the `method` |
| 113 |
keyword like this: |
| 114 |
|
| 115 |
```meson |
| 116 |
qt5_dep = dependency('qt5', modules : 'core', method : 'qmake') |
| 117 |
``` |
| 118 |
|
| 119 |
## Link whole contents of static libraries |
| 120 |
|
| 121 |
The default behavior of static libraries is to discard all symbols |
| 122 |
that are not directly referenced. This may lead to exported |
| 123 |
symbols being lost. Most compilers support "whole archive" linking |
| 124 |
that includes all symbols and code of a given static library. This is |
| 125 |
exposed with the `link_whole` keyword. |
| 126 |
|
| 127 |
```meson |
| 128 |
shared_library('foo', 'foo.c', link_whole : some_static_library) |
| 129 |
``` |
| 130 |
|
| 131 |
Note that Visual Studio compilers only support this functionality on |
| 132 |
VS 2015 and newer. |
| 133 |
|
| 134 |
## Unity builds only for subprojects |
| 135 |
|
| 136 |
Up until now unity builds were either done for every target or none of |
| 137 |
them. Now unity builds can be specified to be enabled only for |
| 138 |
subprojects, which change seldom, and not for the master project, |
| 139 |
which changes a lot. This is enabled by setting the `unity` option to |
| 140 |
`subprojects`. |
| 141 |
|
| 142 |
## Running `mesonintrospect` from scripts |
| 143 |
|
| 144 |
Meson now sets the `MESONINTROSPECT` environment variable in addition |
| 145 |
to `MESON_SOURCE_ROOT` and other variables when running scripts. It is |
| 146 |
guaranteed to point to the correct `mesonintrospect` script, which is |
| 147 |
important when running Meson uninstalled from git or when your `PATH`s |
| 148 |
may not be set up correctly. |
| 149 |
|
| 150 |
Specifically, the following Meson functions will set it: |
| 151 |
`meson.add_install_script()`, `meson.add_postconf_script()`, |
| 152 |
`run_command()`, `run_target()`. |