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 @@ -125,7 +125,7 @@ pub fn builder() -> Builder {
125
125
}
126
126
127
127
/// Construct a new [`Builder`](./struct.Builder.html) from command line flags.
128
- pub fn builder_from_flags < I > ( args : I ) -> Result < Builder , io:: Error >
128
+ pub fn builder_from_flags < I > ( args : I ) -> Result < ( Builder , Option < Box < io :: Write > > ) , io:: Error >
129
129
where I : Iterator < Item =String >
130
130
{
131
131
let matches = App :: new ( "bindgen" )
@@ -346,15 +346,14 @@ pub fn builder_from_flags<I>(args: I) -> Result<Builder, io::Error>
346
346
}
347
347
}
348
348
349
- // FIXME: hrrrmmm
350
- let _output = if let Some ( path) = matches. value_of ( "output" ) {
349
+ let output = if let Some ( path) = matches. value_of ( "output" ) {
351
350
let file = try!( File :: create ( path) ) ;
352
351
Box :: new ( io:: BufWriter :: new ( file) ) as Box < io:: Write >
353
352
} else {
354
353
Box :: new ( io:: BufWriter :: new ( io:: stdout ( ) ) ) as Box < io:: Write >
355
354
} ;
356
355
357
- Ok ( builder)
356
+ Ok ( ( builder, Some ( output ) ) )
358
357
}
359
358
360
359
impl Builder {
You can’t perform that action at this time.
0 commit comments