| 1 |
--- |
| 2 |
title: Release 0.60.0 |
| 3 |
short-description: Release notes for 0.60.0 |
| 4 |
... |
| 5 |
|
| 6 |
# New features |
| 7 |
|
| 8 |
## `run_target` can now be used as a dependency |
| 9 |
|
| 10 |
A `run_target()` can now be saved in a variable and reused as a dependency in |
| 11 |
an `alias_target()`. This can be used to create custom alias rules that ensure |
| 12 |
multiple other targets are run, even if those targets don't produce output |
| 13 |
files. |
| 14 |
|
| 15 |
For example: |
| 16 |
|
| 17 |
``` |
| 18 |
i18n = import('i18n') |
| 19 |
|
| 20 |
all_pot_targets = [] |
| 21 |
|
| 22 |
foo_i18n = i18n.gettext('foo') |
| 23 |
|
| 24 |
all_pot_targets += foo_i18n[1] |
| 25 |
|
| 26 |
alias_target('all-pot', all_pot_targets) |
| 27 |
``` |
| 28 |
|
| 29 |
## The Python Modules dependency method no longer accepts positional arguments |
| 30 |
|
| 31 |
Previously these were ignored with a warning, now they're a hard error. |
| 32 |
|
| 33 |
## `unset_variable()` |
| 34 |
|
| 35 |
`unset_variable()` can be used to unset a variable. Reading a variable after |
| 36 |
calling `unset_variable()` will raise an exception unless the variable is set |
| 37 |
again. |
| 38 |
|
| 39 |
```meson |
| 40 |
# tests/meson.build |
| 41 |
tests = ['test1', 'test2'] |
| 42 |
|
| 43 |
# ... |
| 44 |
|
| 45 |
unset_variable('tests') |
| 46 |
|
| 47 |
# tests is no longer usable until it is set again |
| 48 |
``` |
| 49 |
|
| 50 |
## Override python installation paths |
| 51 |
|
| 52 |
The `python` module now has options to control where modules are installed: |
| 53 |
- python.platlibdir: Directory for site-specific, platform-specific files. |
| 54 |
- python.purelibdir: Directory for site-specific, non-platform-specific files. |
| 55 |
|
| 56 |
Those options are used by python module methods `python.install_sources()` and |
| 57 |
`python.get_install_dir()`. By default Meson tries to detect the correct installation |
| 58 |
path, but make them relative to the installation `prefix`, which will often result |
| 59 |
in installed python modules to not be found by the interpreter unless `prefix` |
| 60 |
is `/usr` on Linux, or for example `C:\Python39` on Windows. These new options |
| 61 |
can be absolute paths outside of `prefix`. |
| 62 |
|
| 63 |
## New `subprojects packagefiles` subcommand |
| 64 |
|
| 65 |
It is now possible to re-apply `meson.build` overlays (`patch_filename` or |
| 66 |
`patch_directory` in the wrap ini file) after a subproject was downloaded and |
| 67 |
set up, via `meson subprojects packagefiles --apply <wrap-name>`. |
| 68 |
|
| 69 |
It is also possible for `patch_directory` overlays in a `[wrap-file]`, to copy |
| 70 |
the packagefiles out of the subproject and back into `packagefiles/<patch_directory>/` |
| 71 |
via `meson subprojects packagefiles --save <wrap-name>`. This is useful for |
| 72 |
testing an edit in the subproject and then saving it back to the overlay which |
| 73 |
is checked into git. |
| 74 |
|
| 75 |
## Deprecated project options |
| 76 |
|
| 77 |
Project options declared in `meson_options.txt` can now be marked as deprecated |
| 78 |
and Meson will warn when user sets a value to it. It is also possible to deprecate |
| 79 |
only some of the choices, and map deprecated values to a new value. |
| 80 |
|
| 81 |
```meson |
| 82 |
# Option fully deprecated, it warns when any value is set. |
| 83 |
option('o1', type: 'boolean', deprecated: true) |
| 84 |
|
| 85 |
# One of the choices is deprecated, it warns only when 'a' is in the list of values. |
| 86 |
option('o2', type: 'array', choices: ['a', 'b'], deprecated: ['a']) |
| 87 |
|
| 88 |
# One of the choices is deprecated, it warns only when 'a' is in the list of values |
| 89 |
# and replace it by 'c'. |
| 90 |
option('o3', type: 'array', choices: ['a', 'b', 'c'], deprecated: {'a': 'c'}) |
| 91 |
|
| 92 |
# A boolean option has been replaced by a feature, old true/false values are remapped. |
| 93 |
option('o4', type: 'feature', deprecated: {'true': 'enabled', 'false': 'disabled'}) |
| 94 |
|
| 95 |
# A feature option has been replaced by a boolean, enabled/disabled/auto values are remapped. |
| 96 |
option('o5', type: 'boolean', deprecated: {'enabled': 'true', 'disabled': 'false', 'auto': 'false'}) |
| 97 |
``` |
| 98 |
|
| 99 |
## More efficient static linking of uninstalled libraries |
| 100 |
|
| 101 |
**Note**: This change had to be reverted in 0.60.1 because it caused regressions. |
| 102 |
New API will likely be introduced in 0.61.0 to have better control whether or |
| 103 |
not to create thin archive. |
| 104 |
|
| 105 |
A somewhat common use case of [[static_library]] is to create uninstalled |
| 106 |
internal convenience libraries which are solely meant to be linked to other |
| 107 |
targets. Some build systems call these "object libraries". Meson's |
| 108 |
implementation does always create a static archive. |
| 109 |
|
| 110 |
This will now check to see if the static linker supports "thin archives" |
| 111 |
(archives which do not contain the actual object code, only references to their |
| 112 |
location on disk) and if so, use them to minimize space usage and speed up |
| 113 |
linking. |
| 114 |
|
| 115 |
## gnome.yelp variadic argument deprecation |
| 116 |
|
| 117 |
`gnome.yelp` previously allowed sources to be passed either as variadic |
| 118 |
arguments or as a keyword argument. If the keyword argument was given the |
| 119 |
variadic arguments would be silently ignored. This has changed in 0.60.0, the |
| 120 |
variadic form has been deprecated, and a warning is printed if both are given. |
| 121 |
|
| 122 |
## `static` keyword argument to `meson.override_dependency()` |
| 123 |
|
| 124 |
It is now possible to override shared and/or static dependencies separately. |
| 125 |
When the `static` keyword argument is not specified in `dependency()`, the first |
| 126 |
override will be used (`static_dep` in the example below). |
| 127 |
```meson |
| 128 |
static_lib = static_library() |
| 129 |
static_dep = declare_dependency(link_with: static_lib) |
| 130 |
meson.override_dependency('foo', static_dep, static: true) |
| 131 |
|
| 132 |
shared_lib = shared_library() |
| 133 |
shared_dep = declare_dependency(link_with: shared_lib) |
| 134 |
meson.override_dependency('foo', shared_dep, static: false) |
| 135 |
|
| 136 |
# Returns static_dep |
| 137 |
dependency('foo') |
| 138 |
|
| 139 |
# Returns static_dep |
| 140 |
dependency('foo', static: true) |
| 141 |
|
| 142 |
# Returns shared_dep |
| 143 |
dependency('foo', static: false) |
| 144 |
``` |
| 145 |
|
| 146 |
When the `static` keyword argument is not specified in `meson.override_dependency()`, |
| 147 |
the dependency is assumed to follow the value of `default_library` option. |
| 148 |
```meson |
| 149 |
dep = declare_dependency(...) |
| 150 |
meson.override_dependency('foo', dep) |
| 151 |
|
| 152 |
# Always works |
| 153 |
dependency('foo') |
| 154 |
|
| 155 |
# Works only if default_library is 'static' or 'both' |
| 156 |
dependency('foo', static: true) |
| 157 |
|
| 158 |
# Works only if default_library is 'shared' or 'both' |
| 159 |
dependency('foo', static: false) |
| 160 |
``` |
| 161 |
|
| 162 |
## `dependency()` sets `default_library` on fallback subproject |
| 163 |
|
| 164 |
When the `static` keyword argument is set but `default_library` is missing in |
| 165 |
`default_options`, `dependency()` will set it when configuring fallback |
| 166 |
subproject. `dependency('foo', static: true)` is now equivalent to |
| 167 |
`dependency('foo', static: true, default_options: ['default_library=static'])`. |
| 168 |
|
| 169 |
## install_emptydir function |
| 170 |
|
| 171 |
It is now possible to define a directory which will be created during |
| 172 |
installation, without creating it as a side effect of installing files into it. |
| 173 |
This replaces custom `meson.add_install_script()` routines. For example: |
| 174 |
|
| 175 |
```meson |
| 176 |
meson.add_install_script('sh', '-c', 'mkdir -p "$DESTDIR/@0@"'.format(path)) |
| 177 |
``` |
| 178 |
|
| 179 |
can be replaced by: |
| 180 |
|
| 181 |
```meson |
| 182 |
install_emptydir(path) |
| 183 |
``` |
| 184 |
|
| 185 |
and as a bonus this works reliably on Windows, prints a sensible progress |
| 186 |
message, will be uninstalled by `ninja uninstall`, etc. |
| 187 |
|
| 188 |
## Cython can now transpile to C++ as an intermediate language |
| 189 |
|
| 190 |
Built-in cython support currently only allows C as an intermediate language, now |
| 191 |
C++ is also allowed. This can be set via the `cython_language` option, either on |
| 192 |
the command line, or in the meson.build files. |
| 193 |
|
| 194 |
```meson |
| 195 |
project( |
| 196 |
'myproject', |
| 197 |
'cython', |
| 198 |
default_options : ['cython_language=cpp'], |
| 199 |
) |
| 200 |
``` |
| 201 |
|
| 202 |
or on a per target basis with: |
| 203 |
```meson |
| 204 |
python.extension_module( |
| 205 |
'mod', |
| 206 |
'mod.pyx', |
| 207 |
override_options : ['cython_language=cpp'], |
| 208 |
) |
| 209 |
``` |
| 210 |
|
| 211 |
## New custom dependency for iconv |
| 212 |
|
| 213 |
``` |
| 214 |
dependency('iconv') |
| 215 |
``` |
| 216 |
|
| 217 |
will now check for the functionality of libiconv.so, but first check if it is |
| 218 |
provided in the libc (for example in glibc or musl libc on Linux). |
| 219 |
|
| 220 |
## Unknown options are now always fatal |
| 221 |
|
| 222 |
Passing unknown options to "meson setup" or "meson configure" is now |
| 223 |
always fatal. That is, Meson will exit with an error code if this |
| 224 |
happens. Previous Meson versions only showed a warning message. |
| 225 |
|
| 226 |
## Install DESTDIR relative to build directory |
| 227 |
|
| 228 |
When `DESTDIR` environment or `meson install --destdir` option is a relative path, |
| 229 |
it is now assumed to be relative to the build directory. An absolute path will be |
| 230 |
set into environment when executing scripts. It was undefined behavior in prior |
| 231 |
Meson versions but was working as relative to build directory most of the time. |
| 232 |
|
| 233 |
## Java Module |
| 234 |
|
| 235 |
The Java module has been added to Meson. The Java module allows users to |
| 236 |
generate native header files without needing to use a `custom_target()`. |
| 237 |
|
| 238 |
```meson |
| 239 |
jmod = import('java') |
| 240 |
|
| 241 |
native_header = jmod.generate_native_header('File.java', package: 'com.mesonbuild') |
| 242 |
native_header_includes = include_directories('.') |
| 243 |
|
| 244 |
jdkjava = shared_module( |
| 245 |
'jdkjava', |
| 246 |
[native_header_includes, other_sources], |
| 247 |
dependencies : [jdk], |
| 248 |
include_directories : [native_header_includes] |
| 249 |
) |
| 250 |
``` |
| 251 |
|
| 252 |
## Link tests can use sources for a different compiler |
| 253 |
|
| 254 |
Usually, the `links` method of the compiler object uses a single program |
| 255 |
invocation to do both compilation and linking. Starting with this version, |
| 256 |
whenever the argument to `links` is a file, Meson will check if the file |
| 257 |
suffix matches the compiler object's language. If they do not match, |
| 258 |
as in the following case: |
| 259 |
|
| 260 |
``` |
| 261 |
cxx = meson.get_compiler('cpp') |
| 262 |
cxx.links(files('test.c')) |
| 263 |
``` |
| 264 |
|
| 265 |
then Meson will separate compilation and linking. In the above example |
| 266 |
`test.c` will be compiled with a C compiler and the resulting object file |
| 267 |
will be linked with a C++ compiler. This makes it possible to detect |
| 268 |
misconfigurations of the compilation environment, for example when the |
| 269 |
C++ runtime is not compatible with the one expected by the C compiler. |
| 270 |
|
| 271 |
For this reason, passing file arguments with an unrecognized suffix to |
| 272 |
`links` will cause a warning. |
| 273 |
|
| 274 |
## Relax restrictions of `str.join()` |
| 275 |
|
| 276 |
Since 0.60.0, the [[str.join]] method can take an arbitrary number of arguments |
| 277 |
instead of just one list. Additionally, all lists past to [[str.join]] will now |
| 278 |
be flattened. |
| 279 |
|
| 280 |
## Improvements for the Rustc compiler |
| 281 |
|
| 282 |
- Werror now works, this set's `-D warnings`, which will cause rustc to error |
| 283 |
for every warning not explicitly disabled |
| 284 |
- warning levels have been implemented |
| 285 |
- support for meson's pic has been enabled |
| 286 |
|
| 287 |
## The qt modules now accept generated outputs as inputs for qt.compile_* |
| 288 |
|
| 289 |
This means you can use `custom_target`, custom_target indices |
| 290 |
(`custom_target[0]`, for example), or the output of `generator.process` as |
| 291 |
inputs to the various `qt.compile_*` methods. |
| 292 |
|
| 293 |
```meson |
| 294 |
qt = import('qt5') |
| 295 |
|
| 296 |
ct = custom_target(...) |
| 297 |
|
| 298 |
out = qt.compile_ui(sources : ct) |
| 299 |
``` |
| 300 |
|
| 301 |
## Waf support in external-project module |
| 302 |
|
| 303 |
If the first argument is `'waf'`, special treatment is done for the |
| 304 |
[waf](https://waf.io/) build system. The waf executable must be |
| 305 |
found either in the current directory, or in system `PATH`. |
| 306 |
|
| 307 |
## Comparing two objects with different types is now an error |
| 308 |
|
| 309 |
Using the `==` and `!=` operators to compare objects of different (for instance |
| 310 |
`[1] == 1`) types was deprecated and undefined behavior since 0.45.0 and is |
| 311 |
now a hard error. |
| 312 |
|
| 313 |
## Installation tags |
| 314 |
|
| 315 |
It is now possible to install only a subset of the installable files using |
| 316 |
`meson install --tags tag1,tag2` command line. |
| 317 |
|
| 318 |
See [documentation](Installing.md#installation-tags) for more details. |
| 319 |
|
| 320 |
## Compiler.unittest_args has been removed |
| 321 |
|
| 322 |
It's never been documented, and it's been marked deprecated for a long time, so |
| 323 |
let's remove it. |
| 324 |
|
| 325 |
## Dependencies with multiple names |
| 326 |
|
| 327 |
More than one name can now be passed to `dependency()`, they will be tried in order |
| 328 |
and the first name to be found will be used. The fallback subproject will be |
| 329 |
used only if none of the names are found on the system. Once one of the name has |
| 330 |
been found, all other names are added into the cache so subsequent calls for any |
| 331 |
of those name will return the same value. This is useful in case a dependency |
| 332 |
could have different names, such as `png` and `libpng`. |
| 333 |
|
| 334 |
## i18n module now returns gettext targets |
| 335 |
|
| 336 |
`r = i18n.gettext('mydomain')` will now provide access to: |
| 337 |
- a list of built .mo files |
| 338 |
- the mydomain-pot maintainer target which updates .pot files |
| 339 |
- the mydomain-update-po maintainer target which updates .po files |
| 340 |
|
| 341 |
## Added support for CLA sources when cross-compiling with the C2000 toolchain |
| 342 |
|
| 343 |
Support for CLA sources has been added for cross-compilation with the C2000 toolchain. |
| 344 |
|
| 345 |
## Support for clippy-driver as a rustc wrapper |
| 346 |
|
| 347 |
Clippy is a popular linting tool for Rust, and is invoked in place of rustc as a |
| 348 |
wrapper. Unfortunately it doesn't proxy rustc's output, so we need to have a |
| 349 |
small wrapper around it so that Meson can correctly detect the underlying rustc, |
| 350 |
but still display clippy |
| 351 |
|
| 352 |
## Force Visual Studio environment activation |
| 353 |
|
| 354 |
Since `0.59.0`, meson automatically activates Visual Studio environment on Windows |
| 355 |
for all its subcommands, but only if no other compilers (e.g. `gcc` or `clang`) |
| 356 |
are found, and silently continue if Visual Studio activation fails. |
| 357 |
|
| 358 |
`meson setup --vsenv` command line argument can now be used to force Visual Studio |
| 359 |
activation even when other compilers are found. It also make Meson abort with an |
| 360 |
error message when activation fails. This is especially useful for GitHub Actions |
| 361 |
because their Windows images have gcc in their PATH by default. |
| 362 |
|
| 363 |
`--vsenv` is set by default when using `vs` backend. |
| 364 |
|
| 365 |
Only `setup`, `compile`, `dist` and `devenv` subcommands now activate Visual Studio. |
| 366 |
|
| 367 |
## MSVC compiler now assumes UTF-8 source code by default |
| 368 |
|
| 369 |
Every project that uses UTF-8 source files had to add manually `/utf-8` C/C++ |
| 370 |
compiler argument for MSVC otherwise they wouldn't work on non-English locale. |
| 371 |
Meson now switched the default to UTF-8 to be more consistent with all other |
| 372 |
compilers. |
| 373 |
|
| 374 |
This can be overridden but using `/source-charset`: |
| 375 |
```meson |
| 376 |
if cc.get_id() == 'msvc' |
| 377 |
add_project_arguments('/source-charset:.XYZ', language: ['c', 'cpp']) |
| 378 |
endif |
| 379 |
``` |
| 380 |
|
| 381 |
See Microsoft documentation for details: |
| 382 |
https://docs.microsoft.com/en-us/cpp/build/reference/source-charset-set-source-character-set. |
| 383 |
|
| 384 |
## Add support for `find_library` in Emscripten |
| 385 |
|
| 386 |
The `find_library` method can be used to find your own JavaScript |
| 387 |
libraries. The limitation is that they must have the file extension |
| 388 |
`.js`. Other library lookups will look up "native" libraries from the |
| 389 |
system like currently. A typical usage would look like this: |
| 390 |
|
| 391 |
```meson |
| 392 |
glue_lib = cc.find_library('gluefuncs.js', |
| 393 |
dirs: meson.current_source_dir()) |
| 394 |
executable('prog', 'prog.c', |
| 395 |
dependencies: glue_lib) |
| 396 |
``` |
| 397 |
|
| 398 |
## Optional `custom_target()` name |
| 399 |
|
| 400 |
The name argument is now optional and defaults to the basename of the first |
| 401 |
output. |
| 402 |
|