Skip to content

Commit 88219a3

Browse files
David Tolnayfacebook-github-bot
David Tolnay
authored andcommitted
cargo_env = ["CARGO_CRATE_NAME"]
Summary: I need this for buckifying the next version of rustc after [rust-lang/rust#137834](rust-lang/rust#137834) *"rustc_fluent_macro: use CARGO_CRATE_NAME instead of CARGO_PKG_NAME"* For a Cargo package like this: ``` [package] name = "foo-bar" [lib] name = "baz-quux" ``` the CARGO_PKG_NAME is "foo-bar" (with hyphen) and the CARGO_CRATE_NAME is "baz_quux" (with underscore). https://www.internalfb.com/code/fbsource/[b006779c8e495cf1b16de10324d20a1e61259cb9]/fbcode/common/rust/tools/reindeer/src/fixups.rs?lines=875-877%2C922 Reviewed By: diliop Differential Revision: D73134016 fbshipit-source-id: 494b48d16ab0c3d18132c0a2d190962393453b38
1 parent a3a50e8 commit 88219a3

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

src/fixups.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -872,6 +872,9 @@ impl<'meta> Fixups<'meta> {
872872

873873
for cargo_env in config.cargo_env.iter() {
874874
let v = match cargo_env {
875+
CargoEnv::CARGO_CRATE_NAME => {
876+
StringOrPath::String(self.target.name.replace('-', "_"))
877+
}
875878
CargoEnv::CARGO_MANIFEST_DIR => {
876879
if matches!(self.config.vendor, VendorConfig::Source(_))
877880
|| matches!(self.package.source, Source::Local)

src/fixups/config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ pub enum CargoEnvs {
262262
)]
263263
#[allow(non_camel_case_types)]
264264
pub enum CargoEnv {
265+
CARGO_CRATE_NAME,
265266
CARGO_MANIFEST_DIR,
266267
CARGO_PKG_AUTHORS,
267268
CARGO_PKG_DESCRIPTION,

0 commit comments

Comments
 (0)