Debian Codegraph @

subprojects/meson-docs/docs/markdown/Release-notes-for-0.57.0.md

raw
1 ---
2 title: Release 0.57.0
3 short-description: Release notes for 0.57.0
4 ...
5
6 # New features
7
8 ## Project version can be specified with a file
9
10 Meson can be instructed to load a project's version string from an
11 external file like this:
12
13 ```meson
14 project('foo', 'c', version: files('VERSION'))
15 ```
16
17 The version file must contain exactly one line of text which will
18 be used as the project's version. If the line ends in a newline
19 character, it is removed.
20
21 ## Support for reading files at configuration time with the `fs` module
22
23 Reading text files during configuration is now supported. This can be done at
24 any time after `project` has been called
25
26 ```meson
27 project('myproject', 'c')
28 license_text = run_command(
29 find_program('python3'), '-c', 'print(open("COPYING").read())'
30 ).stdout().strip()
31 about_header = configuration_data()
32 about_header.add('COPYRIGHT', license_text)
33 about_header.add('ABOUT_STRING', meson.project_name())
34 ...
35 ```
36
37 There are several problems with the above approach:
38 1. It's ugly and confusing
39 2. If `COPYING` changes after configuration, Meson won't correctly rebuild when
40 configuration data is based on the data in COPYING
41 3. It has extra overhead
42
43 `fs.read` replaces the above idiom thus:
44 ```meson
45 project('myproject', 'c')
46 fs = import('fs')
47 license_text = fs.read('COPYING').strip()
48 about_header = configuration_data()
49 about_header.add('COPYRIGHT', license_text)
50 about_header.add('ABOUT_STRING', meson.project_name())
51 ...
52 ```
53
54 They are not equivalent, though. Files read with `fs.read` create a
55 configuration dependency on the file, and so if the `COPYING` file is modified,
56 Meson will automatically reconfigure, guaranteeing the build is consistent. It
57 can be used for any properly encoded text files. It supports specification of
58 non utf-8 encodings too, so if you're stuck with text files in a different
59 encoding, it can be passed as an argument. See the [[@meson]]
60 documentation for details.
61
62 ## meson install --dry-run
63
64 New option to meson install command that does not actually install files, but
65 only prints messages.
66
67 ## Experimental support for C++ modules in Visual Studio
68
69 Modules are a new C++ 20 feature for organising source code aiming to
70 increase compilation speed and reliability. This support is
71 experimental and may change in future releases. It only works with the
72 latest preview release of Visual Studio.
73
74 ## Qt6 module
75
76 A module for Qt6 is now available with the same functionality as the Qt5
77 module.
78
79 Currently finding Qt6 is only available via `qmake` as pkg-config files aren't
80 generated (see [QTBUG-86080](https://bugreports.qt.io/browse/QTBUG-86080)) and
81 CMake support is not available for this module yet.
82
83 ## Unstable Rust module
84
85 A new unstable module has been added to make using Rust with Meson easier.
86 Currently, it adds a single function to ease defining Rust tests, as well as a
87 wrapper around bindgen, making it easier to use.
88
89 ## Meson test() now accepts `protocol : 'rust'`
90
91 This allows native Rust tests to be run and parsed by Meson; simply set the
92 protocol to `rust` and Meson takes care of the rest.
93
94 ## MSVC/Clang-Cl Argument Changes/Cleanup
95
96 * "Disable Debug" (`/Od`) is no longer manually specified for optimization levels {`0`,`g`} (it is already the default for MSVC).
97 * "Run Time Checking" (`/RTC1`) removed from `debug` buildtype by default
98 * Clang-CL `debug` buildtype arguments now match MSVC arguments
99 * There is now no difference between `buildtype` flags and `debug` + `optimization` flags
100
101 The /Od flag has been removed, as it is already the default in the MSVC compilers, and conflicts with other user options.
102
103 /RTC1 conflicts with other RTC argument types as there are many different options, and has been removed by default.
104 Run Time Checking can be enabled by manually adding `/RTC1` or other RTC flags of your choice.
105
106 The `debug` buildtype for clang-cl added additional arguments compared to MSVC, which had more to do with optimization than debug. The arguments removed are `/Ob0`, `/Od`, `/RTC1`. (`/Zi` was also removed, but it is already added by default when debug is enabled.)
107
108 If these are important issues for you and would like builtin toggle options,
109 please file an issue in the Meson bug tracker.
110
111 ## Buildtype remains even if dependent options are changed
112
113 Setting the `buildtype` option to a value sets the `debug` and
114 `optimization` options to predefined values. Traditionally setting the
115 options to other values would then change the buildtype to `custom`.
116 This is confusing and means that you can't use, for example, debug
117 level `g` in `debug` buildtype even though it would make sense under
118 many circumstances.
119
120 Starting with this release, the buildtype is only changed when the user
121 explicitly sets it; setting the build type modifies the `debug` and
122 `optimization` options as before.
123
124 ## Passing internal dependencies to the compiler object
125
126 Methods on the compiler object (such as `compiles`, `links`, `has_header`)
127 can be passed dependencies returned by `declare_dependency`, as long as they
128 only specify compiler/linker arguments or other dependencies that satisfy
129 the same requirements.
130
131 ## `unstable-external_project` improvements
132
133 - Default arguments are added to `add_project()` in case some tags are not found
134 in `configure_options`: `'--prefix=@PREFIX@'`, `'--libdir=@PREFIX@/@LIBDIR@'`,
135 and `'--includedir=@PREFIX@/@INCLUDEDIR@'`. It was previously considered a fatal
136 error to not specify them.
137
138 - When the `verbose` keyword argument is not specified, or is false, command outputs
139 are written on file in `<builddir>/meson-logs/`.
140
141 - The `LD` environment variable is not passed any more when running the configure
142 script. It caused issues because Meson sets `LD` to the `CC` linker wrapper but
143 autotools expects it to be a real linker (e.g. `/usr/bin/ld`).
144
145 ## `gnome.post_install()`
146
147 Post-install update of various system wide caches. Each script will be executed
148 only once even if `gnome.post_install()` is called multiple times from multiple
149 subprojects. If `DESTDIR` is specified during installation all scripts will be
150 skipped.
151
152 Currently supports `glib-compile-schemas`, `gio-querymodules`, and
153 `gtk-update-icon-cache`.
154
155 ## "Edit and continue" (/ZI) is no longer used by default for Visual Studio
156
157 Meson was adding the `/ZI` compiler argument as an argument for Visual Studio
158 in debug mode. This enables the `edit-and-continue` debugging in
159 Visual Studio IDE's.
160
161 Unfortunately, it is also extremely expensive and breaks certain use cases such
162 as link time code generation. Edit and continue can be enabled by manually by
163 adding `/ZI` to compiler arguments.
164
165 The `/ZI` argument has now been replaced by the `/Zi` argument for debug builds.
166
167 If this is an important issue for you and would like a builtin toggle option,
168 please file an issue in the Meson bug tracker.
169
170 ## Minimum required Python version updated to 3.6
171
172 Meson now requires at least Python version 3.6 to run as Python 3.5
173 reaches EOL on September 2020. In practice this should only affect
174 people developing on Ubuntu Xenial, which will similarly reach EOL in
175 April 2021.
176
177 ## Packaging a subproject
178
179 The `meson dist` command can now create a distribution tarball for a subproject
180 in the same git repository as the main project. This can be useful if parts of
181 the project (e.g. libraries) can be built and distributed separately. In that
182 case they can be moved into `subprojects/mysub` and running `meson dist` in that
183 directory will now create a tarball containing only the source code from that
184 subdir and not the rest of the main project or other subprojects.
185
186 For example:
187 ```sh
188 git clone https://github.com/myproject
189 cd myproject/subprojects/mysubproject
190 meson setup builddir
191 meson dist -C builddir
192 ```
193
194 ## `custom_target()` and `run_target()` now accepts an `env` keyword argument
195
196 Environment variables can now be passed to the `custom_target()` command.
197
198 ```meson
199 env = environment()
200 env.append('PATH', '/foo')
201 custom_target(..., env: env)
202 custom_target(..., env: {'MY_ENV': 'value'})
203 custom_target(..., env: ['MY_ENV=value'])
204 ```
205
206 ## `summary()` accepts external programs or dependencies
207
208 External program objects and dependency objects can be passed to
209 `summary()` as the value to be printed.
210
211 ## CMake `find_package` version support
212
213 It is now possible to specify a requested package version for the CMake
214 dependency backend via the new `cmake_package_version` kwarg in the
215 `dependency` function.
216
217 ## `meson test` only rebuilds test dependencies
218
219 Until now, `meson test` rebuilt the whole project independent of the
220 requested tests and their dependencies. With this release, `meson test`
221 will only rebuild what is needed for the tests or suites that will be run.
222 This feature can be used, for example, to speed up bisecting regressions
223 using commands like the following:
224
225 git bisect start <broken commit> <working commit>
226 git bisect run meson test <failing test name>
227
228 This would find the broken commit automatically while at each step
229 rebuilding only those pieces of code needed to run the test.
230
231 However, this change could cause failures when upgrading to 0.57, if the
232 dependencies are not specified correctly in `meson.build`.
233
234 ## The `add_*_script` methods now accept a File as the first argument
235
236 Meson now accepts `file` objects, including those produced by
237 `configure_file`, as the first parameter of the various
238 `add_*_script` methods
239
240 ```meson
241 install_script = configure_file(
242 configuration : conf,
243 input : 'myscript.py.in',
244 output : 'myscript.py',
245 )
246
247 meson.add_install_script(install_script, other, params)
248 ```
249
250 ## Unity build with Vala disabled
251
252 The approach that meson has used for Vala unity builds is incorrect, we
253 combine the generated C files like we would any other C file. This is very
254 fragile however, as the Vala compiler generates helper functions and macros
255 which work fine when each file is a separate translation unit, but fail when
256 they are combined.
257
258 ## New logging format for `meson test`
259
260 The console output format for `meson test` has changed in several ways.
261 The major changes are:
262
263 * if stdout is a tty, `meson` includes a progress report.
264
265 * if `--print-errorlogs` is specified, the logs are printed as tests run
266 rather than afterwards. All the error logs are printed rather than only
267 the first ten.
268
269 * if `--verbose` is specified and `--num-processes` specifies more than
270 one concurrent test, test output is buffered and printed after the
271 test finishes.
272
273 * the console logs include a reproducer command. If `--verbose` is
274 specified, the command is printed for all tests at the time they start;
275 otherwise, it is printed for failing tests at the time the test finishes.
276
277 * for TAP and Rust tests, Meson is able to report individual subtests. If
278 `--verbose` is specified, all tests are reported. If `--print-errorlogs`
279 is specified, only failures are.
280
281 In addition, if `--verbose` was specified, Meson used not to generate
282 logs. This limitation has now been removed.
283
284 These changes make the default `ninja test` output more readable, while
285 `--verbose` output provides detailed, human-readable logs that
286 are well suited to CI environments.
287
288 ## Specify DESTDIR on command line
289
290 `meson install` command now has a `--destdir` argument that overrides `DESTDIR`
291 from environment.
292
293 ## Skip install scripts if DESTDIR is set
294
295 `meson.add_install_script()` now has `skip_if_destdir` keyword argument. If set
296 to `true` the script won't be run if `DESTDIR` is set during installation. This is
297 useful in the case the script updates system wide caches, or performs other tasks
298 that are only needed when copying files into final destination.
299
300 ## Add support for prelinked static libraries
301
302 The static library gains a new `prelink` keyword argument that can be
303 used to prelink object files in that target. This is currently only
304 supported for the GNU toolchain, patches to add it to other compilers
305 are most welcome.
306
307 ## Rust now has an `std` option
308
309 Rust calls these `editions`, however, Meson generally refers to such language
310 versions as "standards", or `std` for short. Therefore, Meson's Rust support
311 uses `std` for consistency with other languages.
312
313 ## Ctrl-C behavior in `meson test`
314
315 Starting from this version, sending a `SIGINT` signal (or pressing `Ctrl-C`)
316 to `meson test` will interrupt the longest running test. Pressing `Ctrl-C`
317 three times within a second will exit `meson test`.
318
319 ## Support added for LLVM's thinLTO
320
321 A new `b_lto_mode` option has been added, which may be set to `default` or
322 `thin`. Thin only works for clang, and only with gnu gold, lld variants, or
323 ld64.
324
325 ## `test()` timeout and timeout_multiplier value <= 0
326
327 `test(..., timeout: 0)`, or negative value, used to abort the test immediately
328 but now instead allow infinite duration. Note that omitting the `timeout`
329 keyword argument still defaults to 30s timeout.
330
331 Likewise, `add_test_setup(..., timeout_multiplier: 0)`, or
332 `meson test --timeout-multiplier 0`, or negative value, disable tests timeout.
333
334
335 ## Knob to control LTO thread
336
337 Both the gnu linker and lld support using threads for speeding up LTO, meson
338 now provides a knob for this: `-Db_lto_threads`. Currently this is only
339 supported for clang and gcc. Any positive integer is supported, `0` means
340 `auto`. If the compiler or linker implements its own `auto` we use that,
341 otherwise the number of threads on the machine is used.
342
343 ## `summary()` now uses left alignment for both keys and values
344
345 Previously it aligned keys toward the center, but this was deemed harder
346 to read than having everything left aligned.
347
348 ## `//` is now allowed as a function id for `meson rewrite`.
349
350 msys bash may expand `/` to a path, breaking
351 `meson rewrite kwargs set project / ...`. Passing `//` will be converted to
352 `/` by msys bash but in order to keep usage shell-agnostic, this release
353 also allows `//` as the id. This way, `meson rewrite kwargs set project
354 // ...` will work in both msys bash and other shells.
355
356 ## Get keys of configuration data object
357
358 All keys of the `configuration_data` object can be obtained with the `keys()`
359 method as an alphabetically sorted array.