diff options
| -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 | --------------------------------- |
