Hey all,
I need some guidance on the shell toolchain I'm working on.
== Background ==
My goals are to let Bazel run without Bash or any shell --
unless you build rules that need it -- and to support other paths than the hardcoded "/bin/bash". The solution seems to be Toolchains, so I introduced the shell toolchain in
commit 84d30975.
== Problem ==
To use a toolchain in an action, the action's owning rule class must declare a dependency on the toolchain_type rule. Therefore every rule that needs to run shell commands has to depend on the toolchain_type rule. Obvious examples are sh_* rules and genrule, and anything that creates a SpawnAction with setShellCommand.
Any Skylark rule may create a shell action with ctx.actions.run_shell, therefore, to not break existing Skylark rules by requiring an explicit toolchain dependency, every Skylark rule by default must depend on the shell toolchain.
Finally, extra actions can shadow any action of any rule class. Extra actions are shell commands, and the extra action's owner is the "target" rule, i.e. that which created the shadowed action, meaning the "target" rule's configuration selects the toolchain, therefore every rule must depend on the shell toolchain.
== Questions ==
(a) Is my problem analysis correct?
(b) Where do I declare the dependency on the toolchain_type?
(c) If every rule depends on the toolchain_type, but the toolchain_type itself is a rule, how do I avoid the cycle?
Thanks,
Laszlo
--
László Csomor | Software Engineer |
laszlo...@google.comGoogle Germany GmbH | Erika-Mann-Str. 33 | 80636 München | Germany
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
Geschäftsführer: Paul Manicle, Halimah DeLaine Prado