@@ -90,6 +90,8 @@ pub struct WindowsResource {
90
90
manifest : Option < String > ,
91
91
manifest_file : Option < String > ,
92
92
output_directory : String ,
93
+ windres_path : Option < String > ,
94
+ ar_path : Option < String > ,
93
95
}
94
96
95
97
impl WindowsResource {
@@ -185,6 +187,8 @@ impl WindowsResource {
185
187
manifest : None ,
186
188
manifest_file : None ,
187
189
output_directory : env:: var ( "OUT_DIR" ) . unwrap_or ( "." . to_string ( ) ) ,
190
+ windres_path : None ,
191
+ ar_path : None ,
188
192
}
189
193
}
190
194
@@ -352,6 +356,18 @@ impl WindowsResource {
352
356
self
353
357
}
354
358
359
+ /// Set the path to the windres executable.
360
+ pub fn set_windres_path ( & mut self , path : & str ) -> & mut Self {
361
+ self . windres_path = Some ( path. to_string ( ) ) ;
362
+ self
363
+ }
364
+
365
+ /// Set the path to the ar executable.
366
+ pub fn set_ar_path ( & mut self , path : & str ) -> & mut Self {
367
+ self . ar_path = Some ( path. to_string ( ) ) ;
368
+ self
369
+ }
370
+
355
371
/// Write a resource file with the set values
356
372
pub fn write_resource_file < P : AsRef < Path > > ( & self , path : P ) -> io:: Result < ( ) > {
357
373
let mut f = try!( fs:: File :: create ( path) ) ;
@@ -432,7 +448,8 @@ impl WindowsResource {
432
448
fn compile_with_toolkit < ' a > ( & self , input : & ' a str , output_dir : & ' a str ) -> io:: Result < ( ) > {
433
449
let output = PathBuf :: from ( output_dir) . join ( "resource.o" ) ;
434
450
let input = PathBuf :: from ( input) ;
435
- let status = process:: Command :: new ( "windres.exe" )
451
+ let windres_path = self . windres_path . as_ref ( ) . map_or ( "windres.exe" , String :: as_str) ;
452
+ let status = process:: Command :: new ( windres_path)
436
453
. current_dir ( & self . toolkit_path )
437
454
. arg ( format ! ( "-I{}" , env:: var( "CARGO_MANIFEST_DIR" ) . unwrap( ) ) )
438
455
. arg ( format ! ( "{}" , input. display( ) ) )
@@ -443,7 +460,8 @@ impl WindowsResource {
443
460
}
444
461
445
462
let libname = PathBuf :: from ( output_dir) . join ( "libresource.a" ) ;
446
- let status = process:: Command :: new ( "ar.exe" )
463
+ let ar_path = self . ar_path . as_ref ( ) . map_or ( "ar.exe" , String :: as_str) ;
464
+ let status = process:: Command :: new ( ar_path)
447
465
. current_dir ( & self . toolkit_path )
448
466
. arg ( "rsc" )
449
467
. arg ( format ! ( "{}" , libname. display( ) ) )
0 commit comments