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