@@ -40,27 +40,27 @@ pub fn compile_windows_resource_file(
4040
4141 let mut resource_script = RESOURCE_TEMPLATE . to_string ( ) ;
4242
43- // Set the string product version to the same thing as `rustc --version`
44- let product_version = env:: var ( "CFG_VERSION" ) . unwrap_or ( "unknown" . to_string ( ) ) ;
45- let file_version = & product_version;
46-
47- // This is just "major.minor.patch" and a "-dev", "-nightly" or similar suffix
48- let rel_version = env:: var ( "CFG_RELEASE" ) . unwrap ( ) ;
43+ // Set the string product and file version to the same thing as `rustc --version`
44+ let descriptive_version = env:: var ( "CFG_VERSION" ) . unwrap_or ( "unknown" . to_string ( ) ) ;
4945
46+ // Set the product name to "Rust Compiler" or "Rust Compiler (nightly)" etc
5047 let product_name = product_name ( env:: var ( "CFG_RELEASE_CHANNEL" ) . unwrap ( ) ) ;
5148
49+ // For the numeric version we need `major,minor,patch,build`.
50+ // Extract them from `CFG_RELEASE` which is "major.minor.patch" and a "-dev", "-nightly" or similar suffix
51+ let cfg_release = env:: var ( "CFG_RELEASE" ) . unwrap ( ) ;
5252 // remove the suffix, if present and parse into [`ResourceVersion`]
53- let version = parse_version ( rel_version . split ( "-" ) . next ( ) . unwrap_or ( "0.0.0" ) )
53+ let version = parse_version ( cfg_release . split ( "-" ) . next ( ) . unwrap_or ( "0.0.0" ) )
5454 . expect ( "valid CFG_RELEASE version" ) ;
5555
5656 resource_script = resource_script
5757 . replace ( "@RUSTC_FILEDESCRIPTION_STR@" , file_description)
5858 . replace ( "@RUSTC_FILETYPE@" , & format ! ( "{}" , filetype as u32 ) )
5959 . replace ( "@RUSTC_FILEVERSION_QUAD@" , & version. to_quad_string ( ) )
60- . replace ( "@RUSTC_FILEVERSION_STR@" , file_version )
60+ . replace ( "@RUSTC_FILEVERSION_STR@" , & descriptive_version )
6161 . replace ( "@RUSTC_PRODUCTNAME_STR@" , & product_name)
6262 . replace ( "@RUSTC_PRODUCTVERSION_QUAD@" , & version. to_quad_string ( ) )
63- . replace ( "@RUSTC_PRODUCTVERSION_STR@" , & product_version ) ;
63+ . replace ( "@RUSTC_PRODUCTVERSION_STR@" , & descriptive_version ) ;
6464
6565 let rc_path = resources_dir. join ( file_stem. with_extension ( "rc" ) ) ;
6666 fs:: write ( & rc_path, resource_script)
0 commit comments