@@ -38,6 +38,34 @@ pub fn compile_windows_resource_file(
38
38
let resource_compiler =
39
39
find_resource_compiler ( & env:: var ( "CARGO_CFG_TARGET_ARCH" ) . unwrap ( ) ) . expect ( "found rc.exe" ) ;
40
40
41
+ let rc_path = resources_dir. join ( file_stem. with_extension ( "rc" ) ) ;
42
+
43
+ write_resource_script_file ( & rc_path, file_description, filetype) ;
44
+
45
+ let res_path = resources_dir. join ( file_stem. with_extension ( "res" ) ) ;
46
+
47
+ let status = process:: Command :: new ( resource_compiler)
48
+ . arg ( "/fo" )
49
+ . arg ( & res_path)
50
+ . arg ( & rc_path)
51
+ . status ( )
52
+ . expect ( "can execute resource compiler" ) ;
53
+ assert ! ( status. success( ) , "rc.exe failed with status {}" , status) ;
54
+ assert ! (
55
+ res_path. try_exists( ) . unwrap_or( false ) ,
56
+ "resource file {} was not created" ,
57
+ res_path. display( )
58
+ ) ;
59
+ res_path
60
+ }
61
+
62
+ /// Writes a Windows resource script file for the rust compiler with the product and file version information
63
+ /// into `rc_path`
64
+ fn write_resource_script_file (
65
+ rc_path : & path:: Path ,
66
+ file_description : & str ,
67
+ filetype : VersionInfoFileType ,
68
+ ) {
41
69
let mut resource_script = RESOURCE_TEMPLATE . to_string ( ) ;
42
70
43
71
// Set the string product and file version to the same thing as `rustc --version`
@@ -62,25 +90,8 @@ pub fn compile_windows_resource_file(
62
90
. replace ( "@RUSTC_PRODUCTVERSION_QUAD@" , & version. to_quad_string ( ) )
63
91
. replace ( "@RUSTC_PRODUCTVERSION_STR@" , & descriptive_version) ;
64
92
65
- let rc_path = resources_dir. join ( file_stem. with_extension ( "rc" ) ) ;
66
93
fs:: write ( & rc_path, resource_script)
67
94
. unwrap_or_else ( |_| panic ! ( "failed to write resource file {}" , rc_path. display( ) ) ) ;
68
-
69
- let res_path = resources_dir. join ( file_stem. with_extension ( "res" ) ) ;
70
-
71
- let status = process:: Command :: new ( resource_compiler)
72
- . arg ( "/fo" )
73
- . arg ( & res_path)
74
- . arg ( & rc_path)
75
- . status ( )
76
- . expect ( "can execute resource compiler" ) ;
77
- assert ! ( status. success( ) , "rc.exe failed with status {}" , status) ;
78
- assert ! (
79
- res_path. try_exists( ) . unwrap_or( false ) ,
80
- "resource file {} was not created" ,
81
- res_path. display( )
82
- ) ;
83
- res_path
84
95
}
85
96
86
97
fn product_name ( channel : String ) -> String {
0 commit comments