@@ -4,7 +4,7 @@ use std::path::{Path, PathBuf};
44use std:: slice;
55
66use core:: { Package , VirtualManifest , EitherManifest , SourceId } ;
7- use core:: { PackageIdSpec , Dependency } ;
7+ use core:: { PackageIdSpec , Dependency , Profile , Profiles } ;
88use ops;
99use util:: { Config , CargoResult , Filesystem , human} ;
1010use util:: paths;
@@ -162,6 +162,14 @@ impl<'cfg> Workspace<'cfg> {
162162 self . config
163163 }
164164
165+ pub fn profiles ( & self ) -> & Profiles {
166+ let root = self . root_manifest . as_ref ( ) . unwrap_or ( & self . current_manifest ) ;
167+ match * self . packages . get ( root) {
168+ MaybePackage :: Package ( ref p) => p. manifest ( ) . profiles ( ) ,
169+ MaybePackage :: Virtual ( ref m) => m. profiles ( ) ,
170+ }
171+ }
172+
165173 /// Returns the root path of this workspace.
166174 ///
167175 /// That is, this returns the path of the directory containing the
@@ -432,6 +440,33 @@ impl<'cfg> Workspace<'cfg> {
432440 extra) ;
433441 }
434442
443+ if let Some ( ref root_manifest) = self . root_manifest {
444+ let default_profiles = Profiles {
445+ release : Profile :: default_release ( ) ,
446+ dev : Profile :: default_dev ( ) ,
447+ test : Profile :: default_test ( ) ,
448+ test_deps : Profile :: default_dev ( ) ,
449+ bench : Profile :: default_bench ( ) ,
450+ bench_deps : Profile :: default_release ( ) ,
451+ doc : Profile :: default_doc ( ) ,
452+ custom_build : Profile :: default_custom_build ( ) ,
453+ } ;
454+
455+ for pkg in self . members ( ) . filter ( |p| p. manifest_path ( ) != root_manifest) {
456+ if pkg. manifest ( ) . profiles ( ) != & default_profiles {
457+ let message = & format ! ( "profiles for the non root package will be ignored, \
458+ specify profiles at the workspace root:\n \
459+ package: {}\n \
460+ workspace: {}",
461+ pkg. manifest_path( ) . display( ) ,
462+ root_manifest. display( ) ) ;
463+
464+ //TODO: remove `Eq` bound from `Profiles` when the warning is removed.
465+ try!( self . config . shell ( ) . warn ( & message) ) ;
466+ }
467+ }
468+ }
469+
435470 Ok ( ( ) )
436471 }
437472}
0 commit comments