advotracker_client: update windows resource handling
Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
This commit is contained in:
@@ -5,21 +5,39 @@
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
extern crate winres;
|
||||
|
||||
use std::error::Error;
|
||||
use twine::build_translations;
|
||||
|
||||
fn main() {
|
||||
println!("cargo:rerun-if-changed=build.rs");
|
||||
fn set_winres() -> Result<(), Box<dyn Error>> {
|
||||
use winres::WindowsResource;
|
||||
//use winapi::{shared::windef::MAKELANGID, um::winuser::LANG_GERMAN};
|
||||
|
||||
if cfg!(target_os="windows") {
|
||||
println!("cargo: build windows resources");
|
||||
cfg!(target_env="gnu");
|
||||
let mut res = WindowsResource::new();
|
||||
res.set_icon("assets/icons/advotracker/advotracker.ico");
|
||||
// .set_language(MAKELANGID(LANG_GERMAN));
|
||||
// winapi::um::winnt::MAKELANGID(
|
||||
// winapi::um::winnt::LANG_ENGLISH,
|
||||
// winapi::um::winnt::SUBLANG_ENGLISH_US);
|
||||
|
||||
//res.set("InternalName", "ADVOTRACKER.EXE")
|
||||
// manually set version 0.1.8.0
|
||||
//.set_version_info(VersionInfo::PRODUCTVERSION, 0x0000000100080000);
|
||||
res.compile()?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn main() -> Result<(), Box<dyn Error>> {
|
||||
println!("cargo: rerun-if-changed=build.rs");
|
||||
build_translations(&["./src/i18n/localization.ini"], "i18n.rs").unwrap();
|
||||
|
||||
if cfg!(target_os = "windows") {
|
||||
let mut res = winres::WindowsResource::new();
|
||||
//res.set_icon(".\assets\icons\adovtracker\advotracker.ico")
|
||||
res.set_icon("advotracker.ico")
|
||||
.set("InternalName", "ADVOTRACKER.EXE")
|
||||
// manually set version 0.1.5.2
|
||||
.set_version_info(winres::VersionInfo::PRODUCTVERSION, 0x0000000100050002);
|
||||
res.compile().unwrap();
|
||||
if cfg!(target_os="windows") {
|
||||
set_winres()?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -5,20 +5,19 @@
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
use std::env;
|
||||
use std::error::Error;
|
||||
#[cfg(target_os = "windows")]
|
||||
use twine::build_translations;
|
||||
|
||||
//#[cfg(windows)]
|
||||
use windres::Build;
|
||||
|
||||
fn main() -> Result<(), Box<dyn Error>> {
|
||||
if env::var("CARGO_CFG_TARGET_FAMILY")? == "windows" {
|
||||
let mut res = Build::new();
|
||||
let target_env = std::env::var("CARGO_CFG_TARGET_ENV")?;
|
||||
match target_env.as_str() {
|
||||
"gnu" => res.set_icon("advotracker.rc"),
|
||||
"msvc" => res.set_icon("advotracker.rc"),
|
||||
_ => panic!("Unsupported env: {}", target_env),
|
||||
};
|
||||
res.compile()?
|
||||
}
|
||||
println!("cargo: rerun-if-changed=build.rs");
|
||||
build_translations(&["./src/i18n/localization.ini"], "i18n.rs").unwrap();
|
||||
|
||||
println!("cargo: compile windows ressource");
|
||||
//#[cfg(windows)]
|
||||
Build::new().compile("advotracker.rc").unwrap();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -5,48 +5,55 @@
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
use std::env;
|
||||
use cfg_if::cfg_if;
|
||||
use std::error::Error;
|
||||
use winres::{WindowsResource, VersionInfo};
|
||||
use twine::build_translations;
|
||||
#[cfg(target_os="windows")]
|
||||
use winres::{VersionInfo, WindowsResource};
|
||||
#[cfg(target_os="windows")]
|
||||
use winapi;
|
||||
|
||||
fn add_icon_to_bin_when_building_for_win(icon_path: &str) -> Result<(), Box<dyn Error>> {
|
||||
if env::var("CARGO_CFG_TARGET_FAMILY")? == "windows" {
|
||||
//cfg_if! {
|
||||
// if #[cfg(windows)] {
|
||||
fn set_winres() -> Result<(), Box<dyn Error>> {
|
||||
println!("cargo: build windows resources");
|
||||
cfg!(target_env="gnu");
|
||||
let mut res = WindowsResource::new();
|
||||
let target_env = std::env::var("CARGO_CFG_TARGET_ENV")?;
|
||||
match target_env.as_str() {
|
||||
"gnu" => res
|
||||
.set_ar_path("x86_64-w64-mingw32-ar")
|
||||
.set_windres_path("x86_64-w64-mingw32-windres")
|
||||
.set_toolkit_path(".")
|
||||
.set_icon(icon_path)
|
||||
.set_version_info(VersionInfo::PRODUCTVERSION, 0x0000000100050003),
|
||||
"msvc" => res.set_icon(icon_path),
|
||||
_ => panic!("Unsupported env: {}", target_env),
|
||||
};
|
||||
//res.set_icon("assets/icons/advotracker/advotracker.ico")
|
||||
res.set_icon("icon.ico")
|
||||
// needs winapi feature "winnt"
|
||||
.set_language(
|
||||
winapi::um::winnt::MAKELANGID(
|
||||
winapi::um::winnt::LANG_GERMAN
|
||||
)
|
||||
// winapi::um::winnt::MAKELANGID(
|
||||
// winapi::um::winnt::LANG_ENGLISH,
|
||||
// winapi::um::winnt::SUBLANG_ENGLISH_US
|
||||
);
|
||||
//res.set_icon("advotracker.ico")
|
||||
//res.set("InternalName", "ADVOTRACKER.EXE")
|
||||
// manually set version 0.1.8.0
|
||||
//.set_version_info(VersionInfo::PRODUCTVERSION, 0x0000000100080000);
|
||||
res.compile()?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
// }
|
||||
//}
|
||||
|
||||
fn main() -> Result<(), Box<dyn Error>> {
|
||||
println!("cargo: rerun-if-changed=build.rs");
|
||||
build_translations(&["./src/i18n/localization.ini"], "i18n.rs").unwrap();
|
||||
|
||||
println!("Target-OS: windows!");
|
||||
set_winres()?;
|
||||
|
||||
// cfg_if! {
|
||||
// if #[cfg(windows)] {
|
||||
// println!("Target-OS: windows!");
|
||||
// set_winres()?;
|
||||
// }
|
||||
// }
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn main() -> Result<(), Box<dyn Error>> {
|
||||
add_icon_to_bin_when_building_for_win("./assets/icons/advotracker/advotracker.ico")
|
||||
}
|
||||
|
||||
// // only build for windows
|
||||
// fn main() {
|
||||
// if cfg!(target_os = "windows") {
|
||||
// println!("You are building for windows!");
|
||||
// // only build the resource for release builds
|
||||
// // as calling rc.exe might be slow
|
||||
// //if std::env::var("PROFILE").unwrap() == "release" { ]
|
||||
// let mut res = winres::WindowsResource::new();
|
||||
// res.set_icon("advotracker.ico")
|
||||
// .set("InternalName", "ADVOTRACKER.EXE")
|
||||
// // manually set version 0.1.5.2
|
||||
// .set_version_info(winres::VersionInfo::PRODUCTVERSION, 0x0000000100050003);
|
||||
// res.compile().unwrap();
|
||||
// } else {
|
||||
// println!("not windows, so no resource icon needed!");
|
||||
// }
|
||||
// }
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
advotracker ICON "./assets/icons/advotracker/advotracker.ico"
|
||||
Reference in New Issue
Block a user