| 1 |
--- |
| 2 |
title: Release 0.63.0 |
| 3 |
short-description: Release notes for 0.63.0 |
| 4 |
... |
| 5 |
|
| 6 |
# New features |
| 7 |
|
| 8 |
## `add_project_dependencies()` function |
| 9 |
|
| 10 |
Dependencies can now be added to all build products using |
| 11 |
`add_project_dependencies()`. This can be useful in several |
| 12 |
cases: |
| 13 |
|
| 14 |
* with special dependencies such as `dependency('threads')` |
| 15 |
* with system libraries such as `find_library('m')` |
| 16 |
* with the `include_directories` keyword argument of |
| 17 |
`declare_dependency()`, to add both source and build |
| 18 |
directories to the include search path |
| 19 |
|
| 20 |
## Coverage targets now respect tool config files |
| 21 |
|
| 22 |
gcovr >= 4.2 supports `gcovr.cfg` in the project source root to configure how |
| 23 |
coverage is generated. If Meson detects that gcovr will load this file, it no |
| 24 |
longer excludes the `subprojects/` directory from coverage. It's a good default |
| 25 |
for Meson to guess that projects want to ignore it, but not all projects prefer |
| 26 |
that and it is assumed that if a gcovr.cfg exists then it will manually |
| 27 |
include/exclude desired paths. |
| 28 |
|
| 29 |
lcov supports `.lcovrc`, but only as a systemwide or user setting. This is |
| 30 |
non-ideal for projects, so Meson will now detect one in the project source root |
| 31 |
and, if present, manually tell lcov to use it. |
| 32 |
|
| 33 |
## D compiler checks |
| 34 |
|
| 35 |
Some compiler checks are implemented for D: |
| 36 |
- `run` |
| 37 |
- `sizeof` |
| 38 |
- `has_header` (to check if a module is present) |
| 39 |
- `alignment` |
| 40 |
|
| 41 |
Example: |
| 42 |
|
| 43 |
```meson |
| 44 |
ptr_size = meson.get_compiler('d').sizeof('void*') |
| 45 |
``` |
| 46 |
|
| 47 |
## Deprecate an option and replace it with a new one |
| 48 |
|
| 49 |
The `deprecated` keyword argument can now take the name of a new option |
| 50 |
that replaces this option. In that case, setting a value on the deprecated option |
| 51 |
will set the value on both the old and new names, assuming they accept the same |
| 52 |
values. |
| 53 |
|
| 54 |
```meson |
| 55 |
# A boolean option has been replaced by a feature with another name, old true/false values |
| 56 |
# are accepted by the new option for backward compatibility. |
| 57 |
option('o1', type: 'boolean', value: 'true', deprecated: 'o2') |
| 58 |
option('o2', type: 'feature', value: 'enabled', deprecated: {'true': 'enabled', 'false': 'disabled'}) |
| 59 |
|
| 60 |
# A project option is replaced by a module option |
| 61 |
option('o3', type: 'string', value: '', deprecated: 'python.platlibdir') |
| 62 |
``` |
| 63 |
|
| 64 |
## Running Windows executables with Wine in `meson devenv` |
| 65 |
|
| 66 |
When cross compiling for Windows, `meson devenv` now sets `WINEPATH` pointing to |
| 67 |
all directories containing needed DLLs and executables. |
| 68 |
|
| 69 |
## Diff files for wraps |
| 70 |
|
| 71 |
Wrap files can now define `diff_files`, a list of local patch files in `diff` |
| 72 |
format. Meson will apply the diff files after extracting or cloning the project, |
| 73 |
and after applying the overlay archive (`patch_*`). For this feature, the |
| 74 |
`patch` or `git` command-line tool must be available. |
| 75 |
|
| 76 |
## Added preserve_path arg to install_headers |
| 77 |
|
| 78 |
The [[install_headers]] function now has an optional argument `preserve_path` |
| 79 |
that allows installing multi-directory headerfile structures that live |
| 80 |
alongside sourcecode with a single command. |
| 81 |
|
| 82 |
For example, the headerfile structure |
| 83 |
|
| 84 |
```meson |
| 85 |
headers = [ |
| 86 |
'one.h', |
| 87 |
'two.h', |
| 88 |
'alpha/one.h', |
| 89 |
'alpha/two.h', |
| 90 |
'alpha/three.h' |
| 91 |
'beta/one.h' |
| 92 |
] |
| 93 |
``` |
| 94 |
|
| 95 |
can now be passed to `install_headers(headers, subdir: 'mylib', preserve_path: true)` |
| 96 |
and the resulting directory tree will look like |
| 97 |
|
| 98 |
``` |
| 99 |
{prefix} |
| 100 |
└── include |
| 101 |
└── mylib |
| 102 |
├── alpha |
| 103 |
│ ├── one.h |
| 104 |
│ ├── two.h |
| 105 |
│ └── three.h |
| 106 |
├── beta |
| 107 |
│ └── one.h |
| 108 |
├── one.h |
| 109 |
└── two.h |
| 110 |
``` |
| 111 |
|
| 112 |
## JAR Resources |
| 113 |
|
| 114 |
The ability to add resources to a JAR has been added. Use the `java_resources` |
| 115 |
keyword argument. It takes a `structured_src` object. |
| 116 |
|
| 117 |
```meson |
| 118 |
jar( |
| 119 |
meson.project_name(), |
| 120 |
sources, |
| 121 |
main_class: 'com.mesonbuild.Resources', |
| 122 |
java_resources: structured_sources( |
| 123 |
files('resources/resource1.txt'), |
| 124 |
{ |
| 125 |
'subdir': files('resources/subdir/resource2.txt'), |
| 126 |
} |
| 127 |
) |
| 128 |
) |
| 129 |
``` |
| 130 |
|
| 131 |
To access these resources in your Java application: |
| 132 |
|
| 133 |
```java |
| 134 |
try (InputStreamReader reader = new InputStreamReader( |
| 135 |
Resources.class.getResourceAsStream("/resource1.txt"), |
| 136 |
StandardCharsets.UTF_8)) { |
| 137 |
// ... |
| 138 |
} |
| 139 |
|
| 140 |
try (InputStreamReader reader = new InputStreamReader( |
| 141 |
Resources.class.getResourceAsStream("/subdir/resource2.txt"), |
| 142 |
StandardCharsets.UTF_8)) { |
| 143 |
// ... |
| 144 |
} |
| 145 |
``` |
| 146 |
|
| 147 |
## Support for mold linker added |
| 148 |
|
| 149 |
The high performance linker mold can be selected via `CC_LD` or `CXX_LD` for |
| 150 |
Clang and GCC >= 12.0.1. |
| 151 |
|
| 152 |
## MSVC now sets the __cplusplus #define accurately |
| 153 |
|
| 154 |
MSVC will always return `199711L` for `__cplusplus`, even when a newer c++ |
| 155 |
standard is explicitly requested, unless you pass a specific option to the |
| 156 |
compiler for MSVC 2017 15.7 and newer. Older versions are unaffected by this. |
| 157 |
|
| 158 |
Microsoft's stated rationale is that "a lot of existing code appears to depend |
| 159 |
on the value of this macro matching 199711L", therefore for compatibility with |
| 160 |
such (MSVC-only) code they will require opting in to the standards-conformant |
| 161 |
value. |
| 162 |
|
| 163 |
Meson now always sets the option if it is available, as it is unlikely that |
| 164 |
users want the default behavior, and *impossible* to use the default behavior |
| 165 |
in cross-platform code (which frequently breaks as soon as the first person |
| 166 |
tries to compile using MSVC). |
| 167 |
|
| 168 |
## Added `debug` function |
| 169 |
|
| 170 |
In addition to the `message()`, `warning()` and `error()` functions there is now the |
| 171 |
`debug()` function to log messages that only end up in the `meson-log.txt` logfile |
| 172 |
and are not printed to stdout at configure time. |
| 173 |
|
| 174 |
## Compiler options can be set per subproject |
| 175 |
|
| 176 |
All compiler options can now be set per subproject. See |
| 177 |
[here](Build-options.md#specifying-options-per-subproject) for details on how |
| 178 |
the default value is inherited from main project. |
| 179 |
|
| 180 |
This is useful for example when the main project requires C++11 but a subproject |
| 181 |
requires C++14. The `cpp_std` value from subproject's `default_options` is now |
| 182 |
respected. |
| 183 |
|
| 184 |
## Per-subproject languages |
| 185 |
|
| 186 |
Subprojects does not inherit languages added by main project or other subprojects |
| 187 |
any more. This could break subprojects that wants to compile e.g. `.c` files but |
| 188 |
did not add `c` language, either in `project()` or `add_languages()`, and were |
| 189 |
relying on the main project to do it for them. |
| 190 |
|
| 191 |
## Installed pkgconfig files can now be relocatable |
| 192 |
|
| 193 |
The pkgconfig module now has a module option `pkgconfig.relocatable`. |
| 194 |
When set to `true`, the pkgconfig files generated will have their |
| 195 |
`prefix` variable set to be relative to their `install_dir`. |
| 196 |
|
| 197 |
For example to enable it from the command line run: |
| 198 |
|
| 199 |
```sh |
| 200 |
meson setup builddir -Dpkgconfig.relocatable=true … |
| 201 |
``` |
| 202 |
|
| 203 |
It will only work if the `install_dir` for the generated pkgconfig |
| 204 |
files are located inside the install prefix of the package. Not doing |
| 205 |
so will cause an error. |
| 206 |
|
| 207 |
This should be useful on Windows or any other platform where |
| 208 |
relocatable packages are desired. |
| 209 |
|
| 210 |
## New prefer_static built-in option |
| 211 |
|
| 212 |
Users can now set a boolean, `prefer_static`, that controls whether or not |
| 213 |
static linking should be tried before shared linking. This option acts as |
| 214 |
strictly a preference. If the preferred linking method is not successful, |
| 215 |
then Meson will fallback and try the other linking method. Specifically |
| 216 |
setting the `static` kwarg in the meson.build will take precedence over |
| 217 |
the value of `prefer_static` for that specific `dependency` or |
| 218 |
`find_library` call. |
| 219 |
|
| 220 |
## Python extension modules now depend on the python library by default |
| 221 |
|
| 222 |
Python extension modules are usually expected to link to the python library |
| 223 |
and/or its headers in order to build correctly (via the default `embed: false`, |
| 224 |
which may not actually link to the library itself). This means that every |
| 225 |
single use of `.extension_module()` needed to include the `dependencies: |
| 226 |
py_installation.dependency()` kwarg explicitly. |
| 227 |
|
| 228 |
In the interest of doing the right thing out of the box, this is now the |
| 229 |
default for extension modules that don't already include a dependency on |
| 230 |
python. This is not expected to break anything, because it should always be |
| 231 |
needed. Nevertheless, `py_installation.dependency().partial_dependency()` will |
| 232 |
be detected as already included while providing no compile/link args. |
| 233 |
|
| 234 |
## Python extension modules now build with hidden visibility |
| 235 |
|
| 236 |
Python extension modules are usually expected to only export a single symbol, |
| 237 |
decorated with the `PyMODINIT_FUNC` macro and providing the module entry point. |
| 238 |
On versions of python >= 3.9, the python headers contain GNU symbol visibility |
| 239 |
attributes to mark the init function with default visibility; it is then safe |
| 240 |
to set the [[shared_module]] inherited kwarg `gnu_symbol_visibility: 'hidden'`. |
| 241 |
|
| 242 |
In the interest of doing the right thing out of the box, this is now the |
| 243 |
default for extension modules for found installations that are new enough to |
| 244 |
have this set, which is not expected to break anything, but remains possible to |
| 245 |
set explicitly (in which case that will take precedence). |
| 246 |
|
| 247 |
## Added support for multiline fstrings |
| 248 |
|
| 249 |
Added support for multiline f-strings which use the same syntax as f-strings |
| 250 |
for string substitution. |
| 251 |
|
| 252 |
```meson |
| 253 |
x = 'hello' |
| 254 |
y = 'world' |
| 255 |
|
| 256 |
msg = f'''Sending a message... |
| 257 |
"@x@ @y@" |
| 258 |
''' |
| 259 |
``` |
| 260 |
|
| 261 |
which produces: |
| 262 |
|
| 263 |
``` |
| 264 |
Sending a message.... |
| 265 |
|
| 266 |
"hello world" |
| 267 |
|
| 268 |
``` |
| 269 |
|