Debian Codegraph @

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

raw
1 ---
2 title: Release 1.1.0
3 short-description: Release notes for 1.1.0
4 ...
5
6 # New features
7
8 Meson 1.1.0 was released on 10 April 2023
9 ## `clang-cl` now accepts `cpp_std=c++20`
10
11 Requires `clang-cl` 13 or later.
12
13 ## coercing values in the option() function is deprecated
14
15 Currently code such as:
16 ```meson
17 option('foo', type : 'boolean', value : 'false')
18 ```
19 works, because Meson coerces `'false'` to `false`.
20
21 This should be avoided, and will now result in a deprecation warning.
22
23 ## New `declare_dependency(objects: )` argument
24
25 A new argument to `declare_dependency` makes it possible to add objects
26 directly to executables that use an internal dependency, without going
27 for example through `link_whole`.
28
29 ## Dump devenv into file and select format
30
31 `meson devenv --dump [<filename>]` command now takes an optional filename argument
32 to write the environment into a file instead of printing to stdout.
33
34 A new `--dump-format` argument has been added to select which shell format
35 should be used. There are currently 3 formats supported:
36 - `sh`: Lines are in the format `VAR=/prepend:$VAR:/append`.
37 - `export`: Same as `sh` but with extra `export VAR` lines.
38 - `vscode`: Same as `sh` but without `$VAR` substitution because they do not
39 seems to be properly supported by vscode.
40
41 ## Feature objects now have an enable_auto_if method
42
43 This performs the opposite task of the disable_auto_if method, enabling the
44 feature if the condition is true.
45
46 ## Add a FeatureOption.enable_if and .disable_if
47
48 These are useful when features need to be constrained to pass to [[dependency]],
49 as the behavior of an `auto` and `disabled` or `enabled` feature is markedly
50 different. consider the following case:
51
52 ```meson
53 opt = get_option('feature').disable_auto_if(not foo)
54 if opt.enabled() and not foo
55 error('Cannot enable feat when foo is not also enabled')
56 endif
57 dep = dependency('foo', required : opt)
58 ```
59
60 This could be simplified to
61 ```meson
62 opt = get_option('feature').disable_if(not foo, error_message : 'Cannot enable feature when foo is not also enabled')
63 dep = dependency('foo', required : opt)
64 ```
65
66 For a real life example, here is some code in mesa:
67 ```meson
68 _llvm = get_option('llvm')
69 dep_llvm = null_dep
70 with_llvm = false
71 if _llvm.allowed()
72 dep_llvm = dependency(
73 'llvm',
74 version : _llvm_version,
75 modules : llvm_modules,
76 optional_modules : llvm_optional_modules,
77 required : (
78 with_amd_vk or with_gallium_radeonsi or with_gallium_opencl or with_clc
79 or _llvm.enabled()
80 ),
81 static : not _shared_llvm,
82 fallback : ['llvm', 'dep_llvm'],
83 include_type : 'system',
84 )
85 with_llvm = dep_llvm.found()
86 endif
87 if with_llvm
88 ...
89 elif with_amd_vk and with_aco_tests
90 error('ACO tests require LLVM, but LLVM is disabled.')
91 elif with_gallium_radeonsi or with_swrast_vk
92 error('The following drivers require LLVM: RadeonSI, SWR, Lavapipe. One of these is enabled, but LLVM is disabled.')
93 elif with_gallium_opencl
94 error('The OpenCL "Clover" state tracker requires LLVM, but LLVM is disabled.')
95 elif with_clc
96 error('The CLC compiler requires LLVM, but LLVM is disabled.')
97 else
98 draw_with_llvm = false
99 endif
100 ```
101
102 simplified to:
103 ```meson
104 _llvm = get_option('llvm') \
105 .enable_if(with_amd_vk and with_aco_tests, error_message : 'ACO tests requires LLVM') \
106 .enable_if(with_gallium_radeonsi, error_message : 'RadeonSI requires LLVM') \
107 .enable_if(with_swrast_vk, error_message : 'Vulkan SWRAST requires LLVM') \
108 .enable_if(with_gallium_opencl, error_message : 'The OpenCL Clover state trackers requires LLVM') \
109 .enable_if(with_clc, error_message : 'CLC library requires LLVM')
110
111 dep_llvm = dependency(
112 'llvm',
113 version : _llvm_version,
114 modules : llvm_modules,
115 optional_modules : llvm_optional_modules,
116 required : _llvm,
117 static : not _shared_llvm,
118 fallback : ['llvm', 'dep_llvm'],
119 include_type : 'system',
120 )
121 with_llvm = dep_llvm.found()
122 ```
123
124 ## Generated objects can be passed in the `objects:` keyword argument
125
126 In previous versions of Meson, generated objects could only be
127 passed as sources of a build target. This was confusing, therefore
128 generated objects can now be passed in the `objects:` keyword
129 argument as well.
130
131 ## The project function now supports setting the project license files
132
133 This goes together with the license name. The license files can be
134 automatically installed via [[meson.install_dependency_manifest]],
135 or queried via [[meson.project_license_files]].
136
137 ## A new core directory option "licensedir" is available
138
139 This will install a dependency manifest to the specified directory, if none
140 is is explicitly set.
141
142 ## `sudo meson install` now drops privileges when rebuilding targets
143
144 It is common to install projects using sudo, which should not affect build
145 outputs but simply install the results. Unfortunately, since the ninja backend
146 updates a state file when run, it's not safe to run ninja as root at all.
147
148 It has always been possible to carefully build with:
149
150 ```
151 ninja && sudo meson install --no-rebuild
152 ```
153
154 Meson now tries to be extra safe as a general solution. `sudo meson install`
155 will attempt to rebuild, but has learned to run `ninja` as the original
156 (pre-sudo or pre-doas) user, ensuring that build outputs are generated/compiled
157 as non-root.
158
159 ## `meson install` now supports user-preferred root elevation tools
160
161 Previously, when installing a project, if any files could not be installed due
162 to insufficient permissions the install process was automatically re-run using
163 polkit. Now it prompts to ask whether that is desirable, and checks for
164 CLI-based tools such as sudo or opendoas or `$MESON_ROOT_CMD`, first.
165
166 Meson will no longer attempt privilege elevation at all, when not running
167 interactively.
168
169 ## Support for reading options from meson.options
170
171 Support has been added for reading options from `meson.options` instead of
172 `meson_options.txt`. These are equivalent, but not using the `.txt` extension
173 for a build file has a few advantages, chief among them many tools and text
174 editors expect a file with the `.txt` extension to be plain text files, not
175 build scripts.
176
177 ## Redirect introspection outputs to stderr
178
179 `meson introspect` used to disable logging to `stdout` to not interfere with generated json.
180 It now redirect outputs to `stderr` to allow printing warnings to the console
181 while keeping `stdout` clean for json outputs.
182
183 ## New "none" backend
184
185 The `--backend=none` option has been added, to configure a project that has no
186 build rules, only install rules. This avoids depending on ninja.
187
188 ## compiler.preprocess()
189
190 Dependencies keyword argument can now be passed to `compiler.preprocess()` to
191 add include directories or compiler arguments.
192
193 Generated sources such as custom targets are now allowed too.
194
195 ## New pybind11 custom dependency
196
197 `dependency('pybind11')` works with pkg-config and cmake without any special
198 support, but did not handle the `pybind11-config` script.
199
200 This is useful because the config-tool will work out of the box when pybind11
201 is installed, but the pkg-config and cmake files are shoved into python's
202 site-packages, which makes it impossible to use in an out of the box manner.
203
204
205 ## Allow --reconfigure and --wipe of empty builddir
206
207 `meson setup --reconfigure builddir` and `meson setup --wipe builddir` are now
208 accepting `builddir/` to be empty or containing a previously failed setup attempt.
209 Note that in that case previously passed command line options must be repeated
210 as only a successful build saves configured options.
211
212 This is useful for example with scripts that always repeat all options,
213 `meson setup builddir --wipe -Dfoo=bar` will always work regardless whether
214 it is a first invocation or not.
215
216 ## Allow custom install scripts to run with `--dry-run` option
217
218 An new `dry_run` keyword is added to `meson.add_install_script()`
219 to allow a custom install script to run when meson is invoked
220 with `meson install --dry-run`.
221
222 In dry run mode, the `MESON_INSTALL_DRY_RUN` environment variable
223 is set.
224