@@ -11,7 +11,7 @@ use url::Url;
1111
1212use core:: interning:: InternedString ;
1313use core:: profiles:: Profiles ;
14- use core:: { Dependency , PackageId , PackageIdSpec , SourceId , Summary } ;
14+ use core:: { Dependency , PackageId , PackageIdSpec , Platform , SourceId , Summary } ;
1515use core:: { Edition , Feature , Features , WorkspaceConfig } ;
1616use util:: errors:: * ;
1717use util:: toml:: TomlManifest ;
@@ -171,6 +171,10 @@ pub struct Target {
171171 doctest : bool ,
172172 harness : bool , // whether to use the test harness (--test)
173173 for_host : bool ,
174+
175+ // This target should only be built for this platform. `None` means *all
176+ // platforms*.
177+ platform : Option < Platform > ,
174178}
175179
176180#[ derive( Clone , PartialEq , Eq , Debug ) ]
@@ -194,6 +198,7 @@ struct SerializedTarget<'a> {
194198 crate_types : Vec < & ' a str > ,
195199 name : & ' a str ,
196200 src_path : & ' a PathBuf ,
201+ platform : Option < & ' a Platform > ,
197202}
198203
199204impl ser:: Serialize for Target {
@@ -203,6 +208,7 @@ impl ser::Serialize for Target {
203208 crate_types : self . rustc_crate_types ( ) ,
204209 name : & self . name ,
205210 src_path : & self . src_path . path ,
211+ platform : self . platform ( ) ,
206212 } . serialize ( s)
207213 }
208214}
@@ -417,6 +423,7 @@ impl Target {
417423 for_host : false ,
418424 tested : true ,
419425 benched : true ,
426+ platform : None ,
420427 }
421428 }
422429
@@ -537,6 +544,12 @@ impl Target {
537544 self . benched
538545 }
539546
547+ /// If none, this target must be built for all platforms.
548+ /// If some, it must only be built for the specified platform.
549+ pub fn platform ( & self ) -> Option < & Platform > {
550+ self . platform . as_ref ( )
551+ }
552+
540553 pub fn doctested ( & self ) -> bool {
541554 self . doctest && match self . kind {
542555 TargetKind :: Lib ( ref kinds) => kinds
@@ -552,7 +565,7 @@ impl Target {
552565
553566 pub fn is_lib ( & self ) -> bool {
554567 match self . kind {
555- TargetKind :: Lib ( _ ) => true ,
568+ TargetKind :: Lib ( .. ) => true ,
556569 _ => false ,
557570 }
558571 }
@@ -659,6 +672,10 @@ impl Target {
659672 self . doc = doc;
660673 self
661674 }
675+ pub fn set_platform ( & mut self , platform : Option < Platform > ) -> & mut Target {
676+ self . platform = platform;
677+ self
678+ }
662679}
663680
664681impl fmt:: Display for Target {
0 commit comments