build: include metadata in Windows binary (#1735)
This commit is contained in:
parent
a5890a9901
commit
821fa38bc1
11
Cargo.lock
generated
11
Cargo.lock
generated
@ -3687,6 +3687,15 @@ dependencies = [
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winres"
|
||||
version = "0.1.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b68db261ef59e9e52806f688020631e987592bd83619edccda9c47d42cde4f6c"
|
||||
dependencies = [
|
||||
"toml",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ws"
|
||||
version = "0.9.1"
|
||||
@ -3784,7 +3793,9 @@ dependencies = [
|
||||
"search",
|
||||
"site",
|
||||
"termcolor",
|
||||
"time 0.3.7",
|
||||
"tokio",
|
||||
"utils",
|
||||
"winres",
|
||||
"ws",
|
||||
]
|
||||
|
||||
@ -15,6 +15,8 @@ include = ["src/**/*", "LICENSE", "README.md"]
|
||||
[build-dependencies]
|
||||
clap = "3"
|
||||
clap_complete = "3"
|
||||
winres = "0.1"
|
||||
time = "0.3"
|
||||
|
||||
[[bin]]
|
||||
name = "zola"
|
||||
@ -64,3 +66,7 @@ codegen-units = 1
|
||||
# Disabling debug info speeds up builds a bunch,
|
||||
# and we don't rely on it for debugging that much.
|
||||
debug = 0
|
||||
|
||||
[package.metadata.winres]
|
||||
OriginalFilename = "zola.exe"
|
||||
InternalName = "zola"
|
||||
|
||||
21
build.rs
21
build.rs
@ -2,6 +2,21 @@
|
||||
|
||||
include!("src/cli.rs");
|
||||
|
||||
fn generate_pe_header() {
|
||||
use time::OffsetDateTime;
|
||||
|
||||
let today = OffsetDateTime::now_utc();
|
||||
let copyright = format!("Copyright © 2017-{} Vincent Prouillet", today.year());
|
||||
let mut res = winres::WindowsResource::new();
|
||||
// needed for MinGW cross-compiling
|
||||
if cfg!(unix) {
|
||||
res.set_windres_path("x86_64-w64-mingw32-windres");
|
||||
}
|
||||
res.set_icon("docs/static/favicon.ico");
|
||||
res.set("LegalCopyright", ©right);
|
||||
res.compile().expect("Failed to compile Windows resources!");
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// disabled below as it fails in CI
|
||||
// let mut app = build_cli();
|
||||
@ -9,4 +24,10 @@ fn main() {
|
||||
// app.gen_completions("zola", Shell::Fish, "completions/");
|
||||
// app.gen_completions("zola", Shell::Zsh, "completions/");
|
||||
// app.gen_completions("zola", Shell::PowerShell, "completions/");
|
||||
if std::env::var("CARGO_CFG_TARGET_OS").unwrap() != "windows"
|
||||
&& std::env::var("PROFILE").unwrap() != "release"
|
||||
{
|
||||
return;
|
||||
}
|
||||
generate_pe_header();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user