diff options
-rw-r--r-- | crates/ra_project_model/src/json_project.rs | 1 | ||||
-rw-r--r-- | crates/ra_project_model/src/lib.rs | 24 |
2 files changed, 22 insertions, 3 deletions
diff --git a/crates/ra_project_model/src/json_project.rs b/crates/ra_project_model/src/json_project.rs index 1bacb1d09..336446e58 100644 --- a/crates/ra_project_model/src/json_project.rs +++ b/crates/ra_project_model/src/json_project.rs | |||
@@ -22,6 +22,7 @@ pub struct Crate { | |||
22 | pub(crate) deps: Vec<Dep>, | 22 | pub(crate) deps: Vec<Dep>, |
23 | pub(crate) atom_cfgs: FxHashSet<String>, | 23 | pub(crate) atom_cfgs: FxHashSet<String>, |
24 | pub(crate) key_value_cfgs: FxHashMap<String, String>, | 24 | pub(crate) key_value_cfgs: FxHashMap<String, String>, |
25 | pub(crate) out_dir: Option<PathBuf>, | ||
25 | } | 26 | } |
26 | 27 | ||
27 | #[derive(Clone, Copy, Debug, Deserialize)] | 28 | #[derive(Clone, Copy, Debug, Deserialize)] |
diff --git a/crates/ra_project_model/src/lib.rs b/crates/ra_project_model/src/lib.rs index b2c3e576d..081b1fec2 100644 --- a/crates/ra_project_model/src/lib.rs +++ b/crates/ra_project_model/src/lib.rs | |||
@@ -152,7 +152,15 @@ impl ProjectWorkspace { | |||
152 | 152 | ||
153 | pub fn out_dirs(&self) -> Vec<PathBuf> { | 153 | pub fn out_dirs(&self) -> Vec<PathBuf> { |
154 | match self { | 154 | match self { |
155 | ProjectWorkspace::Json { project: _project } => vec![], | 155 | ProjectWorkspace::Json { project } => { |
156 | let mut out_dirs = Vec::with_capacity(project.crates.len()); | ||
157 | for krate in &project.crates { | ||
158 | if let Some(out_dir) = &krate.out_dir { | ||
159 | out_dirs.push(out_dir.to_path_buf()); | ||
160 | } | ||
161 | } | ||
162 | out_dirs | ||
163 | } | ||
156 | ProjectWorkspace::Cargo { cargo, sysroot: _sysroot } => { | 164 | ProjectWorkspace::Cargo { cargo, sysroot: _sysroot } => { |
157 | let mut out_dirs = Vec::with_capacity(cargo.packages().len()); | 165 | let mut out_dirs = Vec::with_capacity(cargo.packages().len()); |
158 | for pkg in cargo.packages() { | 166 | for pkg in cargo.packages() { |
@@ -202,6 +210,16 @@ impl ProjectWorkspace { | |||
202 | opts | 210 | opts |
203 | }; | 211 | }; |
204 | 212 | ||
213 | let mut env = Env::default(); | ||
214 | let mut extern_source = ExternSource::default(); | ||
215 | if let Some(out_dir) = &krate.out_dir { | ||
216 | // FIXME: We probably mangle non UTF-8 paths here, figure out a better solution | ||
217 | env.set("OUT_DIR", out_dir.to_string_lossy().to_string()); | ||
218 | if let Some(&extern_source_id) = extern_source_roots.get(out_dir) { | ||
219 | extern_source.set_extern_path(&out_dir, extern_source_id); | ||
220 | } | ||
221 | } | ||
222 | |||
205 | // FIXME: No crate name in json definition such that we cannot add OUT_DIR to env | 223 | // FIXME: No crate name in json definition such that we cannot add OUT_DIR to env |
206 | crates.insert( | 224 | crates.insert( |
207 | crate_id, | 225 | crate_id, |
@@ -211,8 +229,8 @@ impl ProjectWorkspace { | |||
211 | // FIXME json definitions can store the crate name | 229 | // FIXME json definitions can store the crate name |
212 | None, | 230 | None, |
213 | cfg_options, | 231 | cfg_options, |
214 | Env::default(), | 232 | env, |
215 | Default::default(), | 233 | extern_source, |
216 | ), | 234 | ), |
217 | ); | 235 | ); |
218 | } | 236 | } |