| Summary: | Suggested clarification and motivation for the override-style operators | ||
|---|---|---|---|
| Product: | [Documentation] BitBake User Manual | Reporter: | ulfalizer |
| Component: | bitbake-manual | Assignee: | Scott Rifenbark <srifenbark> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | Medium | CC: | bluelightning, sgw, srifenbark |
| Version: | 2.2 | ||
| Target Milestone: | 2.2 M3 | ||
| Hardware: | x86 | ||
| OS: | Multiple | ||
| Whiteboard: | 01 August 2016: IN PROGRESS REVIEW | ||
| OS type for building Yocto: | --- | Type of Regression: | --- |
| Verified: | Documentation change: | Done (doc changes complete) | |
Ulf, Here is the change for 3.1.9 - http://www.yoctoproject.org/docs/2.2/bitbake-user-manual/bitbake-user-manual.html#removing-override-style-syntax Here is the new 3.1.10 section - http://www.yoctoproject.org/docs/2.2/bitbake-user-manual/bitbake-user-manual.html#override-style-operation-advantages Here is the 3.2.3 change - http://www.yoctoproject.org/docs/2.2/bitbake-user-manual/bitbake-user-manual.html#variable-interaction-worked-examples. thanks, Scott A few nits, otherwise fine: - "...changing the second assignment in the previous example..." would be clearer as "...changing the second assignment in the previous example to use ':='..." - There's an ending parenthesis missing in "(due to how the '+=' operator works." - The following also needs to say "ZX" rather than "Z X". I missed that when I first went through it: Finally, applying the override for "foo" results in the conditional variable A becoming "Z X" (i.e. A is replaced with A_foo). Thanks Here are the changes: * http://www.yoctoproject.org/docs/2.2/bitbake-user-manual/bitbake-user-manual.html#override-style-operation-advantages * http://www.yoctoproject.org/docs/2.2/bitbake-user-manual/bitbake-user-manual.html#variable-interaction-worked-examples I wondered about the second one. I almost went ahead and changed it but figured if it was wrong you would catch it. Scott You put too much trust in me. ;) Looks good to me now. Thanks. Thanks - closing out. Ops... I made a typo: ...example to use ":=" would be to add... should be ...example to use "+=" would be to add... Ulf, See the note in http://www.yoctoproject.org/docs/2.2/bitbake-user-manual/bitbake-user-manual.html#override-style-operation-advantages for the fix. I should have realized that had to change as well. Scott Hello, As mentioned in bug 9984, the changes for this bug disappeared. Other changes besides 9984 and 9985 might be affected too. Cheers, Ulf Check the link again for the change... Same explanation as the Bug 9984. Scott Looks good now! Thanks, Ulf Cool - setting doc flag to "done" |
Hello, I suspect the override-style operators (_append, _prepend, _remove) would be much easier to understand if some motivation was given. The existing descriptions are also vague in places. I suggest the following changes: Add to the end of '3.1.9. Removal (Override Style Syntax)': Like _append and _prepend, _remove is deferred until after parsing completes. Add a new section '3.1.10 Motivation behind the override-style operations': An advantage of the override-style operations _append, _prepend, and _remove (compared to e.g. += and =+) is that they provide "guaranteed" operations. For example, consider a class foo.bbclass that needs to add the value "val" to the variable FOO, and a recipe that uses foo.bbclass as follows: inherit foo FOO = "initial" If foo.bbclass uses the '+=' operator, as follows, then the final value of FOO will be "initial", which is not what we want: FOO += "val" If on the other hand foo.bbclass uses the _append operator, as follows, then the final value of FOO will be "initial val", as intended: FOO_append = " val" Note { It is never necessary to use += together with _append. The following sequence of assignments will append "barbaz" to FOO: FOO_append = "bar" FOO_append = "baz" The only effect of changing the second assignment to FOO_append += "baz" is to add a space before "baz" in the appended value (due to how the += operator works). } Another advantage of the override-style operations is that they can be combined with other overrides, as described in [3.2. Conditional Syntax (Overrides)]. In '3.2.3. Examples', change OVERRIDES = "foo" A = "Y" A_foo_append = "Z" A_foo_append += "X" to OVERRIDES = "foo" A = "Y" A_foo_append = "Z" A_foo_append = "X" and change ...leaving the variable set to "Z X" to ...leaving the variable set to "ZX" This avoids tricking people into thinking += is necessary when using _append. I tested it out to make sure it was correct. Cheers, Ulf