Skip to content

Commit e3204c5

Browse files
Merge #7464
7464: Export `CARGO` for proc. macros r=jonas-schievink a=jonas-schievink Fixes #7462 bors r+ Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2 parents 6a6a80e + 481a74e commit e3204c5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

crates/project_model/src/build_data.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,14 +175,17 @@ fn is_dylib(path: &Path) -> bool {
175175
/// Should be synced with <https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-crates>
176176
fn inject_cargo_env(package: &cargo_metadata::Package, env: &mut Vec<(String, String)>) {
177177
// FIXME: Missing variables:
178-
// CARGO, CARGO_PKG_HOMEPAGE, CARGO_CRATE_NAME, CARGO_BIN_NAME, CARGO_BIN_EXE_<name>
178+
// CARGO_PKG_HOMEPAGE, CARGO_CRATE_NAME, CARGO_BIN_NAME, CARGO_BIN_EXE_<name>
179179

180180
let mut manifest_dir = package.manifest_path.clone();
181181
manifest_dir.pop();
182182
if let Some(cargo_manifest_dir) = manifest_dir.to_str() {
183183
env.push(("CARGO_MANIFEST_DIR".into(), cargo_manifest_dir.into()));
184184
}
185185

186+
// Not always right, but works for common cases.
187+
env.push(("CARGO".into(), "cargo".into()));
188+
186189
env.push(("CARGO_PKG_VERSION".into(), package.version.to_string()));
187190
env.push(("CARGO_PKG_VERSION_MAJOR".into(), package.version.major.to_string()));
188191
env.push(("CARGO_PKG_VERSION_MINOR".into(), package.version.minor.to_string()));

0 commit comments

Comments
 (0)