Update runfiles usage example to use merge_all()
In the example, we are merging a potentially very large list of runfiles - so we
should be using merge_all() to avoid exceeding depset depth limits, instead of
calling merge() in a loop.
RELNOTES: None.
PiperOrigin-RevId: 364640619
diff --git a/site/docs/skylark/rules.md b/site/docs/skylark/rules.md
index 050d6bc..27efefa 100644
--- a/site/docs/skylark/rules.md
+++ b/site/docs/skylark/rules.md
@@ -497,8 +497,11 @@
def _example_library_impl(ctx):
...
runfiles = ctx.runfiles(files = ctx.files.data)
- for target in ctx.attr.srcs + ctx.attr.hdrs + ctx.attr.deps + ctx.attr.data:
- runfiles = runfiles.merge(target[DefaultInfo].default_runfiles)
+ all_targets = ctx.attr.srcs + ctx.attr.hdrs + ctx.attr.deps + ctx.attr.data
+ runfiles = runfiles.merge_all([
+ target[DefaultInfo].default_runfiles
+ for target in all_targets
+ ])
return [
DefaultInfo(..., runfiles = runfiles),
...