仓库指标
- Star
- (25,384 star)
- PR 合并指标
- (平均合并 22天 20小时) (30 天内合并 77 个 PR)
描述
Description of the feature request:
I'd like additional properties on module_ctx.
module_ctx.root_modulewould be anOptional[bazel_module]that would be equivalent to the output of the_find_rootfunction belowmodule_ctx.current_modulewould be abazel_moduleobject corresponding to the module that defined the current module extension (it could possibly be aOptional[bazel_module].
A classic piece of code being written is:
def _find_root(module_ctx):
for mod in module_ctx.module:
if mod.is_root:
return mod
def _find_current_module(module_ctx):
for mod in module_ctx.module:
if mod.name == "rules_rust":
return mod
This would significantly simplify the recommended workflow we prescribe in https://github.com/bazelbuild/bazel/discussions/22024 (eg. https://github.com/bazelbuild/rules_rust/pull/2624)
Which category does this issue belong to?
Core, External Dependency
What underlying problem are you trying to solve with this feature?
Our discussion about the right way to implement toolchains in bazel came to the following conclusion:
The policy would be, for a given toolchain defined by rules_foo which has the tag foo.toolchain:
- If the root module defines a toolchain tag, the toolchain configuration will be:
- Configured based on the root MODULE's
foo.toolchaintag- Any unspecified fields may be inherited from
rules_foo'sfoo.toolchain - Any specified fields must not be affected by
rules_foo'sfoo.toolchain - The toolchain configuration must not be affected by any module other than the root module and
rules_foo
- Any unspecified fields may be inherited from
- If MVS is supported,
rules_foomay choose to compare the root MODULE'sfoo.toolchainwith MVS(all modules'foo.toolchain) in order to output warnings
- Configured based on the root MODULE's
- If the root module doesn't define a toolchain, the toolchain is defined by:
- If MVS is supported, MVS(all modules'
foo.toolchaininvocations) - Otherwise,
rules_foo'sfoo.toolchain
- If MVS is supported, MVS(all modules'
- Non-leaf modules should specify the minimum possible versions and minimal set of features in their
foo.toolchain
This will require special-casing of the root module and the current module extension, both of which seems like something pretty reasonable to me.
Which operating system are you running Bazel on?
linux
What is the output of bazel info release?
7.1.1
If bazel info release returns development version or (@non-git), tell us how you built Bazel.
No response
What's the output of git remote get-url origin; git rev-parse HEAD ?
No response
Have you found anything relevant by searching the web?
No response
Any other information, logs, or outputs that you want to share?
No response