-
Notifications
You must be signed in to change notification settings - Fork 249
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
Add <rule>_variant macros #734
Conversation
foreign_cc/nmake.bzl
Outdated
load(":configure.bzl", "configure_make") | ||
|
||
def _extra_toolchains_transition_impl(settings, attrs): | ||
return {"//command_line_option:extra_toolchains": attrs.extra_toolchains + settings["//command_line_option:extra_toolchains"]} |
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'm not too familiar with extra toolchains, can you explain how this can use a toolchain that isn't registered? What's the guarantee that the thing that's returned here is going to be used for the target if another toolchain was matched?
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.
Sure
extra_toolchains
are considered before those registered in a WORKSPACE file (by register_toolchains
). As such, by applying the transition it is like the target is being built like
bazel build <target> --extra_toolchains="@rules_foreign_cc//toolchains:preinstalled_nmake_toolchain"
and the nmake toolchain will be considered before the toolchains registered in the WORKSPACE file
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 personally prefer this approach to transitioning the host platform as I think it is less confusing.
When transitioning the host platform, the transition is from a Windows OS platform targeting MSVC to a Windows OS platform targeting MSVC. Essentially the approach leverages this issue.
2f59b54
to
91147fc
Compare
@UebelAndre How does this PR look now? To see how the new |
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.
This looks good to me! I had one nit but the real reason I didn't click approve was to ask if you could update the PR title and description 🙏 😄
Thanks for working so hard on this!
91147fc
to
9befdc0
Compare
I've updated the PR title and description 👍 |
5992d02
to
e608dcf
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.
Looks good to me! Thanks for working with me on this and all the hard work you've put in!
Buildifier seems unhappy and would like @jsharpe to take a look too but I'm happy here!
e608dcf
to
0c16c94
Compare
My pleasure! :) |
Hi @jsharpe, If you are happy with this PR, could you please merge it? 😁 |
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.
Apologies for the delay in getting round to reviewing this.
One small bit of logic to fix up around the handling of tags
but otherwise I think I'm happy with this.
The macros utilise bazel "transitions" to set the `make` toolchain used in the configure_make(), cmake() or make() rules to a given make variant toolchain, e.g. preinstalled_nmake. Note that the msvc constraint was removed from the `exec_compatible_with` attribute of `preinstalled_nmake_toolchain` as the condition is not actually met even when building with msvc. See bazelbuild/bazel#7730. This will be tested in PR#729
0c16c94
to
52da86b
Compare
The macros utilise bazel "transitions" to set the
make
toolchain tobe the preinstalled
nmake
tool.Note that the msvc constraint was removed from the
exec_compatible_with
attribute ofpreinstalled_nmake_toolchain
asthe condition is not actually met even when building with msvc. See
bazelbuild/bazel#7730.
This will be tested in PR #729