Skip to content

Commit

Permalink
Update aspects documentation to the latest and greatest APIs.
Browse files Browse the repository at this point in the history
Change-Id: I76d785dbbcd2c5cf30ab5d130e82b2819931651a
PiperOrigin-RevId: 162672358
  • Loading branch information
dslomov authored and aehlig committed Jul 21, 2017
1 parent 99b2ece commit 67f42c3
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions site/docs/skylark/aspects.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,23 +116,23 @@ functions. They return [providers](rules.md#providers), can generate
Example:

```python
MetalProtoInfo = provider()
def _metal_proto_aspect_impl(target, ctx):
# For every `src` in proto_library, generate an output file
proto_sources = [f for src in ctx.rule.attr.srcs
for f in src.files]
outputs = [ctx.new_file(f.short_path + ".metal")
outputs = [ctx.actions.declare_file(f.short_path + ".metal")
for f in proto_sources]
ctx.action(
ctx.actions.run(
executable = ctx.executable._protoc,
argument = ...
inputs = proto_sources
outputs = outputs)
transitive_outputs = depset(outputs)
for dep in ctx.rule.attr.deps:
transitive_outputs = transitive_outputs | dep.metal_proto.transitive_outputs
return struct(
metal_proto = struct(direct_outputs = outputs,
transitive_outputs = transitive_outputs))
return [MetalProtoInfo(direct_outputs = outputs,
transitive_outputs = transitive_outputs)]
```

The implementation function can access the attributes of the target rule via
Expand Down

0 comments on commit 67f42c3

Please sign in to comment.