Skip to content

Commit b48336b

Browse files
committed
Replace OUT_DIR in project.json with general env
OUT_DIR doesn't make sense here, as this is a cargo-specific concept
1 parent fe87aec commit b48336b

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

crates/ra_project_model/src/lib.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -259,11 +259,8 @@ impl ProjectWorkspace {
259259
let file_id = load(&file_path)?;
260260

261261
let mut env = Env::default();
262-
if let Some(out_dir) = &krate.out_dir {
263-
// NOTE: cargo and rustc seem to hide non-UTF-8 strings from env! and option_env!()
264-
if let Some(out_dir) = out_dir.to_str().map(|s| s.to_owned()) {
265-
env.set("OUT_DIR", out_dir);
266-
}
262+
for (k, v) in &krate.env {
263+
env.set(k, v.clone());
267264
}
268265
let proc_macro = krate
269266
.proc_macro_dylib_path

crates/ra_project_model/src/project_json.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::path::PathBuf;
55
use paths::{AbsPath, AbsPathBuf};
66
use ra_cfg::CfgOptions;
77
use ra_db::{CrateId, CrateName, Dependency, Edition};
8-
use rustc_hash::FxHashSet;
8+
use rustc_hash::{FxHashMap, FxHashSet};
99
use serde::{de, Deserialize};
1010
use stdx::split_delim;
1111

@@ -24,7 +24,7 @@ pub struct Crate {
2424
pub(crate) deps: Vec<Dependency>,
2525
pub(crate) cfg: CfgOptions,
2626
pub(crate) target: Option<String>,
27-
pub(crate) out_dir: Option<AbsPathBuf>,
27+
pub(crate) env: FxHashMap<String, String>,
2828
pub(crate) proc_macro_dylib_path: Option<AbsPathBuf>,
2929
pub(crate) is_workspace_member: bool,
3030
pub(crate) include: Vec<AbsPathBuf>,
@@ -78,7 +78,7 @@ impl ProjectJson {
7878
cfg
7979
},
8080
target: crate_data.target,
81-
out_dir: crate_data.out_dir.map(|it| base.join(it)),
81+
env: crate_data.env,
8282
proc_macro_dylib_path: crate_data
8383
.proc_macro_dylib_path
8484
.map(|it| base.join(it)),
@@ -105,7 +105,8 @@ struct CrateData {
105105
#[serde(default)]
106106
cfg: FxHashSet<String>,
107107
target: Option<String>,
108-
out_dir: Option<PathBuf>,
108+
#[serde(default)]
109+
env: FxHashMap<String, String>,
109110
proc_macro_dylib_path: Option<PathBuf>,
110111
is_workspace_member: Option<bool>,
111112
source: Option<CrateSource>,

0 commit comments

Comments
 (0)