-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #243 from SalOne22/feature/add_exe_info
chore: add version info and other infos for windows
- Loading branch information
Showing
5 changed files
with
157 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,7 @@ | |
|
||
# code coverage | ||
lcov.info | ||
|
||
# self build scrpits | ||
*.ps1 | ||
*.log |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
extern crate winres; | ||
use std::env; | ||
use winres::VersionInfo; | ||
|
||
fn main() { | ||
// only run if target os is windows | ||
if env::var("CARGO_CFG_TARGET_OS").unwrap() != "windows" { | ||
println!( | ||
"cargo:warning={:#?}", | ||
"This build script is only for windows target, skipping..." | ||
); | ||
return; | ||
} | ||
|
||
let mut res = winres::WindowsResource::new(); | ||
|
||
match env::var("CARGO_PKG_VERSION_PRE") { | ||
Ok(success_info) => println!("{}", success_info), | ||
Err(err_info) => println!("{}", err_info), | ||
}; | ||
|
||
//version X. X. X. X | ||
// ⇑ ⇑ ⇑ ⇑ | ||
// MAJOR MINOR PATCH PRE | ||
let mut version: u64 = 0; | ||
version |= { | ||
env::var("CARGO_PKG_VERSION_MAJOR") | ||
.unwrap() | ||
.parse::<u64>() | ||
.unwrap() | ||
<< 48 | ||
}; | ||
version |= { | ||
env::var("CARGO_PKG_VERSION_MINOR") | ||
.unwrap() | ||
.parse::<u64>() | ||
.unwrap() | ||
<< 32 | ||
}; | ||
version |= { | ||
env::var("CARGO_PKG_VERSION_PATCH") | ||
.unwrap() | ||
.parse::<u64>() | ||
.unwrap() | ||
<< 16 | ||
}; | ||
|
||
let product_version = version | { | ||
let temp = env::var("CARGO_PKG_VERSION_PRE").unwrap(); | ||
if temp == *"" { | ||
0_u64 | ||
} else { | ||
temp.parse::<u64>().unwrap_or(0_u64) | ||
} | ||
}; | ||
|
||
res.set_version_info(VersionInfo::FILEVERSION, version) | ||
.set_version_info(VersionInfo::PRODUCTVERSION, product_version); | ||
|
||
if let Err(e) = res.compile() { | ||
eprintln!("{}", e); | ||
std::process::exit(1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[env] | ||
# Because rust doesn't support it in cargo.toml => package.version, so it has to be define here to avoid any accident | ||
CARGO_PKG_VERSION_PRE = { value = "2", force = true, relative = true } |