@@ -4,6 +4,7 @@ use crate::ops;
4
4
use crate :: sources:: path:: PathSource ;
5
5
use crate :: sources:: CRATES_IO_REGISTRY ;
6
6
use crate :: util:: cache_lock:: CacheLockMode ;
7
+ use crate :: util:: toml:: AbsolutePathTomlTarget ;
7
8
use crate :: util:: { try_canonicalize, CargoResult , GlobalContext } ;
8
9
use anyhow:: { bail, Context as _} ;
9
10
use cargo_util:: { paths, Sha256 } ;
@@ -412,9 +413,13 @@ fn prepare_for_vendor(
412
413
) -> CargoResult < Package > {
413
414
let contents = me. manifest ( ) . contents ( ) ;
414
415
let document = me. manifest ( ) . document ( ) ;
416
+ let abs_targets =
417
+ crate :: util:: toml:: absolute_normalized_targets ( me. manifest ( ) . normalized_toml ( ) , me. root ( ) ) ?;
415
418
let original_toml = prepare_toml_for_vendor (
416
419
me. manifest ( ) . normalized_toml ( ) . clone ( ) ,
417
420
packaged_files,
421
+ & abs_targets,
422
+ me. root ( ) ,
418
423
gctx,
419
424
) ?;
420
425
let normalized_toml = original_toml. clone ( ) ;
@@ -428,10 +433,12 @@ fn prepare_for_vendor(
428
433
document. clone ( ) ,
429
434
original_toml,
430
435
normalized_toml,
436
+ & abs_targets,
431
437
features,
432
438
workspace_config,
433
439
source_id,
434
440
me. manifest_path ( ) ,
441
+ me. root ( ) ,
435
442
gctx,
436
443
& mut warnings,
437
444
& mut errors,
@@ -443,14 +450,19 @@ fn prepare_for_vendor(
443
450
fn prepare_toml_for_vendor (
444
451
mut me : cargo_util_schemas:: manifest:: TomlManifest ,
445
452
packaged_files : & [ PathBuf ] ,
453
+ abs_targets : & AbsolutePathTomlTarget ,
454
+ package_root : & Path ,
446
455
gctx : & GlobalContext ,
447
456
) -> CargoResult < cargo_util_schemas:: manifest:: TomlManifest > {
448
457
let package = me
449
458
. package
450
459
. as_mut ( )
451
460
. expect ( "venedored manifests must have packages" ) ;
452
- if let Some ( cargo_util_schemas:: manifest:: StringOrBool :: String ( path) ) = & package. build {
453
- let path = paths:: normalize_path ( Path :: new ( path) ) ;
461
+ if let Some ( path) = & abs_targets. build {
462
+ let path = path
463
+ . strip_prefix ( package_root)
464
+ . expect ( "path shoud be under the package root" )
465
+ . to_path_buf ( ) ;
454
466
let included = packaged_files. contains ( & path) ;
455
467
let build = if included {
456
468
let path = path
@@ -469,37 +481,42 @@ fn prepare_toml_for_vendor(
469
481
package. build = Some ( build) ;
470
482
}
471
483
472
- let lib = if let Some ( target) = & me . lib {
484
+ let lib = if let Some ( target) = & abs_targets . lib {
473
485
crate :: util:: toml:: prepare_target_for_publish (
474
486
target,
475
487
Some ( packaged_files) ,
488
+ package_root,
476
489
"library" ,
477
490
gctx,
478
491
) ?
479
492
} else {
480
493
None
481
494
} ;
482
495
let bin = crate :: util:: toml:: prepare_targets_for_publish (
483
- me . bin . as_ref ( ) ,
496
+ abs_targets . bin . as_ref ( ) ,
484
497
Some ( packaged_files) ,
498
+ package_root,
485
499
"binary" ,
486
500
gctx,
487
501
) ?;
488
502
let example = crate :: util:: toml:: prepare_targets_for_publish (
489
- me . example . as_ref ( ) ,
503
+ abs_targets . example . as_ref ( ) ,
490
504
Some ( packaged_files) ,
505
+ package_root,
491
506
"example" ,
492
507
gctx,
493
508
) ?;
494
509
let test = crate :: util:: toml:: prepare_targets_for_publish (
495
- me . test . as_ref ( ) ,
510
+ abs_targets . test . as_ref ( ) ,
496
511
Some ( packaged_files) ,
512
+ package_root,
497
513
"test" ,
498
514
gctx,
499
515
) ?;
500
516
let bench = crate :: util:: toml:: prepare_targets_for_publish (
501
- me . bench . as_ref ( ) ,
517
+ abs_targets . bench . as_ref ( ) ,
502
518
Some ( packaged_files) ,
519
+ package_root,
503
520
"benchmark" ,
504
521
gctx,
505
522
) ?;
0 commit comments