Debian Codegraph @

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

raw
1 ---
2 title: Release 0.48
3 short-description: Release notes for 0.48
4 ...
5
6 # New features
7
8 ## Toggles for build type, optimization and vcrt type
9
10 Since the very beginning Meson has provided different project types to
11 use, such as *debug* and *minsize*. There is also a *plain* type that
12 adds nothing by default but instead makes it the user's responsibility
13 to add everything by hand. This works but is a bit tedious.
14
15 In this release we have added new options to manually toggle e.g.
16 optimization levels and debug info so those can be changed
17 independently of other options. For example by default the debug
18 buildtype has no optimization enabled at all. If you wish to use GCC's
19 `-Og` instead, you could set it with the following command:
20
21 ```
22 meson configure -Doptimization=g
23 ```
24
25 Similarly we have added a toggle option to select the version of
26 Visual Studio C runtime to use. By default it uses the debug runtime
27 DLL debug builds and release DLL for release builds but this can be
28 manually changed with the new base option `b_vscrt`.
29
30 ## Meson warns if two calls to `configure_file()` write to the same file
31
32 If two calls to
33 [[configure_file]] write to the
34 same file Meson will print a `WARNING:` message during configuration.
35 For example:
36
37 ```meson
38 project('configure_file', 'cpp')
39
40 configure_file(
41 input: 'a.in',
42 output: 'out',
43 command: ['./foo.sh']
44 )
45 configure_file(
46 input: 'a.in',
47 output: 'out',
48 command: ['./foo.sh']
49 )
50 ```
51
52 This will output:
53
54 ```
55 The Meson build system
56 Version: 0.47.0.dev1
57 Source dir: /path/to/srctree
58 Build dir: /path/to/buildtree
59 Build type: native build
60 Project name: configure_file
61 Project version: undefined
62 Build machine cpu family: x86_64
63 Build machine cpu: x86_64
64 Configuring out with command
65 WARNING: Output file out for configure_file overwritten. First time written in line 3 now in line 8
66 Configuring out with command
67 Build targets in project: 0
68 Found ninja-1.8.2 at /usr/bin/ninja
69 ```
70
71 ## New kwarg `console` for `custom_target()`
72
73 This keyword argument conflicts with `capture`, and is meant for
74 commands that are resource-intensive and take a long time to
75 finish. With the Ninja backend, setting this will add this target to
76 [Ninja's `console`
77 pool](https://ninja-build.org/manual.html#_the_literal_console_literal_pool),
78 which has special properties such as not buffering stdout and
79 serializing all targets in this pool.
80
81 The primary use-case for this is to be able to run external commands
82 that take a long time to execute. Without setting this, the user does
83 not receive any feedback about what the program is doing.
84
85 ## `dependency(version:)` now applies to all dependency types
86
87 Previously, version constraints were only enforced for dependencies
88 found using the pkg-config dependency provider. These constraints now
89 apply to dependencies found using any dependency provider.
90
91 Some combinations of dependency, host and method do not currently
92 support discovery of the version. In these cases, the dependency will
93 not be found if a version constraint is applied, otherwise the
94 `version()` method for the dependency object will return `'unknown'`.
95
96 (If discovering the version in one of these combinations is important
97 to you, and a method exists to determine the version in that case,
98 please file an issue with as much information as possible.)
99
100 ## python3 module is deprecated
101
102 A generic module `python` has been added in Meson `0.46.0` and has a superset of
103 the features implemented by the previous `python3` module.
104
105 In most cases, it is a simple matter of renaming:
106 ```meson
107 py3mod = import('python3')
108 python = py3mod.find_python()
109 ```
110
111 becomes
112
113 ```meson
114 pymod = import('python')
115 python = pymod.find_installation()
116 ```
117
118 ## Dictionary addition
119
120 Dictionaries can now be added, values from the second dictionary overrides values
121 from the first
122
123 ```meson
124 d1 = {'a' : 'b'}
125 d3 = d1 + {'a' : 'c'}
126 d3 += {'d' : 'e'}
127 ```
128
129 ## Dist scripts
130
131 You can now specify scripts that are run as part of the `dist`
132 target. An example usage would go like this:
133
134 ```meson
135 project('foo', 'c')
136
137 # other stuff here
138
139 meson.add_dist_script('dist_cleanup.py')
140 ```
141
142 ## Fatal warnings
143
144 A new command line option has been added: `--fatal-meson-warnings`.
145 When enabled, any warning message printed by Meson will be fatal and
146 raise an exception. It is intended to be used by developers and CIs to
147 easily catch deprecation warnings, or any other potential issues.
148
149 ## Helper methods added for checking GNU style attributes: `__attribute__(...)`
150
151 A set of new helpers have been added to the C and C++ compiler objects
152 for checking GNU style function attributes. These are not just simpler
153 to use, they may be optimized to return fast on compilers that don't
154 support these attributes. Currently this is true for MSVC.
155
156 ```meson
157 cc = meson.get_compiler('c')
158 if cc.has_function_attribute('aligned')
159 add_project_arguments('-DHAVE_ALIGNED', language : 'c')
160 endif
161 ```
162
163 Would replace code like:
164
165 ```meson
166 if cc.compiles('''into foo(void) __attribute__((aligned(32)))''')
167 add_project_arguments('-DHAVE_ALIGNED', language : 'c')
168 endif
169 ```
170
171 Additionally, a multi argument version has been added:
172
173 ```meson
174 foreach s : cc.get_supported_function_attributes(['hidden', 'alias'])
175 add_project_arguments('-DHAVE_@0@'.format(s.to_upper()), language : 'c')
176 endforeach
177 ```
178
179 ## `gnome.generate_gir()` now optionally accepts multiple libraries
180
181 The GNOME module can now generate a single gir for multiple libraries,
182 which is something `g-ir-scanner` supported, but had not been exposed
183 yet.
184
185 gnome.generate_gir() will now accept multiple positional arguments, if
186 none of these arguments are an `Executable` instance.
187
188 ## Hotdoc module
189
190 A new module has been written to ease generation of
191 [hotdoc](https://hotdoc.github.io/) based documentation. It supports
192 complex use cases such as hotdoc subprojects (to create documentation
193 portals) and makes it straight forward to leverage full capabilities
194 of hotdoc.
195
196 Simple usage:
197
198 ``` meson
199 hotdoc = import('hotdoc')
200
201 hotdoc.generate_doc(
202 'foobar',
203 c_smart_index: true,
204 project_version: '0.1',
205 sitemap: 'sitemap.txt',
206 index: 'index.md',
207 c_sources: ['path/to/file.c'],
208 languages: ['c'],
209 install: true,
210 )
211 ```
212
213 ## `i18n.merge_file()` now fully supports variable substitutions defined in `custom_target()`
214
215 Filename substitutions like @BASENAME@ and @PLAINNAME@ were previously
216 accepted but the name of the build target wasn't altered leading to
217 colliding target names when using the substitution twice.
218 i18n.merge_file() now behaves as custom_target() in this regard.
219
220 ## Projects args can be set separately for cross and native builds (potentially breaking change)
221
222 It has been a longstanding bug (or let's call it a "delayed bug fix")
223 that if you do this:
224
225 ```meson
226 add_project_arguments('-DFOO', language : 'c')
227 ```
228
229 Then the flag is used both in native and cross compilations. This is
230 very confusing and almost never what you want. To fix this a new
231 keyword `native` has been added to all functions that add arguments,
232 namely `add_global_arguments`, `add_global_link_arguments`,
233 `add_project_arguments` and `add_project_link_arguments` that behaves
234 like the following:
235
236 ```meson
237 # Added to native builds when compiling natively and to cross
238 # compilations when doing cross compiles.
239 add_project_arguments(...)
240
241 # Added only to native compilations, not used in cross compilations.
242 add_project_arguments(..., native : true)
243
244 # Added only to cross compilations, not used in native compilations.
245 add_project_arguments(..., native : false)
246 ```
247
248 Also remember that cross compilation is a property of each target.
249 There can be target that are compiled with the native compiler and
250 some which are compiled with the cross compiler.
251
252 Unfortunately this change is backwards incompatible and may cause some
253 projects to fail building. However this should be very rare in
254 practice.
255
256 ## More flexible `override_find_program()`.
257
258 It is now possible to pass an `executable` to
259 `override_find_program()` if the overridden program is not used during
260 configure.
261
262 This is particularly useful for fallback dependencies like Protobuf
263 that also provide a tool like protoc.
264
265 ## `shared_library()` now supports setting dylib compatibility and current version
266
267 Now, by default `shared_library()` sets `-compatibility_version` and
268 `-current_version` of a macOS dylib using the `soversion`.
269
270 This can be overridden by using the `darwin_versions:` kwarg to
271 [[shared_library]]. As usual,
272 you can also pass this kwarg to `library()` or `build_target()` and it
273 will be used in the appropriate circumstances.
274
275 ## Version comparison
276
277 `dependency(version:)` and other version constraints now handle
278 versions containing non-numeric characters better, comparing versions
279 using the rpmvercmp algorithm (as using the `pkg-config` autoconf
280 macro `PKG_CHECK_MODULES` does).
281
282 This is a breaking change for exact comparison constraints which rely
283 on the previous comparison behaviour of extending the compared
284 versions with `'0'` elements, up to the same length of `'.'`-separated
285 elements.
286
287 For example, a version of `'0.11.0'` would previously match a version
288 constraint of `'==0.11'`, but no longer does, being instead considered
289 strictly greater.
290
291 Instead, use a version constraint which exactly compares with the
292 precise version required, e.g. `'==0.11.0'`.
293
294 ## Keyword argument for GNU symbol visibility
295
296 Build targets got a new keyword, `gnu_symbol_visibility` that controls
297 how symbols are exported from shared libraries. This is most commonly
298 used to hide implementation symbols like this:
299
300 ```meson
301 shared_library('mylib', ...
302 gnu_symbol_visibility: 'hidden')
303 ```
304
305 In this case only symbols explicitly marked as visible in the source
306 files get exported.
307
308 ## Git wraps can now clone submodules automatically
309
310 To enable this, the following needs to be added to the `.wrap` file:
311
312 ```ini
313 clone-recursive=true
314 ```
315
316 ## `subproject()` function now supports the `required:` kwarg
317
318 This allows you to declare an optional subproject. You can now call
319 `found()` on the return value of the `subproject()` call to see if the
320 subproject is available before calling `get_variable()` to fetch
321 information from it.
322
323 ## `dependency()` objects now support the `.name()` method
324
325 You can now fetch the name of the dependency that was searched like
326 so:
327
328 ```meson
329 glib_dep = dependency('glib-2.0')
330 ...
331 message("dependency name is " + glib_dep.name())
332 # This outputs `dependency name is glib-2.0`
333
334 qt_dep = dependency('qt5')
335 ...
336 message("dependency name is " + qt_dep.name())
337 # This outputs `dependency name is qt5`
338
339 decl_dep = declare_dependency()
340 ...
341 message("dependency name is " + decl_dep.name())
342 # This outputs `dependency name is internal`
343 ```