diff options
author | Jacob Kroon <jacob.kroon@gmail.com> | 2022-06-15 11:23:45 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-06-21 20:50:57 +0100 |
commit | 1c020325647d7c7e7ad77bfdf2fdafbe0e2b62ab (patch) | |
tree | 8ee81fece9bbc782a739cbee79643d0a4cab6656 /bitbake | |
parent | 5aca7a8f10e16c402a1f2625f9c34a3accb9c6cc (diff) | |
download | poky-1c020325647d7c7e7ad77bfdf2fdafbe0e2b62ab.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: 8189f58d0449d16f162b6e8d98c4e5edc6bff875)
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>
Diffstat (limited to 'bitbake')
-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 | --------------------------------- |