Skip to content

Commit

Permalink
Merge pull request #125 from serpilliere/add_winres
Browse files Browse the repository at this point in the history
Add windows binaries properties
  • Loading branch information
serpilliere authored Jan 19, 2023
2 parents ff6a7cc + 98493bc commit 5f65881
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 2 deletions.
11 changes: 10 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion sanzu/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sanzu"
version = "0.1.0"
version = "0.1.1"
authors = ["Fabrice Desclaux <[email protected]>"]
edition = "2018"
readme = "README.md"
Expand All @@ -10,6 +10,7 @@ license = "GPL-3.0"
[build-dependencies]
bindgen = "0.63"
cc = "1.0"
winres = {git = "https://github.com/serpilliere/winres", branch="link_resources"}

[dependencies]
anyhow = "1.0"
Expand Down Expand Up @@ -108,6 +109,9 @@ assets = [
{ source = "README.md", dest = "/usr/share/doc/sanzu/README", mode = "0644", doc = true },
]

[package.metadata.winres]
LegalCopyright = "Copyright © 2021-2023"
FileDescription = "Sanzu video server, proxy and client"

# Compilation for Windows:
# export PKG_CONFIG_ALLOW_CROSS=1
Expand Down
31 changes: 31 additions & 0 deletions sanzu/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
extern crate winres;

fn main() {
// only run if target os is windows
if std::env::var("CARGO_CFG_TARGET_OS").unwrap() != "windows" {
return;
}
// 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();
if cfg!(unix) {
// paths for X64 on archlinux
res.set_toolkit_path("/usr/bin");
// ar tool for mingw in toolkit path
res.set_ar_path("/usr/bin/x86_64-w64-mingw32-ar");
// windres tool
res.set_windres_path("/usr/bin/x86_64-w64-mingw32-windres");
}

res.set_icon("data/icons/sanzu.ico")
// can't use winapi crate constants for cross compiling
// MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US )
.set_language(0x0409)
.set_manifest_file("data/winres/manifest.xml");
if let Err(e) = res.compile() {
eprintln!("{}", e);
std::process::exit(1);
}
}
}
Binary file added sanzu/data/icons/sanzu.ico
Binary file not shown.
40 changes: 40 additions & 0 deletions sanzu/data/winres/manifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!-- example.exe.manifest -->
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<assemblyIdentity
type="win32"
name="Sanzu"
processorArchitecture="x86"
/>
<description>Sanzu</description>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- Windows 10 and Windows 11 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
<!-- Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
<!-- Windows 8 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
<!-- Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<!-- Windows Vista -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
</application>
</compatibility>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<!--
UAC settings:
- app should run at same integrity level as calling process
- app does not need to manipulate windows belonging to
higher-integrity-level processes
-->
<requestedExecutionLevel
level="asInvoker"
uiAccess="false"
/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>

0 comments on commit 5f65881

Please sign in to comment.