| 1 |
--- |
| 2 |
title: Release 0.49 |
| 3 |
short-description: Release notes for 0.49 |
| 4 |
... |
| 5 |
|
| 6 |
# New features |
| 7 |
|
| 8 |
## Libgcrypt dependency now supports libgcrypt-config |
| 9 |
|
| 10 |
Earlier, `dependency('libgcrypt')` could only detect the library with |
| 11 |
pkg-config files. Now, if pkg-config files are not found, Meson will |
| 12 |
look for `libgcrypt-config` and if it's found, will use that to find |
| 13 |
the library. |
| 14 |
|
| 15 |
## New `section` key for the buildoptions introspection |
| 16 |
|
| 17 |
Meson now has a new `section` key in each build option. This allows |
| 18 |
IDEs to group these options similar to `meson configure`. |
| 19 |
|
| 20 |
The possible values for `section` are: |
| 21 |
|
| 22 |
- core |
| 23 |
- backend |
| 24 |
- base |
| 25 |
- compiler |
| 26 |
- directory |
| 27 |
- user |
| 28 |
- test |
| 29 |
|
| 30 |
## CC-RX compiler for C and CPP |
| 31 |
|
| 32 |
Cross-compilation is now supported for Renesas RX targets with the |
| 33 |
CC-RX compiler. |
| 34 |
|
| 35 |
The environment path should be set properly for the CC-RX compiler |
| 36 |
executables. The `-cpu` option with the appropriate value should be |
| 37 |
mentioned in the cross-file as shown in the snippet below. |
| 38 |
|
| 39 |
```ini |
| 40 |
[properties] |
| 41 |
c_args = ['-cpu=rx600'] |
| 42 |
cpp_args = ['-cpu=rx600'] |
| 43 |
``` |
| 44 |
|
| 45 |
The default extension of the executable output is `.abs`. Other target |
| 46 |
specific arguments to the compiler and linker will need to be added |
| 47 |
explicitly from the |
| 48 |
cross-file(`c_args`/`c_link_args`/`cpp_args`/`cpp_link_args`) or some |
| 49 |
other way. Refer to the CC-RX User's manual for additional compiler |
| 50 |
and linker options. |
| 51 |
|
| 52 |
## CMake `find_package` dependency backend |
| 53 |
|
| 54 |
Meson can now use the CMake `find_package` ecosystem to detect |
| 55 |
dependencies. Both the old-style `<NAME>_LIBRARIES` variables as well |
| 56 |
as imported targets are supported. Meson can automatically guess the |
| 57 |
correct CMake target in most cases but it is also possible to manually |
| 58 |
specify a target with the `modules` property. |
| 59 |
|
| 60 |
```meson |
| 61 |
# Implicitly uses CMake as a fallback and guesses a target |
| 62 |
dep1 = dependency('KF5TextEditor') |
| 63 |
|
| 64 |
# Manually specify one or more CMake targets to use |
| 65 |
dep2 = dependency('ZLIB', method : 'cmake', modules : ['ZLIB::ZLIB']) |
| 66 |
``` |
| 67 |
|
| 68 |
CMake is automatically used after `pkg-config` fails when |
| 69 |
no `method` (or `auto`) was provided in the dependency options. |
| 70 |
|
| 71 |
## New compiler method `get_argument_syntax` |
| 72 |
|
| 73 |
The compiler object now has `get_argument_syntax` method, which |
| 74 |
returns a string value of `gcc`, `msvc`, or an undefined value string |
| 75 |
value. This can be used to determine if a compiler uses gcc syntax |
| 76 |
(`-Wfoo`), msvc syntax (`/w1234`), or some other kind of arguments. |
| 77 |
|
| 78 |
```meson |
| 79 |
cc = meson.get_compiler('c') |
| 80 |
|
| 81 |
if cc.get_argument_syntax() == 'msvc' |
| 82 |
if cc.has_argument('/w1235') |
| 83 |
add_project_arguments('/w1235', language : ['c']) |
| 84 |
endif |
| 85 |
elif cc.get_argument_syntax() == 'gcc' |
| 86 |
if cc.has_argument('-Wfoo') |
| 87 |
add_project_arguments('-Wfoo', language : ['c']) |
| 88 |
endif |
| 89 |
elif cc.get_id() == 'some other compiler' |
| 90 |
add_project_arguments('--error-on-foo', language : ['c']) |
| 91 |
endif |
| 92 |
``` |
| 93 |
|
| 94 |
## Return `Disabler()` instead of not-found object |
| 95 |
|
| 96 |
Functions such as `dependency()`, `find_library()`, `find_program()`, |
| 97 |
and `python.find_installation()` have a new keyword argument: |
| 98 |
`disabler`. When set to `true` those functions return `Disabler()` |
| 99 |
objects instead of not-found objects. |
| 100 |
|
| 101 |
## `introspect --projectinfo` can now be used without configured build directory |
| 102 |
|
| 103 |
This allows IDE integration to get information about the project |
| 104 |
before the user has configured a build directory. |
| 105 |
|
| 106 |
Before you could use `meson.py introspect --projectinfo |
| 107 |
build-directory`. Now you also can use `meson.py introspect |
| 108 |
--projectinfo project-dir/meson.build`. |
| 109 |
|
| 110 |
The output is similar to the output with a build directory but |
| 111 |
additionally also includes information from `introspect |
| 112 |
--buildsystem-files`. |
| 113 |
|
| 114 |
For example `meson.py introspect --projectinfo test\ cases/common/47\ |
| 115 |
subproject\ options/meson.build` This outputs (pretty printed for |
| 116 |
readability): |
| 117 |
|
| 118 |
``` |
| 119 |
{ |
| 120 |
"buildsystem_files": [ |
| 121 |
"meson_options.txt", |
| 122 |
"meson.build" |
| 123 |
], |
| 124 |
"name": "suboptions", |
| 125 |
"version": null, |
| 126 |
"descriptive_name": "suboptions", |
| 127 |
"subprojects": [ |
| 128 |
{ |
| 129 |
"buildsystem_files": [ |
| 130 |
"subprojects/subproject/meson_options.txt", |
| 131 |
"subprojects/subproject/meson.build" |
| 132 |
], |
| 133 |
"name": "subproject", |
| 134 |
"version": "undefined", |
| 135 |
"descriptive_name": "subproject" |
| 136 |
} |
| 137 |
] |
| 138 |
} |
| 139 |
``` |
| 140 |
|
| 141 |
Both usages now include a new `descriptive_name` property which always |
| 142 |
shows the name set in the project. |
| 143 |
|
| 144 |
## Can specify keyword arguments with a dictionary |
| 145 |
|
| 146 |
You can now specify keyword arguments for any function and method call |
| 147 |
with the `kwargs` keyword argument. This is perhaps best described |
| 148 |
with an example: |
| 149 |
|
| 150 |
```meson |
| 151 |
options = {'include_directories': include_directories('inc')} |
| 152 |
|
| 153 |
... |
| 154 |
|
| 155 |
executable(... |
| 156 |
kwargs: options) |
| 157 |
``` |
| 158 |
|
| 159 |
The above code is identical to this: |
| 160 |
|
| 161 |
```meson |
| 162 |
executable(... |
| 163 |
include_directories: include_directories('inc')) |
| 164 |
``` |
| 165 |
|
| 166 |
That is, Meson will expand the dictionary given to `kwargs` as if the |
| 167 |
entries in it had been given as keyword arguments directly. |
| 168 |
|
| 169 |
Note that any individual argument can be specified either directly or |
| 170 |
with the `kwarg` dict but not both. If a key is specified twice, it |
| 171 |
is a hard error. |
| 172 |
|
| 173 |
## Manpages are no longer compressed implicitly |
| 174 |
|
| 175 |
Earlier, the `install_man` command has automatically compressed |
| 176 |
installed manpages into `.gz` format. This collided with manpage |
| 177 |
compression hooks already used by various distributions. Now, manpages |
| 178 |
are installed uncompressed and distributors are expected to handle |
| 179 |
compressing them according to their own compression preferences. |
| 180 |
|
| 181 |
## Native config files |
| 182 |
|
| 183 |
Native files (`--native-file`) are the counterpart to cross files |
| 184 |
(`--cross-file`), and allow specifying information about the build |
| 185 |
machine, both when cross compiling and when not. |
| 186 |
|
| 187 |
Currently the native files only allow specifying the names of |
| 188 |
binaries, similar to the cross file, for example: |
| 189 |
|
| 190 |
```ini |
| 191 |
[binaries] |
| 192 |
llvm-config = "/opt/llvm-custom/bin/llvm-config" |
| 193 |
``` |
| 194 |
|
| 195 |
Will override the llvm-config used for *native* binaries. Targets for |
| 196 |
the host machine will continue to use the cross file. |
| 197 |
|
| 198 |
## Foreach `break` and `continue` |
| 199 |
|
| 200 |
`break` and `continue` keywords can be used inside foreach loops. |
| 201 |
|
| 202 |
```meson |
| 203 |
items = ['a', 'continue', 'b', 'break', 'c'] |
| 204 |
result = [] |
| 205 |
foreach i : items |
| 206 |
if i == 'continue' |
| 207 |
continue |
| 208 |
elif i == 'break' |
| 209 |
break |
| 210 |
endif |
| 211 |
result += i |
| 212 |
endforeach |
| 213 |
# result is ['a', 'b'] |
| 214 |
``` |
| 215 |
|
| 216 |
You can check if an array contains an element like this: |
| 217 |
```meson |
| 218 |
my_array = [1, 2] |
| 219 |
if 1 in my_array |
| 220 |
# This condition is true |
| 221 |
endif |
| 222 |
if 1 not in my_array |
| 223 |
# This condition is false |
| 224 |
endif |
| 225 |
``` |
| 226 |
|
| 227 |
You can check if a dictionary contains a key like this: |
| 228 |
```meson |
| 229 |
my_dict = {'foo': 42, 'foo': 43} |
| 230 |
if 'foo' in my_dict |
| 231 |
# This condition is true |
| 232 |
endif |
| 233 |
if 42 in my_dict |
| 234 |
# This condition is false |
| 235 |
endif |
| 236 |
if 'foo' not in my_dict |
| 237 |
# This condition is false |
| 238 |
endif |
| 239 |
``` |
| 240 |
|
| 241 |
## Joining paths with / |
| 242 |
|
| 243 |
For clarity and conciseness, we recommend using the `/` operator to separate |
| 244 |
path elements: |
| 245 |
|
| 246 |
```meson |
| 247 |
joined = 'foo' / 'bar' |
| 248 |
``` |
| 249 |
|
| 250 |
Before Meson 0.49, joining path elements was done with the legacy |
| 251 |
`join_paths` function, but the `/` syntax above is now recommended. |
| 252 |
|
| 253 |
```meson |
| 254 |
joined = join_paths('foo', 'bar') |
| 255 |
``` |
| 256 |
|
| 257 |
This only works for strings. |
| 258 |
|
| 259 |
## Position-independent executables |
| 260 |
|
| 261 |
When `b_pie` option, or `executable()`'s `pie` keyword argument is set |
| 262 |
to `true`, position-independent executables are built. All their |
| 263 |
objects are built with `-fPIE` and the executable is linked with |
| 264 |
`-pie`. Any static library they link must be built with `pic` set to |
| 265 |
`true` (see `b_staticpic` option). |
| 266 |
|
| 267 |
## Deprecation warning in pkg-config generator |
| 268 |
|
| 269 |
All libraries passed to the `libraries` keyword argument of the |
| 270 |
`generate()` method used to be associated with that generated |
| 271 |
pkg-config file. That means that any subsequent call to `generate()` |
| 272 |
where those libraries appear would add the filebase of the |
| 273 |
`generate()` that first contained them into `Requires:` or |
| 274 |
`Requires.private:` field instead of adding an `-l` to `Libs:` or |
| 275 |
`Libs.private:`. |
| 276 |
|
| 277 |
This behaviour is now deprecated. The library that should be |
| 278 |
associated with the generated pkg-config file should be passed as |
| 279 |
first positional argument instead of in the `libraries` keyword |
| 280 |
argument. The previous behaviour is maintained but prints a |
| 281 |
deprecation warning and support for this will be removed in a future |
| 282 |
Meson release. If you cannot create the needed pkg-config file |
| 283 |
without this warning, please file an issue with as much details as |
| 284 |
possible about the situation. |
| 285 |
|
| 286 |
For example this sample will write `Requires: liba` into `libb.pc` but |
| 287 |
print a deprecation warning: |
| 288 |
|
| 289 |
```meson |
| 290 |
liba = library(...) |
| 291 |
pkg.generate(libraries : liba) |
| 292 |
|
| 293 |
libb = library(...) |
| 294 |
pkg.generate(libraries : [liba, libb]) |
| 295 |
``` |
| 296 |
|
| 297 |
It can be fixed by passing `liba` as first positional argument:: |
| 298 |
```meson |
| 299 |
liba = library(...) |
| 300 |
pkg.generate(liba) |
| 301 |
|
| 302 |
libb = library(...) |
| 303 |
pkg.generate(libb, libraries : [liba]) |
| 304 |
``` |
| 305 |
|
| 306 |
## Subprojects download, checkout, update command-line |
| 307 |
|
| 308 |
New command-line tool has been added to manage subprojects: |
| 309 |
|
| 310 |
- `meson subprojects download` to download all subprojects that have a wrap file. |
| 311 |
- `meson subprojects update` to update all subprojects to latest version. |
| 312 |
- `meson subprojects checkout` to checkout or create a branch in all git subprojects. |
| 313 |
|
| 314 |
## New keyword argument `is_default` to `add_test_setup()` |
| 315 |
|
| 316 |
The keyword argument `is_default` may be used to set whether the test |
| 317 |
setup should be used by default whenever `meson test` is run without |
| 318 |
the `--setup` option. |
| 319 |
|
| 320 |
```meson |
| 321 |
add_test_setup('default', is_default: true, env: 'G_SLICE=debug-blocks') |
| 322 |
add_test_setup('valgrind', env: 'G_SLICE=always-malloc', ...) |
| 323 |
test('mytest', exe) |
| 324 |
``` |
| 325 |
|
| 326 |
For the example above, running `meson test` and `meson test |
| 327 |
--setup=default` is now equivalent. |