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)
|
* SPDX-License-Identifier: (0BSD or MIT)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
extern crate winres;
|
use std::error::Error;
|
||||||
|
|
||||||
use twine::build_translations;
|
use twine::build_translations;
|
||||||
|
|
||||||
fn main() {
|
fn set_winres() -> Result<(), Box<dyn Error>> {
|
||||||
println!("cargo:rerun-if-changed=build.rs");
|
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();
|
build_translations(&["./src/i18n/localization.ini"], "i18n.rs").unwrap();
|
||||||
|
|
||||||
if cfg!(target_os = "windows") {
|
if cfg!(target_os="windows") {
|
||||||
let mut res = winres::WindowsResource::new();
|
set_winres()?;
|
||||||
//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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,20 +5,19 @@
|
|||||||
* SPDX-License-Identifier: (0BSD or MIT)
|
* SPDX-License-Identifier: (0BSD or MIT)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use std::env;
|
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
#[cfg(target_os = "windows")]
|
use twine::build_translations;
|
||||||
|
|
||||||
|
//#[cfg(windows)]
|
||||||
use windres::Build;
|
use windres::Build;
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn Error>> {
|
fn main() -> Result<(), Box<dyn Error>> {
|
||||||
if env::var("CARGO_CFG_TARGET_FAMILY")? == "windows" {
|
println!("cargo: rerun-if-changed=build.rs");
|
||||||
let mut res = Build::new();
|
build_translations(&["./src/i18n/localization.ini"], "i18n.rs").unwrap();
|
||||||
let target_env = std::env::var("CARGO_CFG_TARGET_ENV")?;
|
|
||||||
match target_env.as_str() {
|
println!("cargo: compile windows ressource");
|
||||||
"gnu" => res.set_icon("advotracker.rc"),
|
//#[cfg(windows)]
|
||||||
"msvc" => res.set_icon("advotracker.rc"),
|
Build::new().compile("advotracker.rc").unwrap();
|
||||||
_ => panic!("Unsupported env: {}", target_env),
|
|
||||||
};
|
Ok(())
|
||||||
res.compile()?
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,48 +5,55 @@
|
|||||||
* SPDX-License-Identifier: (0BSD or MIT)
|
* SPDX-License-Identifier: (0BSD or MIT)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use std::env;
|
use cfg_if::cfg_if;
|
||||||
use std::error::Error;
|
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>> {
|
//cfg_if! {
|
||||||
if env::var("CARGO_CFG_TARGET_FAMILY")? == "windows" {
|
// 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 mut res = WindowsResource::new();
|
||||||
let target_env = std::env::var("CARGO_CFG_TARGET_ENV")?;
|
//res.set_icon("assets/icons/advotracker/advotracker.ico")
|
||||||
match target_env.as_str() {
|
res.set_icon("icon.ico")
|
||||||
"gnu" => res
|
// needs winapi feature "winnt"
|
||||||
.set_ar_path("x86_64-w64-mingw32-ar")
|
.set_language(
|
||||||
.set_windres_path("x86_64-w64-mingw32-windres")
|
winapi::um::winnt::MAKELANGID(
|
||||||
.set_toolkit_path(".")
|
winapi::um::winnt::LANG_GERMAN
|
||||||
.set_icon(icon_path)
|
)
|
||||||
.set_version_info(VersionInfo::PRODUCTVERSION, 0x0000000100050003),
|
// winapi::um::winnt::MAKELANGID(
|
||||||
"msvc" => res.set_icon(icon_path),
|
// winapi::um::winnt::LANG_ENGLISH,
|
||||||
_ => panic!("Unsupported env: {}", target_env),
|
// 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()?;
|
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(())
|
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