diff options
| author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-09-20 15:59:54 +0100 |
|---|---|---|
| committer | Steve Sakoman <steve@sakoman.com> | 2023-10-07 05:39:59 -1000 |
| commit | 7ffedb40a1bae3e287253c1348141fdcee0504a6 (patch) | |
| tree | 027d957d0e7a172d4f8dc8889501c7cc8969989d | |
| parent | 1c8f2d8cad3951c7e5d0be2fd8b630b5e2ad5be8 (diff) | |
| download | poky-7ffedb40a1bae3e287253c1348141fdcee0504a6.tar.gz | |
contributor-guide/style-guide: Add a note about task idempotence
(From yocto-docs rev: 681e6a0a4305057f7b96f5bef804391d8aff812b)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
CC: Yoann Congal <yoann.congal@smile.fr>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
| -rw-r--r-- | documentation/contributor-guide/recipe-style-guide.rst | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/documentation/contributor-guide/recipe-style-guide.rst b/documentation/contributor-guide/recipe-style-guide.rst index 1a1c1c6ee2..b63172bd77 100644 --- a/documentation/contributor-guide/recipe-style-guide.rst +++ b/documentation/contributor-guide/recipe-style-guide.rst | |||
| @@ -257,6 +257,20 @@ Tips and Guidelines for Writing Recipes | |||
| 257 | and ``-nativesdk`` ones, whenever possible. This avoids having to maintain multiple | 257 | and ``-nativesdk`` ones, whenever possible. This avoids having to maintain multiple |
| 258 | recipe files at the same time. | 258 | recipe files at the same time. |
| 259 | 259 | ||
| 260 | - Recipes should have tasks which are idempotent, i.e. that executing a given task | ||
| 261 | multiple times shouldn't change the end result. The build environment is built upon | ||
| 262 | this assumption and breaking it can cause obscure build failures. | ||
| 263 | |||
| 264 | - For idempotence when modifying files in tasks, it is usually best to: | ||
| 265 | |||
| 266 | - copy a file ``X`` to ``X.orig`` (only if it doesn't exist already) | ||
| 267 | - then, copy ``X.orig`` back to ``X``, | ||
| 268 | - and, finally, modify ``X``. | ||
| 269 | |||
| 270 | This ensures if rerun the task always has the same end result and the | ||
| 271 | original file can be preserved to reuse. It also guards against an | ||
| 272 | interrupted build corrupting the file. | ||
| 273 | |||
| 260 | Patch Upstream Status | 274 | Patch Upstream Status |
| 261 | ===================== | 275 | ===================== |
| 262 | 276 | ||
