-
Notifications
You must be signed in to change notification settings - Fork 524
Make get_host_triple public to get a triple from Bazel's repository_ctx #1289
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
Conversation
| version = "1.53.0", | ||
| iso_date = None, | ||
| target_triple = target_triple, | ||
| target_triple = host_triple.str, |
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 added a str field to the struct returned by triple("..."), because triple.triple didn't strike me as evocative enough. str makes sense to me as the string representation of the triple, which is what target_triple wants.
Alternatively we could look into making target_triple accept the triple struct directly, or union of triple struct and string so that either way works.
Or we could make get_host_triple return the string and not the struct, forcing triple(get_host_triple(repository_ctx)) when someone needs the struct.
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 added a str field to the struct returned by triple("..."), because triple.triple didn't strike me as evocative enough. str makes sense to me as the string representation of the triple, which is what target_triple wants.
I'm fine with the use of str but I'd prefer there to be either str or triple. Could you maybe update the docstring to indicate which of the two is the correct to use?
I added a
strfield to the struct returned bytriple("..."), becausetriple.tripledidn't strike me as evocative enough.strmakes sense to me as the string representation of the triple, which is whattarget_triplewants.Alternatively we could look into making
target_tripleaccept the triple struct directly, or union of triple struct and string so that either way works.Or we could make
get_host_triplereturn the string and not the struct, forcingtriple(get_host_triple(repository_ctx))when someone needs the struct.
I think I would prefer to continue to pass the triple struct until we find a performance reason to do otherwise. We have a lot of places where we parse the same string over and over. I expect passing a struct to be slightly better.
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.
- str (str): Original string representation of the triple
- - triple (str): Same as str
+ - triple (str): Deprecated; same as strI'll open another PR after this to remove triple so that we can discuss that independently of this change.
UebelAndre
left a comment
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!
If you could update one comment and rebase we can get this in 😄
| version = "1.53.0", | ||
| iso_date = None, | ||
| target_triple = target_triple, | ||
| target_triple = host_triple.str, |
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 added a str field to the struct returned by triple("..."), because triple.triple didn't strike me as evocative enough. str makes sense to me as the string representation of the triple, which is what target_triple wants.
I'm fine with the use of str but I'd prefer there to be either str or triple. Could you maybe update the docstring to indicate which of the two is the correct to use?
I added a
strfield to the struct returned bytriple("..."), becausetriple.tripledidn't strike me as evocative enough.strmakes sense to me as the string representation of the triple, which is whattarget_triplewants.Alternatively we could look into making
target_tripleaccept the triple struct directly, or union of triple struct and string so that either way works.Or we could make
get_host_triplereturn the string and not the struct, forcingtriple(get_host_triple(repository_ctx))when someone needs the struct.
I think I would prefer to continue to pass the triple struct until we find a performance reason to do otherwise. We have a lot of places where we parse the same string over and over. I expect passing a struct to be slightly better.
I found half-baked duplicate implementations of this logic in cargo-raze, in cxx, and in rules_rust's test suite of the load_arbitrary_tool function. It seems such logic is necessary for correctly using load_arbitrary_tool from the implementation of a repository_rule.
|
Rebased and updated the documentation of the return type of - str (str): Original string representation of the triple
- - triple (str): Same as str
+ - triple (str): Deprecated; same as strI'll open another PR after this to remove |
I found half-baked duplicate implementations of this logic in cargo-raze (examples_repository.bzl), in cxx (vendor.bzl), and in rules_rust's test suite of the load_arbitrary_tool function (load_arbitrary_tool_test.bzl). It seems such logic is necessary for correctly using load_arbitrary_tool from the implementation of a repository_rule.
Documentation
Example:
Args:
repository_ctx(repository_ctx): The repository_rule's context objectabi(str): Since there's no consistent way to check for ABI, this info may be explicitly providedReturns:
struct: A triple struct; see thetriplefunction in this module