File tree 2 files changed +82
-0
lines changed 2 files changed +82
-0
lines changed Original file line number Diff line number Diff line change @@ -398,6 +398,18 @@ fn add_pkg(
398
398
{
399
399
// Dependency has a `{ …, target = <triple> }`
400
400
Some ( target) => FeaturesFor :: ArtifactDep ( target) ,
401
+ // Get the information of the dependent crate from `features_for`.
402
+ // If a dependent crate is
403
+ //
404
+ // * specified as an artifact dep with a `target`, or
405
+ // * a host dep,
406
+ //
407
+ // its transitive deps, including build-deps, need to be built on that target.
408
+ None if features_for != FeaturesFor :: default ( ) => features_for,
409
+ // Dependent crate is a normal dep, then back to old rules:
410
+ //
411
+ // * normal deps, dev-deps -> inherited target
412
+ // * build-deps -> host
401
413
None => {
402
414
if dep. is_build ( ) || dep_pkg. proc_macro ( ) {
403
415
FeaturesFor :: HostDep
Original file line number Diff line number Diff line change @@ -1579,6 +1579,76 @@ foo v0.0.0 ([ROOT]/foo)
1579
1579
. run ( ) ;
1580
1580
}
1581
1581
1582
+ #[ cargo_test]
1583
+ fn rename_this ( ) {
1584
+ if cross_compile:: disabled ( ) {
1585
+ return ;
1586
+ }
1587
+ let target = cross_compile:: alternate ( ) ;
1588
+ let p = project ( )
1589
+ . file (
1590
+ "Cargo.toml" ,
1591
+ & format ! (
1592
+ r#"
1593
+ [package]
1594
+ name = "foo"
1595
+ version = "0.1.0"
1596
+ edition = "2015"
1597
+
1598
+ [dependencies]
1599
+ bar = {{ path = "bar", artifact = "bin", target = "{target}" }}
1600
+ "# ,
1601
+ ) ,
1602
+ )
1603
+ . file ( "src/lib.rs" , "" )
1604
+ . file (
1605
+ "bar/Cargo.toml" ,
1606
+ & format ! (
1607
+ r#"
1608
+ [package]
1609
+ name = "bar"
1610
+ version = "0.1.0"
1611
+
1612
+ [target.{target}.dependencies]
1613
+ baz = {{ path = "../baz" }}
1614
+ "# ,
1615
+ ) ,
1616
+ )
1617
+ . file ( "bar/src/lib.rs" , "" )
1618
+ . file (
1619
+ "baz/Cargo.toml" ,
1620
+ r#"
1621
+ [package]
1622
+ name = "baz"
1623
+ version = "0.1.0"
1624
+
1625
+ "# ,
1626
+ )
1627
+ . file ( "baz/src/lib.rs" , "" )
1628
+ . build ( ) ;
1629
+
1630
+ // TODO This command currently fails due to a bug in cargo but it should be fixed so that it succeeds in the future.
1631
+ p. cargo ( "check -Z bindeps" )
1632
+ . masquerade_as_nightly_cargo ( & [ "bindeps" ] )
1633
+ . with_stderr_data ( str![ [ r#"
1634
+ [LOCKING] 2 packages to latest compatible versions
1635
+ [ERROR] dependency `bar` in package `foo` requires a `bin` artifact to be present.
1636
+
1637
+ "# ] ] )
1638
+ . with_status ( 101 )
1639
+ . run ( ) ;
1640
+
1641
+ // TODO This command currently fails due to a bug in cargo but it should be fixed so that it succeeds in the future.
1642
+ p. cargo ( "tree -Z bindeps" )
1643
+ . masquerade_as_nightly_cargo ( & [ "bindeps" ] )
1644
+ . with_stderr_data ( r#"...
1645
+ no entry found for key
1646
+ ...
1647
+ "# )
1648
+ . with_status ( 101 )
1649
+ . run ( ) ;
1650
+ }
1651
+
1582
1652
#[ cargo_test]
1583
1653
fn targets_are_picked_up_from_non_workspace_artifact_deps ( ) {
1584
1654
if cross_compile:: disabled ( ) {
You can’t perform that action at this time.
0 commit comments