Skip to content

Commit

Permalink
Merge pull request #243 from SalOne22/feature/add_exe_info
Browse files Browse the repository at this point in the history
chore: add version info and other infos for windows
  • Loading branch information
SalOne22 committed Jul 29, 2024
2 parents c9e463c + dc8ca2a commit bcb4a2b
Show file tree
Hide file tree
Showing 5 changed files with 157 additions and 27 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@

# code coverage
lcov.info

# self build scrpits
*.ps1
*.log
21 changes: 20 additions & 1 deletion Cargo.lock

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

92 changes: 66 additions & 26 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,33 +1,64 @@
[package]
name = "rimage"
version = "0.11.0-next.2"
edition = "2021"
description = "Optimize images natively with best-in-class codecs"
license = "MIT OR Apache-2.0"
readme = "README.md"
authors = ["Vladyslav Vladinov <vladinov.dev@gmail.com>"]
keywords = ["image", "compression", "encoder"]
categories = ["compression", "multimedia::images"]
repository = "https://github.com/SalOne22/rimage"
name = "rimage"
version = "0.11.0-next.2"
edition = "2021"
description = "Optimize images natively with best-in-class codecs"
license = "MIT OR Apache-2.0"
readme = "README.md"
authors = ["Vladyslav Vladinov <vladinov.dev@gmail.com>"]
keywords = ["image", "compression", "encoder"]
categories = ["compression", "multimedia::images"]
repository = "https://github.com/SalOne22/rimage"
documentation = "https://docs.rs/rimage"
homepage = "https://lib.rs/rimage"
include = ["/README.md", "/Cargo.toml", "/src/**/*.rs"]
homepage = "https://lib.rs/rimage"
include = ["/README.md", "/Cargo.toml", "/src/**/*.rs"]
build = "build.rs"

[package.metadata.winres]
LegalCopyright = "Copyright Vladyslav Vladinov © 2024"
FileDescription = "Powerful img optimization CLI tool by Rust"

[build-dependencies]
winres = { version = "0.1.12", default-features = false }

[profile.release]
lto = true
lto = true
codegen-units = 1
strip = true
strip = true
panic = "abort"

[[bin]]
name = "rimage"
path = "./src/main.rs"
name = "rimage"
path = "./src/main.rs"
required-features = ["build-binary"]

[features]
default = ["resize", "quantization", "mozjpeg", "oxipng", "webp", "avif", "tiff", "threads", "metadata"]
default = [
"resize",
"quantization",
"mozjpeg",
"oxipng",
"webp",
"avif",
"tiff",
"threads",
"metadata",
]

# Used for binary
build-binary = ["dep:anyhow", "dep:clap", "dep:indoc", "dep:rayon", "dep:pretty_env_logger", "dep:zune-imageprocs", "dep:glob", "zune-image/default", "dep:indicatif", "dep:indicatif-log-bridge", "dep:console"]
build-binary = [
"dep:anyhow",
"dep:clap",
"dep:indoc",
"dep:rayon",
"dep:pretty_env_logger",
"dep:zune-imageprocs",
"dep:glob",
"zune-image/default",
"dep:indicatif",
"dep:indicatif-log-bridge",
"dep:console",
]

# Enables utilization of threads
threads = ["imagequant?/threads", "mozjpeg?/parallel", "oxipng?/parallel"]
Expand All @@ -48,8 +79,8 @@ webp = ["dep:webp"]
# Enables avif codec
avif = ["dep:ravif", "dep:libavif", "dep:rgb"]
# Enables tiff codec
tiff = ["dep:tiff"]
icc = ["dep:lcms2"]
tiff = ["dep:tiff"]
icc = ["dep:lcms2"]
console = ["dep:console"]

[dependencies]
Expand All @@ -59,11 +90,18 @@ zune-image = { version = "0.5.0-rc0", default-features = false }
fast_image_resize = { version = "3.0.4", optional = true }
imagequant = { version = "4.3.1", default-features = false, optional = true }
rgb = { version = "0.8.44", optional = true }
mozjpeg = { version = "0.10.7", default-features = false, features = ["with_simd"], optional = true }
oxipng = { version = "9.1", default-features = false, features = ["zopfli", "filetime"], optional = true }
mozjpeg = { version = "0.10.7", default-features = false, features = [
"with_simd",
], optional = true }
oxipng = { version = "9.1", default-features = false, features = [
"zopfli",
"filetime",
], optional = true }
webp = { version = "0.3.0", default-features = false, optional = true }
ravif = { version = "0.11.8", optional = true }
libavif = { version = "0.14.0", default-features = false, features = ["codec-aom"], optional = true }
libavif = { version = "0.14.0", default-features = false, features = [
"codec-aom",
], optional = true }
lcms2 = { version = "6.1.0", optional = true }
tiff = { version = "0.9.1", default-features = false, optional = true }

Expand All @@ -73,15 +111,17 @@ clap = { version = "4.5.9", features = ["cargo", "string"], optional = true }
indoc = { version = "2.0.5", optional = true }
pretty_env_logger = { version = "0.5.0", optional = true }
rayon = { version = "1.10.0", optional = true }
zune-imageprocs = { version = "0.5.0-rc0", features = ["exif"], optional = true }
zune-imageprocs = { version = "0.5.0-rc0", features = [
"exif",
], optional = true }
kamadak-exif = { version = "0.5.5", optional = true }
indicatif = { version = "0.17.8", features = ["rayon"], optional = true }
indicatif-log-bridge = { version = "0.2.2", optional = true}
indicatif-log-bridge = { version = "0.2.2", optional = true }
console = { version = "0.15.8", optional = true }

[target.'cfg(windows)'.dependencies]
glob = { version = "0.3.1", optional = true }

[dev-dependencies]
zune-core = { version = "0.5.0-rc1", features = ["std"] }
zune-core = { version = "0.5.0-rc1", features = ["std"] }
zune-image = "0.5.0-rc0"
64 changes: 64 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
extern crate winres;
use std::env;
use winres::VersionInfo;

fn main() {
// only run if target os is windows
if env::var("CARGO_CFG_TARGET_OS").unwrap() != "windows" {
println!(
"cargo:warning={:#?}",
"This build script is only for windows target, skipping..."
);
return;
}

let mut res = winres::WindowsResource::new();

match env::var("CARGO_PKG_VERSION_PRE") {
Ok(success_info) => println!("{}", success_info),
Err(err_info) => println!("{}", err_info),
};

//version X. X. X. X
// ⇑ ⇑ ⇑ ⇑
// MAJOR MINOR PATCH PRE
let mut version: u64 = 0;
version |= {
env::var("CARGO_PKG_VERSION_MAJOR")
.unwrap()
.parse::<u64>()
.unwrap()
<< 48
};
version |= {
env::var("CARGO_PKG_VERSION_MINOR")
.unwrap()
.parse::<u64>()
.unwrap()
<< 32
};
version |= {
env::var("CARGO_PKG_VERSION_PATCH")
.unwrap()
.parse::<u64>()
.unwrap()
<< 16
};

let product_version = version | {
let temp = env::var("CARGO_PKG_VERSION_PRE").unwrap();
if temp == *"" {
0_u64
} else {
temp.parse::<u64>().unwrap_or(0_u64)
}
};

res.set_version_info(VersionInfo::FILEVERSION, version)
.set_version_info(VersionInfo::PRODUCTVERSION, product_version);

if let Err(e) = res.compile() {
eprintln!("{}", e);
std::process::exit(1);
}
}
3 changes: 3 additions & 0 deletions config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[env]
# Because rust doesn't support it in cargo.toml => package.version, so it has to be define here to avoid any accident
CARGO_PKG_VERSION_PRE = { value = "2", force = true, relative = true }

0 comments on commit bcb4a2b

Please sign in to comment.