-
Notifications
You must be signed in to change notification settings - Fork 402
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 the CARGO_CRATE_NAME env var #537
Conversation
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.
Thanks for the contribution! I agree that we should set this env var, but I think we should maybe set it to a slightly different value - let me know what you think :)
To see cargo's behaviour:
$ cargo init crate-with-dashes
$ cd crate-with-dashes
$ cat >src/main.rs <<EOF
fn main() {
println!("CARGO_CRATE_NAME: {}", env!("CARGO_CRATE_NAME"));
println!("CARGO_PKG_NAME: {}", env!("CARGO_PKG_NAME"));
}
EOF
$ cargo run --quiet
CARGO_CRATE_NAME: crate_with_dashes
CARGO_PKG_NAME: crate-with-dashes
107eeea
to
883a04c
Compare
Sorry for the delay! Unfortunately this PR now goes the wrong way around: |
Friendly ping from a bywalker :) |
Thanks for the ping, this fell of my todo list :) I will push changes asap. Am I right in saying that 'crate_name' in rules rust actually refers to the pkg name then? ie. It feels inconsistent so I want to get it right: ctx.attr.crate_name == "my-cool_crate"
pkg_name = ctx.attr.crate_name
crate_name = pkg_name.replace("_", "-")
pkg_name == "my-cool_crate"
crate_name == "my_cool_crate" |
Friendly drive-by ping, any updates here? 😄 |
We're not far off, but if the crate name in rules_rust is in fact the pkg_name then that differenciation should be reflected in the properties in the attributes and we should rename it. I'm not sure about the implications of this though so some feedback would be helpful. |
That's a really good point! And I think we can answer it with my favourite answer of all: Let's delete the attribute! As far as I can tell, we currently use the
(Worthy of note, we don't use it for the thing it was originally added for in #341, which was to set So I'd be tempted to delete the |
SGTM, I'm a big fan of deleting and simplifying code, let's do this! |
Closing after a more comprehensive solution here #643 thanks all! |
See #536 for more discussion.