Skip to content

Commit

Permalink
Make toml dependency optional
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysd committed Aug 22, 2023
1 parent 5e4160c commit fc70bda
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ documentation= "https://docs.rs/winresource/*/winresource/"
[lib]
path = "lib.rs"

[features]
default = ["toml"]

[dependencies]
toml = "0.7"
toml = { version = "0.7", optional = true }
version_check = "0.9"

[dev-dependencies]
Expand Down
3 changes: 3 additions & 0 deletions lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ use std::io::prelude::*;
use std::path::{Path, PathBuf};
use std::process;

#[cfg(feature = "toml")]
extern crate toml;

/// Version info field names
Expand Down Expand Up @@ -175,6 +176,7 @@ impl WindowsResource {

props.insert("FileDescription".to_string(), description);

#[cfg(feature = "toml")]
parse_cargo_toml(&mut props).unwrap();

let mut version = 0_u64;
Expand Down Expand Up @@ -813,6 +815,7 @@ fn get_sdk() -> io::Result<Vec<PathBuf>> {
Ok(kits)
}

#[cfg(feature = "toml")]
fn parse_cargo_toml(props: &mut HashMap<String, String>) -> io::Result<()> {
let cargo = Path::new(&env::var("CARGO_MANIFEST_DIR").unwrap()).join("Cargo.toml");
let mut f = fs::File::open(cargo)?;
Expand Down

0 comments on commit fc70bda

Please sign in to comment.