theoremlp / rules_multitool

Bazel rules for ergonomic tool definitions
Apache License 2.0
24 stars 5 forks source link

Unused tools are fetched #59

Closed alexeagle closed 3 weeks ago

alexeagle commented 1 month ago

I'd expect that if I add an entry to multitool.lock.json which is not referenced anywhere, the corresponding toolchain will be defined but the tool itself is never fetched.

However https://github.com/theoremlp/rules_multitool/pull/58 shows a reproduction adding a new entry and it DOES get fetched. This means users with a big lockfile (or who accumulate third-party lockfiles into their hub, such as from rules_lint) will spend time fetching tools they don't need.

mark-thm commented 3 weeks ago

Largely this is the case because the ruleset aims to support workspace users.

alexeagle commented 3 weeks ago

I'd be happy to help with this - but I don't see how workspace is related. Shouldn't the repository rules behave the same regardless whether they are called by a module extension vs. from WORKSPACE or from a repository macro? They produce the same external repos?

mark-thm commented 3 weeks ago

There’s no equivalent to module_ctx in the workspace case, so we need to generate an additional repo which in turn generates the underlying tool/arch repos. If it was just bzlmod it’s pretty trivial to handle.