From c6fd0b6ec67a7844ea95ca416ca6d94b0ced2086 Mon Sep 17 00:00:00 2001 From: Florian Weikert Date: Mon, 24 Aug 2015 13:06:31 +0000 Subject: Added more details about the use of configuration fragments in Skylark to the documentation. -- MOS_MIGRATED_REVID=101357875 --- site/docs/skylark/rules.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'site/docs/skylark') 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. + +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 --------- -- cgit v1.2.3