@@ -15,7 +15,6 @@ pub use self::EntryFnType::*;
1515pub use self :: CrateType :: * ;
1616pub use self :: Passes :: * ;
1717pub use self :: OptLevel :: * ;
18- pub use self :: OutputType :: * ;
1918pub use self :: DebugInfoLevel :: * ;
2019
2120use session:: { early_error, early_warn, Session } ;
@@ -62,14 +61,14 @@ pub enum DebugInfoLevel {
6261 FullDebugInfo ,
6362}
6463
65- #[ derive( Clone , Copy , PartialEq , PartialOrd , Ord , Eq ) ]
64+ #[ derive( Clone , Copy , PartialEq , Eq , Hash ) ]
6665pub enum OutputType {
67- OutputTypeBitcode ,
68- OutputTypeAssembly ,
69- OutputTypeLlvmAssembly ,
70- OutputTypeObject ,
71- OutputTypeExe ,
72- OutputTypeDepInfo ,
66+ Bitcode ,
67+ Assembly ,
68+ LlvmAssembly ,
69+ Object ,
70+ Exe ,
71+ DepInfo ,
7372}
7473
7574#[ derive( Clone ) ]
@@ -85,7 +84,7 @@ pub struct Options {
8584 pub lint_opts : Vec < ( String , lint:: Level ) > ,
8685 pub lint_cap : Option < lint:: Level > ,
8786 pub describe_lints : bool ,
88- pub output_types : Vec < OutputType > ,
87+ pub output_types : HashMap < OutputType , Option < PathBuf > > ,
8988 // This was mutable for rustpkg, which updates search paths based on the
9089 // parsed code. It remains mutable in case its replacements wants to use
9190 // this.
@@ -105,8 +104,6 @@ pub struct Options {
105104 pub always_build_mir : bool ,
106105 pub no_analysis : bool ,
107106 pub debugging_opts : DebuggingOptions ,
108- /// Whether to write dependency files. It's (enabled, optional filename).
109- pub write_dependency_info : ( bool , Option < PathBuf > ) ,
110107 pub prints : Vec < PrintRequest > ,
111108 pub cg : CodegenOptions ,
112109 pub color : ColorConfig ,
@@ -151,26 +148,25 @@ pub struct OutputFilenames {
151148 pub out_filestem : String ,
152149 pub single_output_file : Option < PathBuf > ,
153150 pub extra : String ,
151+ pub outputs : HashMap < OutputType , Option < PathBuf > > ,
154152}
155153
156154impl OutputFilenames {
157155 pub fn path ( & self , flavor : OutputType ) -> PathBuf {
158- match self . single_output_file {
159- Some ( ref path) => return path. clone ( ) ,
160- None => { }
161- }
162- self . temp_path ( flavor)
156+ self . outputs . get ( & flavor) . and_then ( |p| p. to_owned ( ) )
157+ . or_else ( || self . single_output_file . clone ( ) )
158+ . unwrap_or_else ( || self . temp_path ( flavor) )
163159 }
164160
165161 pub fn temp_path ( & self , flavor : OutputType ) -> PathBuf {
166162 let base = self . out_directory . join ( & self . filestem ( ) ) ;
167163 match flavor {
168- OutputTypeBitcode => base. with_extension ( "bc" ) ,
169- OutputTypeAssembly => base. with_extension ( "s" ) ,
170- OutputTypeLlvmAssembly => base. with_extension ( "ll" ) ,
171- OutputTypeObject => base. with_extension ( "o" ) ,
172- OutputTypeDepInfo => base. with_extension ( "d" ) ,
173- OutputTypeExe => base,
164+ OutputType :: Bitcode => base. with_extension ( "bc" ) ,
165+ OutputType :: Assembly => base. with_extension ( "s" ) ,
166+ OutputType :: LlvmAssembly => base. with_extension ( "ll" ) ,
167+ OutputType :: Object => base. with_extension ( "o" ) ,
168+ OutputType :: DepInfo => base. with_extension ( "d" ) ,
169+ OutputType :: Exe => base,
174170 }
175171 }
176172
@@ -206,7 +202,7 @@ pub fn basic_options() -> Options {
206202 lint_opts : Vec :: new ( ) ,
207203 lint_cap : None ,
208204 describe_lints : false ,
209- output_types : Vec :: new ( ) ,
205+ output_types : HashMap :: new ( ) ,
210206 search_paths : SearchPaths :: new ( ) ,
211207 maybe_sysroot : None ,
212208 target_triple : host_triple ( ) . to_string ( ) ,
@@ -218,7 +214,6 @@ pub fn basic_options() -> Options {
218214 always_build_mir : false ,
219215 no_analysis : false ,
220216 debugging_opts : basic_debugging_options ( ) ,
221- write_dependency_info : ( false , None ) ,
222217 prints : Vec :: new ( ) ,
223218 cg : basic_codegen_options ( ) ,
224219 color : Auto ,
@@ -907,31 +902,30 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
907902 unsafe { llvm:: LLVMSetDebug ( 1 ) ; }
908903 }
909904
910- let mut output_types = Vec :: new ( ) ;
905+ let mut output_types = HashMap :: new ( ) ;
911906 if !debugging_opts. parse_only && !no_trans {
912- let unparsed_output_types = matches. opt_strs ( "emit" ) ;
913- for unparsed_output_type in & unparsed_output_types {
914- for part in unparsed_output_type . split ( ',' ) {
915- let output_type = match part {
916- "asm" => OutputTypeAssembly ,
917- "llvm-ir" => OutputTypeLlvmAssembly ,
918- "llvm-bc" => OutputTypeBitcode ,
919- "obj" => OutputTypeObject ,
920- "link" => OutputTypeExe ,
921- "dep-info" => OutputTypeDepInfo ,
922- _ => {
907+ for list in matches. opt_strs ( "emit" ) {
908+ for output_type in list . split ( ',' ) {
909+ let mut parts = output_type . splitn ( 2 , '=' ) ;
910+ let output_type = match parts . next ( ) . unwrap ( ) {
911+ "asm" => OutputType :: Assembly ,
912+ "llvm-ir" => OutputType :: LlvmAssembly ,
913+ "llvm-bc" => OutputType :: Bitcode ,
914+ "obj" => OutputType :: Object ,
915+ "link" => OutputType :: Exe ,
916+ "dep-info" => OutputType :: DepInfo ,
917+ part => {
923918 early_error ( color, & format ! ( "unknown emission type: `{}`" ,
924919 part) )
925920 }
926921 } ;
927- output_types. push ( output_type)
922+ let path = parts. next ( ) . map ( PathBuf :: from) ;
923+ output_types. insert ( output_type, path) ;
928924 }
929925 }
930926 } ;
931- output_types. sort ( ) ;
932- output_types. dedup ( ) ;
933927 if output_types. is_empty ( ) {
934- output_types. push ( OutputTypeExe ) ;
928+ output_types. insert ( OutputType :: Exe , None ) ;
935929 }
936930
937931 let cg = build_codegen_options ( matches, color) ;
@@ -1004,7 +998,6 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
1004998
1005999 let cfg = parse_cfgspecs ( matches. opt_strs ( "cfg" ) ) ;
10061000 let test = matches. opt_present ( "test" ) ;
1007- let write_dependency_info = ( output_types. contains ( & OutputTypeDepInfo ) , None ) ;
10081001
10091002 let prints = matches. opt_strs ( "print" ) . into_iter ( ) . map ( |s| {
10101003 match & * s {
@@ -1059,7 +1052,6 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
10591052 always_build_mir : always_build_mir,
10601053 no_analysis : no_analysis,
10611054 debugging_opts : debugging_opts,
1062- write_dependency_info : write_dependency_info,
10631055 prints : prints,
10641056 cg : cg,
10651057 color : color,
0 commit comments