File tree 2 files changed +8
-6
lines changed
2 files changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -66,13 +66,16 @@ pub fn main() {
66
66
}
67
67
}
68
68
69
- if let Ok ( builder) = bindgen:: builder_from_flags ( env:: args ( ) ) {
69
+ if let Ok ( ( builder, Some ( output ) ) ) = bindgen:: builder_from_flags ( env:: args ( ) ) {
70
70
//println!("{:#?}", builder);
71
71
72
72
let bindings = builder. generate ( )
73
73
. expect ( "Unable to generate bindings" ) ;
74
74
75
- println ! ( "{}" , bindings. to_string( ) ) ;
75
+ if let Err ( error) = bindings. write ( output) {
76
+ println ! ( "{:#?}" , error) ;
77
+ std:: process:: exit ( 1 ) ;
78
+ }
76
79
}
77
80
78
81
/*
Original file line number Diff line number Diff line change @@ -122,7 +122,7 @@ pub fn builder() -> Builder {
122
122
}
123
123
124
124
/// Construct a new [`Builder`](./struct.Builder.html) from command line flags.
125
- pub fn builder_from_flags < I > ( args : I ) -> Result < Builder , io:: Error >
125
+ pub fn builder_from_flags < I > ( args : I ) -> Result < ( Builder , Option < Box < io :: Write > > ) , io:: Error >
126
126
where I : Iterator < Item =String >
127
127
{
128
128
let matches = App :: new ( "bindgen" )
@@ -343,15 +343,14 @@ pub fn builder_from_flags<I>(args: I) -> Result<Builder, io::Error>
343
343
}
344
344
}
345
345
346
- // FIXME: hrrrmmm
347
- let _output = if let Some ( path) = matches. value_of ( "output" ) {
346
+ let output = if let Some ( path) = matches. value_of ( "output" ) {
348
347
let file = try!( File :: create ( path) ) ;
349
348
Box :: new ( io:: BufWriter :: new ( file) ) as Box < io:: Write >
350
349
} else {
351
350
Box :: new ( io:: BufWriter :: new ( io:: stdout ( ) ) ) as Box < io:: Write >
352
351
} ;
353
352
354
- Ok ( builder)
353
+ Ok ( ( builder, Some ( output ) ) )
355
354
}
356
355
357
356
impl Builder {
You can’t perform that action at this time.
0 commit comments