bazel-contrib / rules-template

A template for creating a new Bazel ruleset
Apache License 2.0
78 stars 20 forks source link

Consider moving resolved_toolchain into the "mylang" workspace #47

Closed aherrmann closed 1 year ago

aherrmann commented 1 year ago

The mylang_register_toolchains macro invokes toolchains_repo which generates a toolchain target for each platform as well as a resolved_toolchains target that acts as an alias for the currently resolved toolchain. This is intended as a workaround for https://github.com/bazelbuild/bazel/issues/14009 to expose make variables to rules that want to directly depend on the "mylang" toolchain, e.g. genrule.

Because the resolved_toolchains target is generated as part of toolchains_repo users have to know and use the name given to that external workspace. E.g. in the example setup a user would have to use the label @mylang1_14_toolchains//:resolved_toolchain. This is problematic:

There is no reason why resolved_toolchains has to part of or linked to toolchains_repo or mylang_register_toolchain. I propose that resolved_toolchains should be defined in com_myorg_rules_mylang directly, instead.