@@ -111,7 +111,7 @@ fn try_main() -> MainResult<i32> {
111
111
let input = match ( args. script . clone ( ) . unwrap ( ) , args. expr , args. loop_ ) {
112
112
( script, false , false ) => {
113
113
let ( path, mut file) =
114
- find_script ( & script) . ok_or ( format ! ( "could not find script: {}" , script) ) ?;
114
+ find_script ( script. as_ref ( ) ) . ok_or ( format ! ( "could not find script: {}" , script) ) ?;
115
115
116
116
let script_name = path
117
117
. file_stem ( )
@@ -316,8 +316,8 @@ struct InputAction {
316
316
*/
317
317
toolchain_version : Option < String > ,
318
318
319
- /// The package metadata structure for the current invocation .
320
- metadata : PackageMetadata ,
319
+ /// If script should be built in debug mode .
320
+ debug : bool ,
321
321
322
322
/// The package manifest contents.
323
323
manifest : String ,
@@ -342,7 +342,7 @@ impl InputAction {
342
342
}
343
343
344
344
fn cargo ( & self , script_args : & [ String ] ) -> MainResult < Command > {
345
- let release_mode = !self . metadata . debug && !matches ! ( self . build_kind, BuildKind :: Bench ) ;
345
+ let release_mode = !self . debug && !matches ! ( self . build_kind, BuildKind :: Bench ) ;
346
346
347
347
let built_binary_path = platform:: binary_cache_path ( )
348
348
. join ( if release_mode { "release" } else { "debug" } )
@@ -426,27 +426,6 @@ impl InputAction {
426
426
}
427
427
}
428
428
429
- /**
430
- The metadata here serves two purposes:
431
-
432
- 1. It records everything necessary for compilation and execution of a package.
433
- 2. It records everything that must be exactly the same in order for a cached executable to still be valid, in addition to the content hash.
434
- */
435
- #[ derive( Clone , Debug , Eq , PartialEq ) ]
436
- struct PackageMetadata {
437
- /// Path to the script file.
438
- path : Option < String > ,
439
-
440
- /// Was the script compiled in debug mode?
441
- debug : bool ,
442
-
443
- /// Sorted list of dependencies.
444
- deps : Vec < ( String , String ) > ,
445
-
446
- /// Sorted list of injected prelude items.
447
- prelude : Vec < String > ,
448
- }
449
-
450
429
/**
451
430
For the given input, this constructs the package metadata and checks the cache to see what should be done.
452
431
*/
@@ -460,12 +439,11 @@ fn decide_action_for(
460
439
let deps_iter = deps. iter ( ) . map ( |( n, v) | ( n as & str , v as & str ) ) ;
461
440
input. compute_id ( deps_iter)
462
441
} ;
442
+ info ! ( "id: {:?}" , input_id) ;
463
443
464
444
let pkg_name = input. package_name ( ) ;
465
445
let bin_name = format ! ( "{}_{}" , & * pkg_name, input_id. to_str( ) . unwrap( ) ) ;
466
446
467
- info ! ( "id: {:?}" , input_id) ;
468
-
469
447
let ( pkg_path, using_cache) = args
470
448
. pkg_path
471
449
. as_ref ( )
@@ -480,26 +458,12 @@ fn decide_action_for(
480
458
let ( mani_str, script_str) = manifest:: split_input ( input, & deps, & prelude, & bin_name) ?;
481
459
482
460
// Forcibly override some flags based on build kind.
483
- let ( debug, force ) = match args. build_kind {
484
- BuildKind :: Normal => ( args. debug , args . force ) ,
485
- BuildKind :: Test => ( true , false ) ,
486
- BuildKind :: Bench => ( false , false ) ,
461
+ let debug = match args. build_kind {
462
+ BuildKind :: Normal => args. debug ,
463
+ BuildKind :: Test => true ,
464
+ BuildKind :: Bench => false ,
487
465
} ;
488
466
489
- let input_meta = {
490
- let path = match input {
491
- Input :: File ( _, path, _) => Some ( path. to_string_lossy ( ) . into_owned ( ) ) ,
492
- _ => None ,
493
- } ;
494
- PackageMetadata {
495
- path,
496
- debug,
497
- deps,
498
- prelude,
499
- }
500
- } ;
501
- info ! ( "input_meta: {:?}" , input_meta) ;
502
-
503
467
let toolchain_version = args
504
468
. toolchain_version
505
469
. clone ( )
@@ -508,46 +472,23 @@ fn decide_action_for(
508
472
_ => None ,
509
473
} ) ;
510
474
511
- let mut action = InputAction {
475
+ Ok ( InputAction {
512
476
cargo_output : args. cargo_output ,
513
- force_compile : force,
514
- execute : true ,
477
+ force_compile : args . force ,
478
+ execute : !args . gen_pkg_only ,
515
479
pkg_path,
516
480
using_cache,
517
481
toolchain_version,
518
- metadata : input_meta ,
482
+ debug ,
519
483
manifest : mani_str,
520
484
script : script_str,
521
485
build_kind : args. build_kind ,
522
486
bin_name,
523
- } ;
524
-
525
- // If we were told to only generate the package, we need to stop *now*
526
- if args. gen_pkg_only {
527
- action. execute = false ;
528
- return Ok ( action) ;
529
- }
530
-
531
- // If we're not doing a regular build, stop.
532
- match action. build_kind {
533
- BuildKind :: Normal => ( ) ,
534
- BuildKind :: Test | BuildKind :: Bench => {
535
- info ! ( "not recompiling because: user asked for test/bench" ) ;
536
- action. force_compile = false ;
537
- return Ok ( action) ;
538
- }
539
- }
540
-
541
- Ok ( action)
487
+ } )
542
488
}
543
489
544
490
/// Attempts to locate the script specified by the given path.
545
- fn find_script < P > ( path : P ) -> Option < ( PathBuf , fs:: File ) >
546
- where
547
- P : AsRef < Path > ,
548
- {
549
- let path = path. as_ref ( ) ;
550
-
491
+ fn find_script ( path : & Path ) -> Option < ( PathBuf , fs:: File ) > {
551
492
if let Ok ( file) = fs:: File :: open ( path) {
552
493
return Some ( ( path. into ( ) , file) ) ;
553
494
}
0 commit comments