aboutsummaryrefslogtreecommitdiff
path: root/docs/markdown/Release-notes-for-0.40.0.md
blob: 9ba483947208398430dae29d011144139e598ca9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
---
title: Release 0.40
short-description: Release notes for 0.40
...

# New features

## Outputs of generators can be used in custom targets in the VS backend

This has been possible with the Ninja backend for a long time but now
the Visual Studio backend works too.

## `compute_int` method in the compiler objects

This method can be used to evaluate the value of an expression. As an
example:

```meson
cc = meson.get_compiler('c')
two = cc.compute_int('1 + 1') # A very slow way of adding two numbers.
```

## Visual Studio 2017 support

There is now a VS2017 backend (`--backend=vs2017`) as well as a
generic VS backend (`--backend=vs`) that autodetects the currently
active VS version.

## Automatic initialization of subprojects that are git submodules

If you have a directory inside your subprojects directory (usually
`subprojects/`) that is a git submodule, meson will automatically
initialize it if your build files refer to it. This will be done
without needing a wrap file since git contains all the information
needed.

## No download mode for wraps

Added a new option `wrap-mode` that can be toggled to prevent Meson
from downloading dependency projects. Attempting to do so will cause
an error. This is useful for distro packagers and other cases where
you must explicitly enforce that nothing is downloaded from the net
during configuration or build.

## Overriding options per target

Build targets got a new keyword argument `override_options` that can
be used to override system options. As an example if you have a target
that you know can't be built with `-Werror` enabled you can override
the value of the option like this:

```meson
executable('foo', 'foo.c', override_options : ['werror=false'])
```

Note that this does not affect project options, only those options
that come from Meson (language standards, unity builds etc).

## Compiler object get define

Compiler objects got a new method `get_define()` that returns the
given preprocessor symbol as a string.

```meson
cc = meson.get_compiler('c')
one = cc.get_define('__linux__') # returns '1' on Linux hosts
```

## Cygwin support

Meson now works under Cygwin and we have added it to our CI test
matrix.

## Multiple install directories

Custom targets can produce many output files. Previously it was only
possible to install all of them in the same directory, but now you can
install each output in its own directory like this:

```meson
custom_target('two_out',
  output : ['diff.h', 'diff.sh'],
  command : [creator, '@OUTDIR@'],
  install : true,
  install_dir : ['dir1', 'dir2'])
```

For backwards compatibility and for conciseness, if you only specify
one directory all outputs will be installed into it.

The same feature is also available for Vala build targets. For
instance, to install a shared library built by valac, the generated
header, and the generated VAPI (respectively) into the default
locations, you can do:

```meson
shared_library('valalib', 'mylib.vala',
  install : true,
  install_dir : [true, true, true])
```

To install any of the three in a custom directory, just pass it as a
string instead of `true`. To not install it, pass `false`. You can
also pass a single string (as before) and it will cause only the
library to be installed, so this is a backwards-compatible change.

## Can specify method of obtaining dependencies

Some dependencies have many ways of being provided. As an example Qt
can either be detected via `pkg-config` or `qmake`. Until now Meson
has had a heuristic for selecting which method to choose but sometimes
it does the wrong thing. This can now be overridden with the `method`
keyword like this:

```meson
qt5_dep = dependency('qt5', modules : 'core', method : 'qmake')
```

## Link whole contents of static libraries

The default behavior of static libraries is to discard all symbols
that are not not directly referenced. This may lead to exported
symbols being lost. Most compilers support "whole archive" linking
that includes all symbols and code of a given static library. This is
exposed with the `link_whole` keyword.

```meson
shared_library('foo', 'foo.c', link_whole : some_static_library)
```

Note that Visual Studio compilers only support this functionality on
VS 2015 and newer.

## Unity builds only for subprojects

Up until now unity builds were either done for every target or none of
them. Now unity builds can be specified to be enabled only for
subprojects, which change seldom, and not for the master project,
which changes a lot. This is enabled by setting the `unity` option to
`subprojects`.

## Running `mesonintrospect` from scripts

Meson now sets the `MESONINTROSPECT` environment variable in addition
to `MESON_SOURCE_ROOT` and other variables when running scripts. It is
guaranteed to point to the correct `mesonintrospect` script, which is
important when running meson uninstalled from git or when your `PATH`s
may not be set up correctly.

Specifically, the following meson functions will set it:
`meson.add_install_script()`, `meson.add_postconf_script()`,
`run_command()`, `run_target()`.