@@ -261,10 +261,11 @@ fn generate_package(action: &InputAction) -> MainResult<()> {
261
261
262
262
info ! ( "generating Cargo package..." ) ;
263
263
let mani_path = action. manifest_path ( ) ;
264
- let script_path = action. script_path ( ) ;
265
264
266
265
overwrite_file ( & mani_path, & action. manifest ) ?;
267
- overwrite_file ( & script_path, & action. script ) ?;
266
+ if let Some ( script) = & action. script {
267
+ overwrite_file ( & action. script_path , script) ?;
268
+ }
268
269
269
270
info ! ( "disarming pkg dir cleanup..." ) ;
270
271
cleanup_dir. disarm ( ) ;
@@ -293,7 +294,8 @@ struct InputAction {
293
294
/// Directory where the package should live.
294
295
pkg_path : PathBuf ,
295
296
296
- script_name : String ,
297
+ /// Path of the source code that Cargo.toml refers.
298
+ script_path : PathBuf ,
297
299
298
300
/**
299
301
Is the package directory in the cache?
@@ -315,8 +317,8 @@ struct InputAction {
315
317
/// The package manifest contents.
316
318
manifest : String ,
317
319
318
- /// The script source.
319
- script : String ,
320
+ /// The script source in case it has to be written .
321
+ script : Option < String > ,
320
322
321
323
/// Did the user ask to run tests or benchmarks?
322
324
build_kind : BuildKind ,
@@ -330,10 +332,6 @@ impl InputAction {
330
332
self . pkg_path . join ( "Cargo.toml" )
331
333
}
332
334
333
- fn script_path ( & self ) -> PathBuf {
334
- self . pkg_path . join ( & self . script_name )
335
- }
336
-
337
335
fn cargo ( & self , script_args : & [ String ] ) -> MainResult < Command > {
338
336
let release_mode = !self . debug && !matches ! ( self . build_kind, BuildKind :: Bench ) ;
339
337
@@ -359,14 +357,15 @@ impl InputAction {
359
357
} ;
360
358
361
359
if matches ! ( self . build_kind, BuildKind :: Normal ) && !self . force_compile {
362
- let script_path = self . script_path ( ) ;
363
-
364
360
match fs:: File :: open ( & built_binary_path) {
365
361
Ok ( built_binary_file) => {
366
362
// Use ctime instead of mtime as cargo may copy an already
367
363
// built binary (with old mtime) here:
368
364
let built_binary_ctime = built_binary_file. metadata ( ) ?. created ( ) ?;
369
- match ( fs:: File :: open ( script_path) , fs:: File :: open ( manifest_path) ) {
365
+ match (
366
+ fs:: File :: open ( & self . script_path ) ,
367
+ fs:: File :: open ( manifest_path) ,
368
+ ) {
370
369
( Ok ( script_file) , Ok ( manifest_file) ) => {
371
370
let script_mtime = script_file. metadata ( ) ?. modified ( ) ?;
372
371
let manifest_mtime = manifest_file. metadata ( ) ?. modified ( ) ?;
@@ -470,10 +469,11 @@ fn decide_action_for(
470
469
471
470
let script_name = format ! ( "{}.rs" , input. safe_name( ) ) ;
472
471
473
- let ( mani_str, script_str) = manifest:: split_input (
472
+ let ( mani_str, script_path , script_str) = manifest:: split_input (
474
473
input,
475
474
& deps,
476
475
& prelude,
476
+ & pkg_path,
477
477
& bin_name,
478
478
& script_name,
479
479
toolchain_version. clone ( ) ,
@@ -491,7 +491,7 @@ fn decide_action_for(
491
491
force_compile : args. force ,
492
492
execute : !args. gen_pkg_only ,
493
493
pkg_path,
494
- script_name ,
494
+ script_path ,
495
495
using_cache,
496
496
toolchain_version,
497
497
debug,
0 commit comments