diff options
author | Jacob Kroon <jacob.kroon@gmail.com> | 2022-09-13 04:26:35 -1000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-09-16 17:53:22 +0100 |
commit | df626c9cc073b9046af72ec7b8af3efbb79a7d36 (patch) | |
tree | e01750f4b3c982225a309c7be0bf69a63ddcccd2 /bitbake/doc | |
parent | f58e385b99ea4871a6ac2b13dad93dc9c455df6f (diff) | |
download | poky-df626c9cc073b9046af72ec7b8af3efbb79a7d36.tar.gz |
bitbake: bitbake-user-manual: Correct description of the ??= operator
Stating that the assignment is done at the end of parsing is misleading.
The weak default value is the value which a variable will expand to if no value
has been assigned to it using any of the assignment operators.
(Bitbake rev: f28dbdf80a7fc2febca227f8cb2b474f5058281e)
Signed-off-by: Jacob Kroon <jacob.kroon@gmail.com>
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 8189f58d0449d16f162b6e8d98c4e5edc6bff875)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/doc')
-rw-r--r-- | bitbake/doc/bitbake-user-manual/bitbake-user-manual-metadata.rst | 55 |
1 files changed, 39 insertions, 16 deletions
diff --git a/bitbake/doc/bitbake-user-manual/bitbake-user-manual-metadata.rst b/bitbake/doc/bitbake-user-manual/bitbake-user-manual-metadata.rst index af4b135867..337821612c 100644 --- a/bitbake/doc/bitbake-user-manual/bitbake-user-manual-metadata.rst +++ b/bitbake/doc/bitbake-user-manual/bitbake-user-manual-metadata.rst | |||
@@ -195,22 +195,45 @@ value. However, if ``A`` is not set, the variable is set to "aval". | |||
195 | Setting a weak default value (??=) | 195 | Setting a weak default value (??=) |
196 | ---------------------------------- | 196 | ---------------------------------- |
197 | 197 | ||
198 | It is possible to use a "weaker" assignment than in the previous section | 198 | The weak default value of a variable is the value which that variable |
199 | by using the "??=" operator. This assignment behaves identical to "?=" | 199 | will expand to if no value has been assigned to it via any of the other |
200 | except that the assignment is made at the end of the parsing process | 200 | assignment operators. The "??=" operator takes effect immediately, replacing |
201 | rather than immediately. Consequently, when multiple "??=" assignments | 201 | any previously defined weak default value. Here is an example:: |
202 | exist, the last one is used. Also, any "=" or "?=" assignment will | 202 | |
203 | override the value set with "??=". Here is an example:: | 203 | W ??= "x" |
204 | 204 | A := "${W}" # Immediate variable expansion | |
205 | A ??= "somevalue" | 205 | W ??= "y" |
206 | A ??= "someothervalue" | 206 | B := "${W}" # Immediate variable expansion |
207 | 207 | W ??= "z" | |
208 | If ``A`` is set before the above statements are | 208 | C = "${W}" |
209 | parsed, the variable retains its value. If ``A`` is not set, the | 209 | W ?= "i" |
210 | variable is set to "someothervalue". | 210 | |
211 | 211 | After parsing we will have:: | |
212 | Again, this assignment is a "lazy" or "weak" assignment because it does | 212 | |
213 | not occur until the end of the parsing process. | 213 | A = "x" |
214 | B = "y" | ||
215 | C = "i" | ||
216 | W = "i" | ||
217 | |||
218 | Appending and prepending non-override style will not substitute the weak | ||
219 | default value, which means that after parsing:: | ||
220 | |||
221 | W ??= "x" | ||
222 | W += "y" | ||
223 | |||
224 | we will have:: | ||
225 | |||
226 | W = " y" | ||
227 | |||
228 | On the other hand, override-style appends/prepends/removes are applied after | ||
229 | any active weak default value has been substituted:: | ||
230 | |||
231 | W ??= "x" | ||
232 | W:append = "y" | ||
233 | |||
234 | After parsing we will have:: | ||
235 | |||
236 | W = "xy" | ||
214 | 237 | ||
215 | Immediate variable expansion (:=) | 238 | Immediate variable expansion (:=) |
216 | --------------------------------- | 239 | --------------------------------- |