aboutsummaryrefslogtreecommitdiffhomepage
path: root/site/docs/skylark/cookbook.md
diff options
context:
space:
mode:
authorGravatar Florian Weikert <fwe@google.com>2016-06-30 14:08:21 +0000
committerGravatar Lukacs Berki <lberki@google.com>2016-07-01 07:07:59 +0000
commit425ba588a696db553eb2f025a03eed591e378e05 (patch)
treed103ae91360a5ccfd52b46cf94c1204b3c7053cc /site/docs/skylark/cookbook.md
parentf6c24decc9cea46bfba41efb07f11b1ce7415cd0 (diff)
Skylark documentation update: callback functions have to list the required attributes as their parameters (instead of using an attribute map).
-- MOS_MIGRATED_REVID=126298988
Diffstat (limited to 'site/docs/skylark/cookbook.md')
-rw-r--r--site/docs/skylark/cookbook.md13
1 files changed, 9 insertions, 4 deletions
diff --git a/site/docs/skylark/cookbook.md b/site/docs/skylark/cookbook.md
index 8dfe03ebe2..3a5430a29d 100644
--- a/site/docs/skylark/cookbook.md
+++ b/site/docs/skylark/cookbook.md
@@ -527,9 +527,14 @@ execute(
Bazel needs to know about all dependencies before doing the analysis phase and
calling the implementation function. Dependencies can be computed based on the
-rule attributes and the configuration: to do so, use a function as the default
+rule attributes: to do so, use a function as the default
value of an attribute (the attribute must be private and have type `label` or
-`list of labels`).
+`list of labels`). The parameters of this function must correspond to the
+attributes that are accessed in the function body.
+
+Note: For legacy reasons, the function takes the configuration as an additional
+parameter. Please do not rely on the configuration since it will be removed in
+the future.
The example below computes the md5 sum of a file. The file can be preprocessed
using a filter. The exact dependencies depend on the filter chosen by the user.
@@ -543,10 +548,10 @@ _filters = {
"none": None,
}
-def _get_filter(attr_map, cfg):
+def _get_filter(filter, cfg=None): # requires attribute "filter"
# Return the value for the attribute "_filter_bin"
# It can be a label or None.
- return _filters[attr_map.filter]
+ return _filters[filter]
def _impl(ctx):
src = ctx.file.src