-
Notifications
You must be signed in to change notification settings - Fork 248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable users to customize cmake and ninja versions with bzlmod #1157
base: main
Are you sure you want to change the base?
Enable users to customize cmake and ninja versions with bzlmod #1157
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
3bc61ce
to
b80bdab
Compare
b80bdab
to
8cf1aa9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch on this. I think how I would like to see this fixed is in a similar way to #1105 where the toolchains are moved into a hub repo which can be generated with all the user requested toolchain versions in it which should remove the need for the use_repo call to need to bring the repos into scope in the parent module.
for mod in module_ctx.modules: | ||
if not mod.is_root: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to maintain this check - only the root module should declare the versions of the tooling.
Good catch though on this being inverted; this should be if mod.is_root
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way it is written in this PR, we allow any module to declare a version of the tooling but the module that is closest to the root has the precedence. Is there a reason to strictly limit these version declarations to the root module only?
elif cmake_versions_count > 1: | ||
fail("More than one cmake version requested: {}".format(mod.tags.cmake)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should be able to support registering more than one version of cmake in a build. We should probably generate a version specific constraint that we apply to the toolchain targets so that a user can select a version constraint that way if they desire.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do support declaring more than one version of cmake, but each such declaration should be in a different module. Here we simply guard against multiple declarations in the same module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By removing the version number from the generated names though you will get duplicate definitions if a module defines one version and then the root requests a different version. This is also the rationale for restricting definitions to the root module at least for the time being.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While we do allow specifying several versions of cmake/ninja, only one version wins—the one closest to the root module (see break
in the "then" clause). Also, there can only be one version per module, so this should be very close to the old logic with the exception that the user can actually configure the versions.
Actually I have to say I didn't get as far with #1105 as I'd remembered and had only moved the toolchains so that I can register them via |
8cf1aa9
to
75fc4d2
Compare
@jsharpe Is there anything I can do to help this progress? What do you think about my replies above? |
This demonstrates that the way it is organized right now, `rules_foreign_cc` does not allow its users to opt for a non-default version of cmake.
Avoid hardcoding cmake and ninja versions in repository names that the bzlmod extension produces.
75fc4d2
to
e0f5959
Compare
Apologies the limiting factor here is my time availability to work on this as I only maintain this in my spare time. |
But if there is only one version of a given tool that is selected in the end, does it make a difference whether its repo name includes the version or it is generic? In any case, this patch solved our immediate problem and we don't think that we will have much more time to contribute to a more elaborate redesign. |
There seem to be no way to override the default cmake (or ninja) version with a tag, although it looks like that was the original intention behind the bzlmod extension. The problem is
if not mod.is_root:
use_repo
andregister_toolchains
invocations inMODULE.bazel
ofrules_foreign_cc
have to mention the default version of cmake because it is part of the repository name that provides the toolchain (why?) and soMODULE.bazel
is incompatible in the case of an override by the user.This PR resolves both these issues.