@@ -43,6 +43,13 @@ pub fn run(settings: BindingBuilderSettings) {
4343 . takes_value ( true )
4444 . help ( "Generate package with the provided modules" ) ,
4545 )
46+ . arg (
47+ Arg :: with_name ( "extra-files" )
48+ . short ( "f" )
49+ . long ( "extra-files" )
50+ . takes_value ( true )
51+ . help ( "Path to extra files to include in the generated bindings" ) ,
52+ )
4653 . get_matches ( ) ;
4754
4855 let run_tests = !matches. is_present ( "no-tests" ) ;
@@ -55,18 +62,34 @@ pub fn run(settings: BindingBuilderSettings) {
5562 let package = matches. is_present ( "package" ) ;
5663 let package_src = matches. value_of ( "package" ) ;
5764
65+ let extra_files = matches
66+ . values_of ( "extra-files" )
67+ . map_or ( Vec :: new ( ) , |v| v. map ( PathBuf :: from) . collect ( ) ) ;
68+
5869 if run_c || run_all {
59- let builder = run_builder :: < CBindingBuilder > ( & settings, run_tests, package, package_src) ;
70+ let builder = run_builder :: < CBindingBuilder > (
71+ & settings,
72+ run_tests,
73+ package,
74+ package_src,
75+ & extra_files,
76+ ) ;
6077
6178 if matches. is_present ( "doxygen" ) {
6279 builder. build_doxygen ( ) ;
6380 }
6481 }
6582 if run_dotnet || run_all {
66- run_builder :: < DotnetBindingBuilder > ( & settings, run_tests, package, package_src) ;
83+ run_builder :: < DotnetBindingBuilder > (
84+ & settings,
85+ run_tests,
86+ package,
87+ package_src,
88+ & extra_files,
89+ ) ;
6790 }
6891 if run_java || run_all {
69- run_builder :: < JavaBindingBuilder > ( & settings, run_tests, package, package_src) ;
92+ run_builder :: < JavaBindingBuilder > ( & settings, run_tests, package, package_src, & extra_files ) ;
7093 }
7194}
7295
@@ -79,6 +102,7 @@ fn run_builder<'a, B: BindingBuilder<'a>>(
79102 run_tests : bool ,
80103 package : bool ,
81104 package_src : Option < & str > ,
105+ extra_files : & [ PathBuf ] ,
82106) -> B {
83107 let mut platforms = PlatformLocations :: new ( ) ;
84108 if let Some ( package_src) = package_src {
@@ -111,7 +135,7 @@ fn run_builder<'a, B: BindingBuilder<'a>>(
111135
112136 let has_dynamic_libs = platforms. has_dynamic_lib ( ) ;
113137
114- let mut builder = B :: new ( settings, platforms) ;
138+ let mut builder = B :: new ( settings, platforms, extra_files ) ;
115139
116140 if B :: requires_dynamic_lib ( ) && !has_dynamic_libs {
117141 println ! (
@@ -144,7 +168,11 @@ pub struct BindingBuilderSettings<'a> {
144168trait BindingBuilder < ' a > {
145169 fn name ( ) -> & ' static str ;
146170 fn requires_dynamic_lib ( ) -> bool ;
147- fn new ( settings : & ' a BindingBuilderSettings < ' a > , platforms : PlatformLocations ) -> Self ;
171+ fn new (
172+ settings : & ' a BindingBuilderSettings < ' a > ,
173+ platforms : PlatformLocations ,
174+ extra_files : & [ PathBuf ] ,
175+ ) -> Self ;
148176 fn generate ( & mut self , is_packaging : bool ) ;
149177 fn build ( & mut self ) ;
150178 fn test ( & mut self ) ;
@@ -154,13 +182,15 @@ trait BindingBuilder<'a> {
154182struct CBindingBuilder < ' a > {
155183 settings : & ' a BindingBuilderSettings < ' a > ,
156184 platforms : PlatformLocations ,
185+ extra_files : Vec < PathBuf > ,
157186}
158187
159188impl < ' a > CBindingBuilder < ' a > {
160189 fn build_doxygen ( & self ) {
161190 let config = c_oo_bindgen:: CBindgenConfig {
162191 output_dir : self . output_dir ( ) ,
163192 ffi_name : self . settings . ffi_name . to_owned ( ) ,
193+ extra_files : Vec :: new ( ) ,
164194 platforms : self . platforms . clone ( ) ,
165195 } ;
166196
@@ -192,17 +222,23 @@ impl<'a> BindingBuilder<'a> for CBindingBuilder<'a> {
192222 false
193223 }
194224
195- fn new ( settings : & ' a BindingBuilderSettings < ' a > , platforms : PlatformLocations ) -> Self {
225+ fn new (
226+ settings : & ' a BindingBuilderSettings < ' a > ,
227+ platforms : PlatformLocations ,
228+ extra_files : & [ PathBuf ] ,
229+ ) -> Self {
196230 Self {
197231 settings,
198232 platforms,
233+ extra_files : extra_files. to_vec ( ) ,
199234 }
200235 }
201236
202237 fn generate ( & mut self , _is_packaging : bool ) {
203238 let config = c_oo_bindgen:: CBindgenConfig {
204239 output_dir : self . output_dir ( ) ,
205240 ffi_name : self . settings . ffi_name . to_owned ( ) ,
241+ extra_files : self . extra_files . clone ( ) ,
206242 platforms : self . platforms . clone ( ) ,
207243 } ;
208244
@@ -253,6 +289,7 @@ impl<'a> BindingBuilder<'a> for CBindingBuilder<'a> {
253289struct DotnetBindingBuilder < ' a > {
254290 settings : & ' a BindingBuilderSettings < ' a > ,
255291 platforms : PlatformLocations ,
292+ extra_files : Vec < PathBuf > ,
256293}
257294
258295impl < ' a > DotnetBindingBuilder < ' a > {
@@ -278,10 +315,15 @@ impl<'a> BindingBuilder<'a> for DotnetBindingBuilder<'a> {
278315 true
279316 }
280317
281- fn new ( settings : & ' a BindingBuilderSettings < ' a > , platforms : PlatformLocations ) -> Self {
318+ fn new (
319+ settings : & ' a BindingBuilderSettings < ' a > ,
320+ platforms : PlatformLocations ,
321+ extra_files : & [ PathBuf ] ,
322+ ) -> Self {
282323 Self {
283324 settings,
284325 platforms,
326+ extra_files : extra_files. to_vec ( ) ,
285327 }
286328 }
287329
@@ -296,6 +338,7 @@ impl<'a> BindingBuilder<'a> for DotnetBindingBuilder<'a> {
296338 let config = dotnet_oo_bindgen:: DotnetBindgenConfig {
297339 output_dir : build_dir,
298340 ffi_name : self . settings . ffi_name . to_owned ( ) ,
341+ extra_files : self . extra_files . clone ( ) ,
299342 platforms : self . platforms . clone ( ) ,
300343 } ;
301344
@@ -344,6 +387,7 @@ impl<'a> BindingBuilder<'a> for DotnetBindingBuilder<'a> {
344387struct JavaBindingBuilder < ' a > {
345388 settings : & ' a BindingBuilderSettings < ' a > ,
346389 platforms : PlatformLocations ,
390+ extra_files : Vec < PathBuf > ,
347391}
348392
349393impl < ' a > JavaBindingBuilder < ' a > {
@@ -390,10 +434,15 @@ impl<'a> BindingBuilder<'a> for JavaBindingBuilder<'a> {
390434 true
391435 }
392436
393- fn new ( settings : & ' a BindingBuilderSettings < ' a > , platforms : PlatformLocations ) -> Self {
437+ fn new (
438+ settings : & ' a BindingBuilderSettings < ' a > ,
439+ platforms : PlatformLocations ,
440+ extra_files : & [ PathBuf ] ,
441+ ) -> Self {
394442 Self {
395443 settings,
396444 platforms,
445+ extra_files : extra_files. to_vec ( ) ,
397446 }
398447 }
399448
@@ -404,6 +453,7 @@ impl<'a> BindingBuilder<'a> for JavaBindingBuilder<'a> {
404453 ffi_name : self . settings . ffi_name . to_owned ( ) ,
405454 ffi_path : self . settings . ffi_path . to_owned ( ) ,
406455 group_id : self . settings . java_group_id . to_owned ( ) ,
456+ extra_files : self . extra_files . clone ( ) ,
407457 platforms : self . platforms . clone ( ) ,
408458 } ;
409459
0 commit comments