Skip to content

Commit

Permalink
Remove copy_from_rule from Bazel documentation since it's deprecated
Browse files Browse the repository at this point in the history
More context at bazelbuild#17668.

PiperOrigin-RevId: 531442266
Change-Id: I2e2fa7652b063d7a6b7bc6034e3ff07f065f346e
  • Loading branch information
kotlaja authored and fweikert committed May 25, 2023
1 parent c50b3ec commit f0825b7
Showing 1 changed file with 0 additions and 72 deletions.
72 changes: 0 additions & 72 deletions site/en/extending/exec-groups.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,48 +62,6 @@ built.
As on native rules, the `test` execution group is present by default on Starlark
test rules.

### Execution group inheritance {:#exec-group-inheritance}

In addition to defining its own constraints and toolchains, a new execution
group can declare that it wants to inherit from the rule's default execution
group, by passing the `copy_from_rule = True` parameter. It is an error to set
`copy_from_rule` to true and to also pass `exec_compatible_with` or
`toolchains`.

An execution group that inherits from the default execution group copies
constraints, toolchains, and execution properties from the default. This
includes constraints and execution properties set on the target level, not just
those specified by the rule itself. In other words, given the following:

```python
# foo.bzl
my_rule = rule(
_impl,
exec_groups = {
“copied”: exec_group(
copy_from_rule = True,
# This will inherit exec_compatible_with and toolchains.
# Setting them here directly would be an error, however.
),
},
toolchains = ["//foo_tools:toolchain_type"],
exec_compatible_with = ["@platforms//os:linux"],
)

# BUILD

my_rule(
name = "demo",
exec_compatible_with = [":local_constraint"],
)
```

The `copied` execution group for the configured target `demo` will include all
of:
- `//fool_tools:toolchain_type`
- `@platforms//os:linux`
- `:local_constraint`

## Accessing execution groups {:#accessing-exec-groups}

In the rule implementation, you can declare that actions should be run on the
Expand Down Expand Up @@ -175,36 +133,6 @@ The following execution groups are available for actions defined by native rules
* `test`: Test runner actions.
* `cpp_link`: C++ linking actions.

### Creating exec groups to set exec properties {:#creating-exec-groups-for-exec-properties}

Sometimes you want to use an exec group to give specific actions different exec
properties but don't actually want different toolchains or constraints than the
rule. For these situations, you can create exec groups using the `copy_from_rule`
parameter:

```python
# foo.bzl

# Creating an exec group with `copy_from_rule=True` is the same as explicitly
# setting the exec group's toolchains and constraints to the same values as the
# rule's respective parameters.
my_rule = rule(
_impl,
exec_compatible_with = ["@platforms//os:linux"],
toolchains = ["//foo:toolchain_type"],
exec_groups = {
# The following two groups have the same toolchains and constraints:
“foo”: exec_group(copy_from_rule = True),
"bar": exec_group(
exec_compatible_with = ["@platforms//os:linux"],
toolchains = ["//foo:toolchain_type"],
),
},
)

#
```

### Execution groups and platform execution properties {:#platform-execution-properties}

It is possible to define `exec_properties` for arbitrary execution groups on
Expand Down

0 comments on commit f0825b7

Please sign in to comment.