Making the outputs of a build rule available as `sh_binary` data

351 views
Skip to first unread message

Filip Filmar

unread,
Nov 9, 2021, 8:33:10 PM11/9/21
to bazel-discuss
Hi folks.

Is there something special I need to return from an impl function of a build rule, such that its output
may appear in the `data =...` section of a `sh_binary`?

This, for example, works. In the sense that the binary `hello` appears in the runfiles for `:sh_bin` when `:sh_bin` is run, and is available to the script to use:

```
cc_binary(name = "hello", srcs = [ "main.cc" ])
sh_binary(name = "sh_bin", srcs = [ "script.sh"], data = [ ":hello"])
```

However, a superficially similar situation with a rule I wrote does not behave the same way:

```
some_rule_i_wrote(name = "hello", srcs = [ ...  ])
sh_binary(name = "sh_bin", srcs = [ "script.sh"], data = [ ":hello"])
```

In the sense that the output of `some_rule_i_wrote` does *not* appear in the runfiles for `:sh_bin`.  Is there a specific provider that I need to return from the implementation of `some_rule_i_wrote` to ensure that I can use its outputs as `data`?

This is an abstract example; but the actual rule that I'm scrutinizing is here.  The returned provider is here.  What am I missing?

Thank you,
F

Filip Filmar

unread,
Nov 9, 2021, 8:38:52 PM11/9/21
to bazel-discuss
Oh, it looks like this post from jayconrod.com talks exactly about this.

F

Reply all
Reply to author
Forward
0 new messages