@@ -22,7 +22,9 @@ use crate::sources::{PathSource, CRATES_IO_INDEX, CRATES_IO_REGISTRY};
22
22
use crate :: util:: errors:: { CargoResult , ManifestError } ;
23
23
use crate :: util:: interning:: InternedString ;
24
24
use crate :: util:: lev_distance;
25
- use crate :: util:: toml:: { read_manifest, TomlDependency , TomlProfiles } ;
25
+ use crate :: util:: toml:: {
26
+ read_manifest, StringOrBool , TomlDependency , TomlProfiles , VecStringOrBool ,
27
+ } ;
26
28
use crate :: util:: { config:: ConfigRelativePath , Config , Filesystem , IntoUrl } ;
27
29
use cargo_util:: paths;
28
30
@@ -123,6 +125,15 @@ pub enum WorkspaceConfig {
123
125
Member { root : Option < String > } ,
124
126
}
125
127
128
+ impl WorkspaceConfig {
129
+ pub fn inheritable ( & self ) -> Option < & InheritableFields > {
130
+ match self {
131
+ WorkspaceConfig :: Root ( root) => Some ( & root. inheritable_fields ) ,
132
+ WorkspaceConfig :: Member { .. } => None ,
133
+ }
134
+ }
135
+ }
136
+
126
137
/// Intermediate configuration of a workspace root in a manifest.
127
138
///
128
139
/// Knows the Workspace Root path, as well as `members` and `exclude` lists of path patterns, which
@@ -133,6 +144,7 @@ pub struct WorkspaceRootConfig {
133
144
members : Option < Vec < String > > ,
134
145
default_members : Option < Vec < String > > ,
135
146
exclude : Vec < String > ,
147
+ inheritable_fields : InheritableFields ,
136
148
custom_metadata : Option < toml:: Value > ,
137
149
}
138
150
@@ -1567,17 +1579,18 @@ impl WorkspaceRootConfig {
1567
1579
members : & Option < Vec < String > > ,
1568
1580
default_members : & Option < Vec < String > > ,
1569
1581
exclude : & Option < Vec < String > > ,
1582
+ inheritable : & Option < InheritableFields > ,
1570
1583
custom_metadata : & Option < toml:: Value > ,
1571
1584
) -> WorkspaceRootConfig {
1572
1585
WorkspaceRootConfig {
1573
1586
root_dir : root_dir. to_path_buf ( ) ,
1574
1587
members : members. clone ( ) ,
1575
1588
default_members : default_members. clone ( ) ,
1576
1589
exclude : exclude. clone ( ) . unwrap_or_default ( ) ,
1590
+ inheritable_fields : inheritable. clone ( ) . unwrap_or_default ( ) ,
1577
1591
custom_metadata : custom_metadata. clone ( ) ,
1578
1592
}
1579
1593
}
1580
-
1581
1594
/// Checks the path against the `excluded` list.
1582
1595
///
1583
1596
/// This method does **not** consider the `members` list.
@@ -1641,3 +1654,121 @@ impl WorkspaceRootConfig {
1641
1654
Ok ( res)
1642
1655
}
1643
1656
}
1657
+
1658
+ /// A group of fields that are inheritable by members of the workspace
1659
+ #[ derive( Clone , Debug , Default ) ]
1660
+ pub struct InheritableFields {
1661
+ dependencies : Option < BTreeMap < String , TomlDependency > > ,
1662
+ version : Option < semver:: Version > ,
1663
+ authors : Option < Vec < String > > ,
1664
+ description : Option < String > ,
1665
+ homepage : Option < String > ,
1666
+ documentation : Option < String > ,
1667
+ readme : Option < StringOrBool > ,
1668
+ keywords : Option < Vec < String > > ,
1669
+ categories : Option < Vec < String > > ,
1670
+ license : Option < String > ,
1671
+ license_file : Option < String > ,
1672
+ repository : Option < String > ,
1673
+ publish : Option < VecStringOrBool > ,
1674
+ edition : Option < String > ,
1675
+ badges : Option < BTreeMap < String , BTreeMap < String , String > > > ,
1676
+ }
1677
+
1678
+ impl InheritableFields {
1679
+ pub fn new (
1680
+ dependencies : Option < BTreeMap < String , TomlDependency > > ,
1681
+ version : Option < semver:: Version > ,
1682
+ authors : Option < Vec < String > > ,
1683
+ description : Option < String > ,
1684
+ homepage : Option < String > ,
1685
+ documentation : Option < String > ,
1686
+ readme : Option < StringOrBool > ,
1687
+ keywords : Option < Vec < String > > ,
1688
+ categories : Option < Vec < String > > ,
1689
+ license : Option < String > ,
1690
+ license_file : Option < String > ,
1691
+ repository : Option < String > ,
1692
+ publish : Option < VecStringOrBool > ,
1693
+ edition : Option < String > ,
1694
+ badges : Option < BTreeMap < String , BTreeMap < String , String > > > ,
1695
+ ) -> InheritableFields {
1696
+ Self {
1697
+ dependencies,
1698
+ version,
1699
+ authors,
1700
+ description,
1701
+ homepage,
1702
+ documentation,
1703
+ readme,
1704
+ keywords,
1705
+ categories,
1706
+ license,
1707
+ license_file,
1708
+ repository,
1709
+ publish,
1710
+ edition,
1711
+ badges,
1712
+ }
1713
+ }
1714
+
1715
+ pub fn dependencies ( & self ) -> Option < BTreeMap < String , TomlDependency > > {
1716
+ self . dependencies . clone ( )
1717
+ }
1718
+
1719
+ pub fn version ( & self ) -> Option < semver:: Version > {
1720
+ self . version . clone ( )
1721
+ }
1722
+
1723
+ pub fn authors ( & self ) -> Option < Vec < String > > {
1724
+ self . authors . clone ( )
1725
+ }
1726
+
1727
+ pub fn description ( & self ) -> Option < String > {
1728
+ self . description . clone ( )
1729
+ }
1730
+
1731
+ pub fn homepage ( & self ) -> Option < String > {
1732
+ self . homepage . clone ( )
1733
+ }
1734
+
1735
+ pub fn documentation ( & self ) -> Option < String > {
1736
+ self . documentation . clone ( )
1737
+ }
1738
+
1739
+ pub fn readme ( & self ) -> Option < StringOrBool > {
1740
+ self . readme . clone ( )
1741
+ }
1742
+
1743
+ pub fn keywords ( & self ) -> Option < Vec < String > > {
1744
+ self . keywords . clone ( )
1745
+ }
1746
+
1747
+ pub fn categories ( & self ) -> Option < Vec < String > > {
1748
+ self . categories . clone ( )
1749
+ }
1750
+
1751
+ pub fn license ( & self ) -> Option < String > {
1752
+ self . license . clone ( )
1753
+ }
1754
+
1755
+ pub fn license_file ( & self ) -> Option < String > {
1756
+ self . license_file . clone ( )
1757
+ }
1758
+
1759
+ pub fn repository ( & self ) -> Option < String > {
1760
+ self . repository . clone ( )
1761
+ }
1762
+
1763
+ pub fn publish ( & self ) -> Option < VecStringOrBool > {
1764
+ self . publish . clone ( )
1765
+ }
1766
+
1767
+ pub fn edition ( & self ) -> Option < String > {
1768
+ self . edition . clone ( )
1769
+ }
1770
+
1771
+ pub fn badges ( & self ) -> Option < BTreeMap < String , BTreeMap < String , String > > > {
1772
+ self . badges . clone ( )
1773
+ }
1774
+ }
0 commit comments