aboutsummaryrefslogtreecommitdiffhomepage
path: root/site/docs/skylark
diff options
context:
space:
mode:
authorGravatar Florian Weikert <fwe@google.com>2015-08-24 13:06:31 +0000
committerGravatar Han-Wen Nienhuys <hanwen@google.com>2015-08-24 14:13:31 +0000
commitc6fd0b6ec67a7844ea95ca416ca6d94b0ced2086 (patch)
treebf5de2b63304c45d1510fc62cc052f671a0508f7 /site/docs/skylark
parenta803e0c91480dacbe1f0cbd40da318357f96881d (diff)
Added more details about the use of configuration fragments in Skylark to the documentation.
-- MOS_MIGRATED_REVID=101357875
Diffstat (limited to 'site/docs/skylark')
-rw-r--r--site/docs/skylark/rules.md21
1 files changed, 21 insertions, 0 deletions
diff --git a/site/docs/skylark/rules.md b/site/docs/skylark/rules.md
index d21ddb1742..f450fd0ab9 100644
--- a/site/docs/skylark/rules.md
+++ b/site/docs/skylark/rules.md
@@ -219,6 +219,27 @@ in the attribute.
`DATA_CFG` is present for legacy reasons and should be used for the `data`
attributes.
+<a name="fragments"></a>
+Configuration Fragments
+--------------
+
+Rules may access configuration fragments such as `cpp`, `java` and `jvm`.
+However, all required fragments have to be declared in order to avoid access
+errors:
+
+```python
+def impl(ctx):
+ # Using ctx.fragments.cpp would lead to an error since it was not declared.
+ x = ctx.fragments.java
+ ...
+
+my_rule = rule(
+ implementation=impl,
+ fragments = ["java"],
+ ...
+)
+```
+
Providers
---------