@@ -161,7 +161,6 @@ fn run_cargo(
161
161
trace ! ( "Cargo compilation options:\n {:?}" , opts) ;
162
162
let rustflags = prepare_cargo_rustflags ( & rls_config) ;
163
163
164
-
165
164
for package in & packages {
166
165
if ws. members ( ) . find ( |x| * x. name ( ) == * package) . is_none ( ) {
167
166
warn ! ( "cargo - couldn't find member package `{}` specified in `analyze_package` configuration" , package) ;
@@ -340,7 +339,7 @@ impl Executor for RlsExecutor {
340
339
let cargo_args = cargo_cmd. get_args ( ) ;
341
340
let crate_name =
342
341
parse_arg ( cargo_args, "--crate-name" ) . expect ( "no crate-name in rustc command line" ) ;
343
- trace ! ( "exec: {}" , crate_name) ;
342
+ trace ! ( "exec: {} {:?} " , crate_name, cargo_cmd ) ;
344
343
345
344
// Send off a window/progress notification for this compile target.
346
345
// At the moment, we don't know the number of things cargo is going to compile,
@@ -389,9 +388,30 @@ impl Executor for RlsExecutor {
389
388
cmd. program ( rustc_shim) ;
390
389
cmd. env ( :: RUSTC_SHIM_ENV_VAR_NAME , "1" ) ;
391
390
391
+ // Add args and envs to cmd.
392
+ let mut args: Vec < _ > = cargo_args
393
+ . iter ( )
394
+ . map ( |a| a. clone ( ) . into_string ( ) . unwrap ( ) )
395
+ . collect ( ) ;
396
+ let envs = cargo_cmd. get_envs ( ) . clone ( ) ;
397
+
392
398
let sysroot =
393
399
current_sysroot ( ) . expect ( "need to specify SYSROOT env var or use rustup or multirust" ) ;
394
400
401
+ {
402
+ let config = self . config . lock ( ) . unwrap ( ) ;
403
+ if config. sysroot . is_none ( ) {
404
+ args. push ( "--sysroot" . to_owned ( ) ) ;
405
+ args. push ( sysroot) ;
406
+ }
407
+ }
408
+ cmd. args_replace ( & args) ;
409
+ for ( k, v) in & envs {
410
+ if let Some ( v) = v {
411
+ cmd. env ( k, v) ;
412
+ }
413
+ }
414
+
395
415
// We only want to intercept rustc call targeting current crate to cache
396
416
// args/envs generated by cargo so we can run only rustc later ourselves
397
417
// Currently we don't cache nor modify build script args
@@ -403,9 +423,11 @@ impl Executor for RlsExecutor {
403
423
""
404
424
} ;
405
425
trace ! (
406
- "rustc not intercepted - {}{}" ,
426
+ "rustc not intercepted - {}{} - args: {:?} envs: {:?} " ,
407
427
id. name( ) ,
408
- build_script_notice
428
+ build_script_notice,
429
+ cmd. get_args( ) ,
430
+ cmd. get_envs( ) ,
409
431
) ;
410
432
411
433
if :: blacklist:: CRATE_BLACKLIST . contains ( & & * crate_name) {
@@ -421,37 +443,17 @@ impl Executor for RlsExecutor {
421
443
let save_config = serde_json:: to_string ( & save_config) ?;
422
444
cmd. env ( "RUST_SAVE_ANALYSIS_CONFIG" , & OsString :: from ( save_config) ) ;
423
445
424
- if self . config . lock ( ) . unwrap ( ) . sysroot . is_none ( ) {
425
- cmd. arg ( "--sysroot" ) ;
426
- cmd. arg ( & sysroot) ;
427
- }
428
446
return cmd. exec ( ) ;
429
447
}
430
448
431
449
trace ! (
432
450
"rustc intercepted - args: {:?} envs: {:?}" ,
433
- cargo_args ,
434
- cargo_cmd . get_envs ( )
451
+ args ,
452
+ envs ,
435
453
) ;
436
454
437
455
self . reached_primary . store ( true , Ordering :: SeqCst ) ;
438
456
439
- let mut args: Vec < _ > = cargo_args
440
- . iter ( )
441
- . map ( |a| a. clone ( ) . into_string ( ) . unwrap ( ) )
442
- . collect ( ) ;
443
-
444
- {
445
- let config = self . config . lock ( ) . unwrap ( ) ;
446
-
447
- if config. sysroot . is_none ( ) {
448
- args. push ( "--sysroot" . to_owned ( ) ) ;
449
- args. push ( sysroot) ;
450
- }
451
-
452
- cmd. args_replace ( & args) ;
453
- }
454
-
455
457
// Cache executed command for the build plan
456
458
{
457
459
let mut cx = self . compilation_cx . lock ( ) . unwrap ( ) ;
@@ -461,7 +463,6 @@ impl Executor for RlsExecutor {
461
463
// Prepare modified cargo-generated args/envs for future rustc calls
462
464
let rustc = cargo_cmd. get_program ( ) . to_owned ( ) . into_string ( ) . unwrap ( ) ;
463
465
args. insert ( 0 , rustc) ;
464
- let envs = cargo_cmd. get_envs ( ) . clone ( ) ;
465
466
466
467
// Store the modified cargo-generated args/envs for future rustc calls
467
468
{
0 commit comments