Use cargo name as the CARGO_CRATE_NAME instead of package name
This commit is contained in:
parent
f29867bd26
commit
506a477acf
@ -2,7 +2,7 @@
|
||||
//! metadata` or `rust-project.json`) into representation stored in the salsa
|
||||
//! database -- `CrateGraph`.
|
||||
|
||||
use std::{collections::VecDeque, fmt, fs, process::Command, sync};
|
||||
use std::{collections::VecDeque, fmt, fs, process::Command, str::FromStr, sync};
|
||||
|
||||
use anyhow::{format_err, Context};
|
||||
use base_db::{
|
||||
@ -1228,6 +1228,10 @@ fn add_target_crate_root(
|
||||
|
||||
let mut env = Env::default();
|
||||
inject_cargo_env(pkg, &mut env);
|
||||
if let Ok(cname) = String::from_str(cargo_name) {
|
||||
// CARGO_CRATE_NAME is the name of the Cargo target with - converted to _, such as the name of the library, binary, example, integration test, or benchmark.
|
||||
env.set("CARGO_CRATE_NAME", cname.replace("-", "_"));
|
||||
}
|
||||
|
||||
if let Some(envs) = build_data.map(|it| &it.envs) {
|
||||
for (k, v) in envs {
|
||||
|
@ -162,7 +162,7 @@
|
||||
"CARGO_MANIFEST_DIR": "$ROOT$hello-world",
|
||||
"CARGO_PKG_VERSION": "0.1.0",
|
||||
"CARGO_PKG_AUTHORS": "",
|
||||
"CARGO_CRATE_NAME": "hello_world",
|
||||
"CARGO_CRATE_NAME": "an_example",
|
||||
"CARGO_PKG_LICENSE_FILE": "",
|
||||
"CARGO_PKG_HOMEPAGE": "",
|
||||
"CARGO_PKG_DESCRIPTION": "",
|
||||
@ -232,7 +232,7 @@
|
||||
"CARGO_MANIFEST_DIR": "$ROOT$hello-world",
|
||||
"CARGO_PKG_VERSION": "0.1.0",
|
||||
"CARGO_PKG_AUTHORS": "",
|
||||
"CARGO_CRATE_NAME": "hello_world",
|
||||
"CARGO_CRATE_NAME": "it",
|
||||
"CARGO_PKG_LICENSE_FILE": "",
|
||||
"CARGO_PKG_HOMEPAGE": "",
|
||||
"CARGO_PKG_DESCRIPTION": "",
|
||||
|
@ -162,7 +162,7 @@
|
||||
"CARGO_MANIFEST_DIR": "$ROOT$hello-world",
|
||||
"CARGO_PKG_VERSION": "0.1.0",
|
||||
"CARGO_PKG_AUTHORS": "",
|
||||
"CARGO_CRATE_NAME": "hello_world",
|
||||
"CARGO_CRATE_NAME": "an_example",
|
||||
"CARGO_PKG_LICENSE_FILE": "",
|
||||
"CARGO_PKG_HOMEPAGE": "",
|
||||
"CARGO_PKG_DESCRIPTION": "",
|
||||
@ -232,7 +232,7 @@
|
||||
"CARGO_MANIFEST_DIR": "$ROOT$hello-world",
|
||||
"CARGO_PKG_VERSION": "0.1.0",
|
||||
"CARGO_PKG_AUTHORS": "",
|
||||
"CARGO_CRATE_NAME": "hello_world",
|
||||
"CARGO_CRATE_NAME": "it",
|
||||
"CARGO_PKG_LICENSE_FILE": "",
|
||||
"CARGO_PKG_HOMEPAGE": "",
|
||||
"CARGO_PKG_DESCRIPTION": "",
|
||||
|
@ -159,7 +159,7 @@
|
||||
"CARGO_MANIFEST_DIR": "$ROOT$hello-world",
|
||||
"CARGO_PKG_VERSION": "0.1.0",
|
||||
"CARGO_PKG_AUTHORS": "",
|
||||
"CARGO_CRATE_NAME": "hello_world",
|
||||
"CARGO_CRATE_NAME": "an_example",
|
||||
"CARGO_PKG_LICENSE_FILE": "",
|
||||
"CARGO_PKG_HOMEPAGE": "",
|
||||
"CARGO_PKG_DESCRIPTION": "",
|
||||
@ -228,7 +228,7 @@
|
||||
"CARGO_MANIFEST_DIR": "$ROOT$hello-world",
|
||||
"CARGO_PKG_VERSION": "0.1.0",
|
||||
"CARGO_PKG_AUTHORS": "",
|
||||
"CARGO_CRATE_NAME": "hello_world",
|
||||
"CARGO_CRATE_NAME": "it",
|
||||
"CARGO_PKG_LICENSE_FILE": "",
|
||||
"CARGO_PKG_HOMEPAGE": "",
|
||||
"CARGO_PKG_DESCRIPTION": "",
|
||||
|
Loading…
x
Reference in New Issue
Block a user