diff --git a/Cargo.lock b/Cargo.lock index 381bcedb15..9fc3c71be3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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" @@ -3768,6 +3777,7 @@ name = "zola" version = "0.16.0" dependencies = [ "atty", + "chrono", "clap 3.0.13", "clap_complete", "ctrlc", @@ -3786,5 +3796,6 @@ dependencies = [ "termcolor", "tokio", "utils", + "winres", "ws", ] diff --git a/Cargo.toml b/Cargo.toml index 7e14095b23..204a18f29b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,6 +15,8 @@ include = ["src/**/*", "LICENSE", "README.md"] [build-dependencies] clap = "3" clap_complete = "3" +winres = "0.1" +chrono = "0.4" [[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" diff --git a/build.rs b/build.rs index f6e897786b..0346723635 100644 --- a/build.rs +++ b/build.rs @@ -2,6 +2,21 @@ include!("src/cli.rs"); +fn generate_pe_header() { + use chrono::prelude::*; + + let today = Utc::today(); + 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(); }