@@ -4,6 +4,7 @@ use crate::ops;
44use crate :: sources:: path:: PathSource ;
55use crate :: sources:: CRATES_IO_REGISTRY ;
66use crate :: util:: cache_lock:: CacheLockMode ;
7+ use crate :: util:: toml:: AbsolutePathTomlTarget ;
78use crate :: util:: { try_canonicalize, CargoResult , GlobalContext } ;
89use anyhow:: { bail, Context as _} ;
910use cargo_util:: { paths, Sha256 } ;
@@ -410,9 +411,13 @@ fn prepare_for_vendor(
410411) -> CargoResult < Package > {
411412 let contents = me. manifest ( ) . contents ( ) ;
412413 let document = me. manifest ( ) . document ( ) ;
414+ let abs_targets =
415+ crate :: util:: toml:: absolute_normalized_targets ( me. manifest ( ) . normalized_toml ( ) , me. root ( ) ) ?;
413416 let original_toml = prepare_toml_for_vendor (
414417 me. manifest ( ) . normalized_toml ( ) . clone ( ) ,
415418 packaged_files,
419+ & abs_targets,
420+ me. root ( ) ,
416421 gctx,
417422 ) ?;
418423 let normalized_toml = original_toml. clone ( ) ;
@@ -426,10 +431,12 @@ fn prepare_for_vendor(
426431 document. clone ( ) ,
427432 original_toml,
428433 normalized_toml,
434+ & abs_targets,
429435 features,
430436 workspace_config,
431437 source_id,
432438 me. manifest_path ( ) ,
439+ me. root ( ) ,
433440 gctx,
434441 & mut warnings,
435442 & mut errors,
@@ -441,14 +448,19 @@ fn prepare_for_vendor(
441448fn prepare_toml_for_vendor (
442449 mut me : cargo_util_schemas:: manifest:: TomlManifest ,
443450 packaged_files : & [ PathBuf ] ,
451+ abs_targets : & AbsolutePathTomlTarget ,
452+ package_root : & Path ,
444453 gctx : & GlobalContext ,
445454) -> CargoResult < cargo_util_schemas:: manifest:: TomlManifest > {
446455 let package = me
447456 . package
448457 . as_mut ( )
449458 . 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 ( ) ;
452464 let included = packaged_files. contains ( & path) ;
453465 let build = if included {
454466 let path = path
@@ -467,37 +479,42 @@ fn prepare_toml_for_vendor(
467479 package. build = Some ( build) ;
468480 }
469481
470- let lib = if let Some ( target) = & me . lib {
482+ let lib = if let Some ( target) = & abs_targets . lib {
471483 crate :: util:: toml:: prepare_target_for_publish (
472484 target,
473485 Some ( packaged_files) ,
486+ package_root,
474487 "library" ,
475488 gctx,
476489 ) ?
477490 } else {
478491 None
479492 } ;
480493 let bin = crate :: util:: toml:: prepare_targets_for_publish (
481- me . bin . as_ref ( ) ,
494+ abs_targets . bin . as_ref ( ) ,
482495 Some ( packaged_files) ,
496+ package_root,
483497 "binary" ,
484498 gctx,
485499 ) ?;
486500 let example = crate :: util:: toml:: prepare_targets_for_publish (
487- me . example . as_ref ( ) ,
501+ abs_targets . example . as_ref ( ) ,
488502 Some ( packaged_files) ,
503+ package_root,
489504 "example" ,
490505 gctx,
491506 ) ?;
492507 let test = crate :: util:: toml:: prepare_targets_for_publish (
493- me . test . as_ref ( ) ,
508+ abs_targets . test . as_ref ( ) ,
494509 Some ( packaged_files) ,
510+ package_root,
495511 "test" ,
496512 gctx,
497513 ) ?;
498514 let bench = crate :: util:: toml:: prepare_targets_for_publish (
499- me . bench . as_ref ( ) ,
515+ abs_targets . bench . as_ref ( ) ,
500516 Some ( packaged_files) ,
517+ package_root,
501518 "benchmark" ,
502519 gctx,
503520 ) ?;
0 commit comments