Debian Codegraph @

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

raw
1 ---
2 title: Release 0.46
3 short-description: Release notes for 0.46
4 ...
5
6 # New features
7
8 ## Allow early return from a script
9
10 Added the function `subdir_done()`. Its invocation exits the current
11 script at the point of invocation. All previously invoked build
12 targets and commands are build/executed. All following ones are
13 ignored. If the current script was invoked via `subdir()` the parent
14 script continues normally.
15
16 ## Log output slightly changed
17
18 The format of some human-readable diagnostic messages has changed in
19 minor ways. In case you are parsing these messages, you may need to
20 adjust your code.
21
22 ## ARM compiler for C and CPP
23
24 Cross-compilation is now supported for ARM targets using ARM compiler
25 - ARMCC. The current implementation does not support shareable
26 libraries. The default extension of the output is .axf. The
27 environment path should be set properly for the ARM compiler
28 executables. The '--cpu' option with the appropriate target type
29 should be mentioned in the cross file as shown in the snippet below.
30
31 ```ini
32 [properties]
33 c_args = ['--cpu=Cortex-M0plus']
34 cpp_args = ['--cpu=Cortex-M0plus']
35
36 ```
37
38 ## Building both shared and static libraries
39
40 A new function `both_libraries()` has been added to build both shared
41 and static libraries at the same time. Source files will be compiled
42 only once and object files will be reused to build both shared and
43 static libraries, unless `b_staticpic` user option or `pic:` keyword
44 argument are set to false in which case sources will be compiled
45 twice.
46
47 The returned `buildtarget` object always represents the shared library.
48
49 ## Compiler object can now be passed to run_command()
50
51 This can be used to run the current compiler with the specified
52 arguments to obtain additional information from it. One of the use
53 cases is to get the location of development files for the GCC plugins:
54
55 ```meson
56 cc = meson.get_compiler('c')
57 result = run_command(cc, '-print-file-name=plugin')
58 plugin_dev_path = result.stdout().strip()
59 ```
60
61 ## declare_dependency() now supports `link_whole:`
62
63 `declare_dependency()` now supports the `link_whole:` keyword argument which
64 transparently works for build targets which use that dependency.
65
66 ## Old command names are now errors
67
68 The old executable names `mesonintrospect`, `mesonconf`,
69 `mesonrewriter` and `mesontest` have been deprecated for a long time.
70 Starting from this version they no longer do anything but instead
71 always error out. All functionality is available as subcommands in the
72 main `meson` binary.
73
74 ## Meson and meson configure now accept the same arguments
75
76 Previously Meson required that builtin arguments (like prefix) be
77 passed as `--prefix` to `meson` and `-Dprefix` to `meson configure`.
78 `meson` now accepts -D form like `meson configure` has. `meson
79 configure` also accepts the `--prefix` form, like `meson` has.
80
81 ## Recursively extract objects
82
83 The `recursive:` keyword argument has been added to
84 `extract_all_objects()`. When set to `true` it will also return
85 objects passed to the `objects:` argument of this target. By default
86 only objects built for this target are returned to maintain backward
87 compatibility with previous versions. The default will eventually be
88 changed to `true` in a future version.
89
90 ```meson
91 lib1 = static_library('a', 'source.c', objects : 'prebuilt.o')
92 lib2 = static_library('b', objects : lib1.extract_all_objects(recursive : true))
93 ```
94
95 ## Can override find_program()
96
97 It is now possible to override the result of `find_program` to point
98 to a custom program you want. The overriding is global and applies to
99 every subproject from there on. Here is how you would use it.
100
101 In master project
102
103 ```meson
104 subproject('mydep')
105 ```
106
107 In the called subproject:
108
109 ```meson
110 prog = find_program('my_custom_script')
111 meson.override_find_program('mycodegen', prog)
112 ```
113
114 In master project (or, in fact, any subproject):
115
116 ```meson
117 genprog = find_program('mycodegen')
118 ```
119
120 Now `genprog` points to the custom script. If the dependency had come
121 from the system, then it would point to the system version.
122
123 You can also use the return value of `configure_file()` to override
124 a program in the same way as above:
125
126 ```meson
127 prog_script = configure_file(input : 'script.sh.in',
128 output : 'script.sh',
129 configuration : cdata)
130 meson.override_find_program('mycodegen', prog_script)
131 ```
132
133 ## New functions: has_link_argument() and friends
134
135 A new set of methods has been added to [[@compiler]]
136 objects to test if the linker
137 supports given arguments.
138
139 - [[compiler.has_link_argument]]
140 - [[compiler.has_multi_link_arguments]]
141 - [[compiler.get_supported_link_arguments]]
142 - [[compiler.first_supported_link_argument]]
143
144 ## "meson help" now shows command line help
145
146 Command line parsing is now less surprising. "meson help" is now
147 equivalent to "meson --help" and "meson help <subcommand>" is
148 equivalent to "meson <subcommand> --help", instead of creating a build
149 directory called "help" in these cases.
150
151 ## Autogeneration of simple meson.build files
152
153 A feature to generate a meson.build file compiling given C/C++ source
154 files into a single executable has been added to "meson init". By
155 default, it will take all recognizable source files in the current
156 directory. You can also specify a list of dependencies with the -d
157 flag and automatically invoke a build with the -b flag to check if the
158 code builds with those dependencies.
159
160 For example,
161
162 ```meson
163 meson init -fbd sdl2,gl
164 ```
165
166 will look for C or C++ files in the current directory, generate a
167 meson.build for them with the dependencies of sdl2 and gl and
168 immediately try to build it, overwriting any previous meson.build and
169 build directory.
170
171 ## install_data() supports `rename:`
172
173 The `rename:` keyword argument is used to change names of the installed
174 files. Here's how you install and rename the following files:
175
176 - `file1.txt` into `share/myapp/dir1/data.txt`
177 - `file2.txt` into `share/myapp/dir2/data.txt`
178
179 ```meson
180 install_data(['file1.txt', 'file2.txt'],
181 rename : ['dir1/data.txt', 'dir2/data.txt'],
182 install_dir : 'share/myapp')
183 ```
184
185 ## Support for lcc compiler for e2k (Elbrus) architecture
186
187 In this version, a support for lcc compiler for Elbrus processors
188 based on [e2k
189 microarchitecture](https://en.wikipedia.org/wiki/Elbrus_2000) has been
190 added.
191
192 Examples of such CPUs:
193 * [Elbrus-8S](https://en.wikipedia.org/wiki/Elbrus-8S);
194 * Elbrus-4S;
195 * [Elbrus-2S+](https://en.wikipedia.org/wiki/Elbrus-2S%2B).
196
197 Such compiler have a similar behavior as gcc (basic option compatibility),
198 but, in is not strictly compatible with gcc as of current version.
199
200 Major differences as of version 1.21.22:
201 * it does not support LTO and PCH;
202 * it suffers from the same dependency file creation error as icc;
203 * it has minor differences in output, especially version output;
204 * it differently reacts to lchmod() detection;
205 * some backend messages are produced in ru_RU.KOI8-R even if LANG=C;
206 * its preprocessor treats some characters differently.
207
208 So every noted difference is properly handled now in Meson.
209
210 ## String escape character sequence update
211
212 Single-quoted strings in Meson have been taught the same set of escape
213 sequences as in Python. It is therefore now possible to use arbitrary
214 bytes in strings, like for example `NUL` (`\0`) and other ASCII
215 control characters. See the chapter about [*Strings* in
216 *Syntax*](Syntax.md#strings) for more details.
217
218 Potential backwards compatibility issue: Any valid escape sequence
219 according to the new rules will be interpreted as an escape sequence
220 instead of the literal characters. Previously only the following
221 escape sequences were supported in single-quote strings: `\'`, `\\`
222 and `\n`.
223
224 Note that the behaviour of triple-quoted (multiline) strings has not
225 changed. They behave like raw strings and do not support any escape
226 sequences.
227
228 ## New `forcefallback` wrap mode
229
230 A new wrap mode was added, `--wrap-mode=forcefallback`. When this is
231 set, dependencies for which a fallback was provided will always use
232 it, even if an external dependency exists and satisfies the version
233 requirements.
234
235 ## Relaxing of target name requirements
236
237 In earlier versions of Meson you could only have one target of a given
238 name for each type. For example you could not have two executables
239 named `foo`. This requirement is now relaxed so that you can have
240 multiple targets with the same name, as long as they are in different
241 subdirectories.
242
243 Note that projects that have multiple targets with the same name can
244 not be built with the `flat` layout or any backend that writes outputs
245 in the same directory.
246
247 ## Addition of OpenMP dependency
248
249 An OpenMP dependency (`openmp`) has been added that encapsulates the
250 various flags used by compilers to enable OpenMP and checks for the
251 existence of the `omp.h` header. The `language` keyword may be passed
252 to force the use of a specific compiler for the checks.
253
254 ## Added new partial_dependency method to dependencies and libraries
255
256 It is now possible to use only part of a dependency in a target. This
257 allows, for example, to only use headers with convenience libraries to
258 avoid linking to the same library multiple times.
259
260 ```meson
261 dep = dependency('xcb')
262
263 helper = static_library(
264 'helper',
265 ['helper1.c', 'helper2.c'],
266 dependencies : dep.partial_dependency(includes : true),
267 ]
268
269 final = shared_library(
270 'final',
271 ['final.c'],
272 dependencies : dep,
273 )
274 ```
275
276 A partial dependency will have the same name version as the full
277 dependency it is derived from, as well as any values requested.
278
279 ## Improved generation of pkg-config files for static only libraries.
280
281 Previously pkg-config files generated by the pkgconfig modules for
282 static libraries with dependencies could only be used in a
283 dependencies with `static: true`.
284
285 Now the generated file contains the needed dependencies libraries
286 directly within `Requires` and `Libs` for build static libraries
287 passed via the `libraries` keyword argument.
288
289 Projects that install both a static and a shared version of a library
290 should use the result of
291 [[both_libraries]] to the
292 pkg-config file generator or use
293 [[configure_file]] for more
294 complicated setups.
295
296 ## Improvements to pkgconfig module
297
298 A `StaticLibrary` or `SharedLibrary` object can optionally be passed
299 as first positional argument of the `generate()` method. If one is provided a
300 default value will be provided for all required fields of the pc file:
301 - `install_dir` is set to `pkgconfig` folder in the same location than the provided library.
302 - `description` is set to the project's name followed by the library's name.
303 - `name` is set to the library's name.
304
305 Generating a .pc file is now as simple as:
306
307 ```meson
308 pkgconfig.generate(mylib)
309 ```
310
311 ## pkgconfig.generate() requires parameters non-string arguments
312
313 `pkgconfig.generate()` `requires:` and `requires_private:` keyword
314 arguments now accept pkgconfig-dependencies and libraries that
315 pkgconfig-files were generated for.
316
317 ## Generic python module
318
319 Meson now has is a revamped and generic (python 2 and 3) version of
320 the python3 module. With [this new interface](Python-module.md),
321 projects can now fully specify the version of python they want to
322 build against / install sources to, and can do so against multiple
323 major or minor versions in parallel.
324
325 ## test() now supports the `depends:` keyword argument
326
327 Build targets and custom targets can be listed in the `depends:`
328 keyword argument of test function. These targets will be built before
329 test is run even if they have `build_by_default : false`.