@@ -15,7 +15,6 @@ pub use self::EntryFnType::*;
15
15
pub use self :: CrateType :: * ;
16
16
pub use self :: Passes :: * ;
17
17
pub use self :: OptLevel :: * ;
18
- pub use self :: OutputType :: * ;
19
18
pub use self :: DebugInfoLevel :: * ;
20
19
21
20
use session:: { early_error, early_warn, Session } ;
@@ -62,14 +61,14 @@ pub enum DebugInfoLevel {
62
61
FullDebugInfo ,
63
62
}
64
63
65
- #[ derive( Clone , Copy , PartialEq , PartialOrd , Ord , Eq ) ]
64
+ #[ derive( Clone , Copy , PartialEq , Eq , Hash ) ]
66
65
pub 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 ,
73
72
}
74
73
75
74
#[ derive( Clone ) ]
@@ -85,7 +84,7 @@ pub struct Options {
85
84
pub lint_opts : Vec < ( String , lint:: Level ) > ,
86
85
pub lint_cap : Option < lint:: Level > ,
87
86
pub describe_lints : bool ,
88
- pub output_types : Vec < OutputType > ,
87
+ pub output_types : HashMap < OutputType , Option < PathBuf > > ,
89
88
// This was mutable for rustpkg, which updates search paths based on the
90
89
// parsed code. It remains mutable in case its replacements wants to use
91
90
// this.
@@ -105,8 +104,6 @@ pub struct Options {
105
104
pub always_build_mir : bool ,
106
105
pub no_analysis : bool ,
107
106
pub debugging_opts : DebuggingOptions ,
108
- /// Whether to write dependency files. It's (enabled, optional filename).
109
- pub write_dependency_info : ( bool , Option < PathBuf > ) ,
110
107
pub prints : Vec < PrintRequest > ,
111
108
pub cg : CodegenOptions ,
112
109
pub color : ColorConfig ,
@@ -151,26 +148,25 @@ pub struct OutputFilenames {
151
148
pub out_filestem : String ,
152
149
pub single_output_file : Option < PathBuf > ,
153
150
pub extra : String ,
151
+ pub outputs : HashMap < OutputType , Option < PathBuf > > ,
154
152
}
155
153
156
154
impl OutputFilenames {
157
155
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) )
163
159
}
164
160
165
161
pub fn temp_path ( & self , flavor : OutputType ) -> PathBuf {
166
162
let base = self . out_directory . join ( & self . filestem ( ) ) ;
167
163
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,
174
170
}
175
171
}
176
172
@@ -206,7 +202,7 @@ pub fn basic_options() -> Options {
206
202
lint_opts : Vec :: new ( ) ,
207
203
lint_cap : None ,
208
204
describe_lints : false ,
209
- output_types : Vec :: new ( ) ,
205
+ output_types : HashMap :: new ( ) ,
210
206
search_paths : SearchPaths :: new ( ) ,
211
207
maybe_sysroot : None ,
212
208
target_triple : host_triple ( ) . to_string ( ) ,
@@ -218,7 +214,6 @@ pub fn basic_options() -> Options {
218
214
always_build_mir : false ,
219
215
no_analysis : false ,
220
216
debugging_opts : basic_debugging_options ( ) ,
221
- write_dependency_info : ( false , None ) ,
222
217
prints : Vec :: new ( ) ,
223
218
cg : basic_codegen_options ( ) ,
224
219
color : Auto ,
@@ -907,31 +902,30 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
907
902
unsafe { llvm:: LLVMSetDebug ( 1 ) ; }
908
903
}
909
904
910
- let mut output_types = Vec :: new ( ) ;
905
+ let mut output_types = HashMap :: new ( ) ;
911
906
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 => {
923
918
early_error ( color, & format ! ( "unknown emission type: `{}`" ,
924
919
part) )
925
920
}
926
921
} ;
927
- output_types. push ( output_type)
922
+ let path = parts. next ( ) . map ( PathBuf :: from) ;
923
+ output_types. insert ( output_type, path) ;
928
924
}
929
925
}
930
926
} ;
931
- output_types. sort ( ) ;
932
- output_types. dedup ( ) ;
933
927
if output_types. is_empty ( ) {
934
- output_types. push ( OutputTypeExe ) ;
928
+ output_types. insert ( OutputType :: Exe , None ) ;
935
929
}
936
930
937
931
let cg = build_codegen_options ( matches, color) ;
@@ -1004,7 +998,6 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
1004
998
1005
999
let cfg = parse_cfgspecs ( matches. opt_strs ( "cfg" ) ) ;
1006
1000
let test = matches. opt_present ( "test" ) ;
1007
- let write_dependency_info = ( output_types. contains ( & OutputTypeDepInfo ) , None ) ;
1008
1001
1009
1002
let prints = matches. opt_strs ( "print" ) . into_iter ( ) . map ( |s| {
1010
1003
match & * s {
@@ -1059,7 +1052,6 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
1059
1052
always_build_mir : always_build_mir,
1060
1053
no_analysis : no_analysis,
1061
1054
debugging_opts : debugging_opts,
1062
- write_dependency_info : write_dependency_info,
1063
1055
prints : prints,
1064
1056
cg : cg,
1065
1057
color : color,
0 commit comments