@@ -8,13 +8,13 @@ extern crate log;
8
8
extern crate clang_sys;
9
9
extern crate rustc_serialize;
10
10
11
- use bindgen:: { Bindings , BindgenOptions , LinkType } ;
11
+ use bindgen:: { BindgenOptions , Bindings , LinkType } ;
12
12
use std:: default:: Default ;
13
+ use std:: env;
14
+ use std:: fs;
13
15
use std:: io;
14
16
use std:: path;
15
17
use std:: process;
16
- use std:: env;
17
- use std:: fs;
18
18
19
19
const USAGE : & ' static str = "
20
20
Usage:
@@ -119,31 +119,37 @@ fn parse_args_or_exit(args: Vec<String>) -> (BindgenOptions, Box<io::Write>) {
119
119
options. links . push ( ( lib, LinkType :: Static ) ) ;
120
120
}
121
121
"--framework-link" => {
122
- let lib = iter. next ( ) . expect ( "--framework-link needs an argument" ) ;
122
+ let lib = iter. next ( )
123
+ . expect ( "--framework-link needs an argument" ) ;
123
124
options. links . push ( ( lib, LinkType :: Framework ) ) ;
124
125
}
125
126
"--raw-line" => {
126
127
let line = iter. next ( ) . expect ( "--raw-line needs an argument" ) ;
127
128
options. raw_lines . push ( line) ;
128
129
}
129
130
"--opaque-type" => {
130
- let ty_canonical_name = iter. next ( ) . expect ( "--opaque-type expects a type" ) ;
131
+ let ty_canonical_name = iter. next ( )
132
+ . expect ( "--opaque-type expects a type" ) ;
131
133
options. opaque_types . insert ( ty_canonical_name) ;
132
134
}
133
135
"--blacklist-type" => {
134
- let ty_canonical_name = iter. next ( ) . expect ( "--blacklist-type expects a type" ) ;
136
+ let ty_canonical_name = iter. next ( )
137
+ . expect ( "--blacklist-type expects a type" ) ;
135
138
options. hidden_types . insert ( ty_canonical_name) ;
136
139
}
137
140
"--whitelist-type" => {
138
- let ty_pat = iter. next ( ) . expect ( "--whitelist-type expects a type pattern" ) ;
141
+ let ty_pat = iter. next ( )
142
+ . expect ( "--whitelist-type expects a type pattern" ) ;
139
143
options. whitelisted_types . insert ( & ty_pat) ;
140
144
}
141
145
"--whitelist-function" => {
142
- let function_pat = iter. next ( ) . expect ( "--whitelist-function expects a pattern" ) ;
146
+ let function_pat = iter. next ( )
147
+ . expect ( "--whitelist-function expects a pattern" ) ;
143
148
options. whitelisted_functions . insert ( & function_pat) ;
144
149
}
145
150
"--whitelist-var" => {
146
- let var_pat = iter. next ( ) . expect ( "--whitelist-var expects a pattern" ) ;
151
+ let var_pat = iter. next ( )
152
+ . expect ( "--whitelist-var expects a pattern" ) ;
147
153
options. whitelisted_vars . insert ( & var_pat) ;
148
154
}
149
155
"--" => {
@@ -202,25 +208,31 @@ fn parse_args_or_exit(args: Vec<String>) -> (BindgenOptions, Box<io::Write>) {
202
208
203
209
pub fn main ( ) {
204
210
log:: set_logger ( |max_log_level| {
205
- use env_logger:: Logger ;
206
- let env_logger = Logger :: new ( ) ;
207
- max_log_level. set ( env_logger. filter ( ) ) ;
208
- Box :: new ( env_logger)
209
- } ) . expect ( "Failed to set logger." ) ;
211
+ use env_logger:: Logger ;
212
+ let env_logger = Logger :: new ( ) ;
213
+ max_log_level. set ( env_logger. filter ( ) ) ;
214
+ Box :: new ( env_logger)
215
+ } )
216
+ . expect ( "Failed to set logger." ) ;
210
217
211
218
let mut bind_args: Vec < _ > = env:: args ( ) . collect ( ) ;
212
219
213
220
if let Some ( clang) = clang_sys:: support:: Clang :: find ( None ) {
214
- let has_clang_args = bind_args. iter ( ) . rposition ( |arg| * arg == "--" ) . is_some ( ) ;
221
+ let has_clang_args =
222
+ bind_args. iter ( ) . rposition ( |arg| * arg == "--" ) . is_some ( ) ;
215
223
if !has_clang_args {
216
224
bind_args. push ( "--" . to_owned ( ) ) ;
217
225
}
218
226
219
- // If --target is specified, assume caller knows what they're doing and don't mess with
227
+ // If --target is specified, assume caller knows what they're doing and
228
+ // don't mess with
220
229
// include paths for them
221
- let has_target_arg = bind_args. iter ( ) . rposition ( |arg| arg. starts_with ( "--target" ) ) . is_some ( ) ;
230
+ let has_target_arg = bind_args. iter ( )
231
+ . rposition ( |arg| arg. starts_with ( "--target" ) )
232
+ . is_some ( ) ;
222
233
if !has_target_arg {
223
- // TODO: distinguish C and C++ paths? C++'s should be enough, I guess.
234
+ // TODO: distinguish C and C++ paths? C++'s should be enough, I
235
+ // guess.
224
236
for path in clang. cpp_search_paths . into_iter ( ) {
225
237
if let Ok ( path) = path. into_os_string ( ) . into_string ( ) {
226
238
bind_args. push ( "-isystem" . to_owned ( ) ) ;
@@ -233,8 +245,8 @@ pub fn main() {
233
245
let ( options, out) = parse_args_or_exit ( bind_args) ;
234
246
235
247
let bindings = Bindings :: generate ( options, None )
236
- . expect ( "Unable to generate bindings" ) ;
248
+ . expect ( "Unable to generate bindings" ) ;
237
249
238
250
bindings. write ( out)
239
- . expect ( "Unable to write bindings to file." ) ;
251
+ . expect ( "Unable to write bindings to file." ) ;
240
252
}
0 commit comments