@@ -20,11 +20,12 @@ use failure::{self, format_err};
20
20
use serde_json;
21
21
22
22
use crate :: actions:: progress:: ProgressUpdate ;
23
- use crate :: build:: environment:: { self , Environment , EnvironmentLock } ;
24
- use crate :: build:: plan:: Plan ;
25
23
use crate :: build:: { BufWriter , BuildResult , CompilationContext , Internals , PackageArg } ;
24
+ use crate :: build:: cargo_plan:: CargoPlan ;
25
+ use crate :: build:: environment:: { self , Environment , EnvironmentLock } ;
26
+ use crate :: build:: plan:: BuildPlan ;
26
27
use crate :: config:: Config ;
27
- use log:: { debug, error , trace, warn} ;
28
+ use log:: { debug, trace, warn} ;
28
29
use rls_data:: Analysis ;
29
30
use rls_vfs:: Vfs ;
30
31
@@ -34,7 +35,6 @@ use std::ffi::OsString;
34
35
use std:: fmt:: Write ;
35
36
use std:: fs:: { read_dir, remove_file} ;
36
37
use std:: path:: { Path , PathBuf } ;
37
- use std:: process:: Command ;
38
38
use std:: sync:: atomic:: { AtomicBool , Ordering } ;
39
39
use std:: sync:: mpsc:: Sender ;
40
40
use std:: sync:: { Arc , Mutex } ;
@@ -188,7 +188,8 @@ fn run_cargo(
188
188
189
189
// Since Cargo build routine will try to regenerate the unit dep graph,
190
190
// we need to clear the existing dep graph.
191
- compilation_cx. lock ( ) . unwrap ( ) . build_plan = Plan :: for_packages ( pkg_names) ;
191
+ compilation_cx. lock ( ) . unwrap ( ) . build_plan =
192
+ BuildPlan :: Cargo ( CargoPlan :: with_packages ( & manifest_path, pkg_names) ) ;
192
193
193
194
let compile_opts = CompileOptions {
194
195
spec,
@@ -328,12 +329,12 @@ impl Executor for RlsExecutor {
328
329
/// is fresh and won't be compiled.
329
330
fn init ( & self , cx : & Context < ' _ , ' _ > , unit : & Unit < ' _ > ) {
330
331
let mut compilation_cx = self . compilation_cx . lock ( ) . unwrap ( ) ;
331
- let plan = & mut compilation_cx. build_plan ;
332
+ let plan = compilation_cx. build_plan . as_cargo_mut ( )
333
+ . expect ( "Build plan should be properly initialized before running Cargo" ) ;
334
+
332
335
let only_primary = |unit : & Unit < ' _ > | self . is_primary_crate ( unit. pkg . package_id ( ) ) ;
333
336
334
- if let Err ( err) = plan. emplace_dep_with_filter ( unit, cx, & only_primary) {
335
- error ! ( "{:?}" , err) ;
336
- }
337
+ plan. emplace_dep_with_filter ( unit, cx, & only_primary) ;
337
338
}
338
339
339
340
fn force_rebuild ( & self , unit : & Unit < ' _ > ) -> bool {
@@ -431,8 +432,8 @@ impl Executor for RlsExecutor {
431
432
. collect ( ) ;
432
433
let envs = cargo_cmd. get_envs ( ) . clone ( ) ;
433
434
434
- let sysroot =
435
- current_sysroot ( ) . expect ( "need to specify SYSROOT env var or use rustup or multirust" ) ;
435
+ let sysroot = super :: rustc :: current_sysroot ( )
436
+ . expect ( "need to specify SYSROOT env var or use rustup or multirust" ) ;
436
437
437
438
{
438
439
let config = self . config . lock ( ) . unwrap ( ) ;
@@ -494,7 +495,8 @@ impl Executor for RlsExecutor {
494
495
// Cache executed command for the build plan
495
496
{
496
497
let mut cx = self . compilation_cx . lock ( ) . unwrap ( ) ;
497
- cx. build_plan . cache_compiler_job ( id, target, mode, & cmd) ;
498
+ let plan = cx. build_plan . as_cargo_mut ( ) . unwrap ( ) ;
499
+ plan. cache_compiler_job ( id, target, mode, & cmd) ;
498
500
}
499
501
500
502
// Prepare modified cargo-generated args/envs for future rustc calls
@@ -646,25 +648,6 @@ fn parse_arg(args: &[OsString], arg: &str) -> Option<String> {
646
648
None
647
649
}
648
650
649
- fn current_sysroot ( ) -> Option < String > {
650
- let home = env:: var ( "RUSTUP_HOME" ) . or_else ( |_| env:: var ( "MULTIRUST_HOME" ) ) ;
651
- let toolchain = env:: var ( "RUSTUP_TOOLCHAIN" ) . or_else ( |_| env:: var ( "MULTIRUST_TOOLCHAIN" ) ) ;
652
- if let ( Ok ( home) , Ok ( toolchain) ) = ( home, toolchain) {
653
- Some ( format ! ( "{}/toolchains/{}" , home, toolchain) )
654
- } else {
655
- let rustc_exe = env:: var ( "RUSTC" ) . unwrap_or_else ( |_| "rustc" . to_owned ( ) ) ;
656
- env:: var ( "SYSROOT" ) . map ( |s| s. to_owned ( ) ) . ok ( ) . or_else ( || {
657
- Command :: new ( rustc_exe)
658
- . arg ( "--print" )
659
- . arg ( "sysroot" )
660
- . output ( )
661
- . ok ( )
662
- . and_then ( |out| String :: from_utf8 ( out. stdout ) . ok ( ) )
663
- . map ( |s| s. trim ( ) . to_owned ( ) )
664
- } )
665
- }
666
- }
667
-
668
651
/// `flag_str` is a string of command line args for Rust. This function removes any
669
652
/// duplicate flags.
670
653
fn dedup_flags ( flag_str : & str ) -> String {
0 commit comments