From b4dec872f29ae87c133f4ab6de42befee7c08728 Mon Sep 17 00:00:00 2001 From: oberrich Date: Fri, 6 Sep 2024 07:28:08 +0200 Subject: [PATCH] feat(regenerate): forward `PHNT_VERSION` and `PHNT_MODE` from env --- Cargo.lock | 2 +- Cargo.toml | 2 +- README.md | 2 +- src/build.rs | 16 ++++++++++++---- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d6fea4a..a4ead6b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -257,7 +257,7 @@ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "phnt" -version = "0.0.29" +version = "0.0.30" dependencies = [ "bindgen", "chrono", diff --git a/Cargo.toml b/Cargo.toml index a74fcbe..fc07e68 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "phnt" -version = "0.0.29" +version = "0.0.30" license = "MIT" authors = ["oberrich "] repository = "https://github.com/oberrich/phnt-rs" diff --git a/README.md b/README.md index 99376ba..6a34446 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Crate Overview - [Functions][docs.rs/ext/functions] - [Macros][docs.rs/ext/macros] -**crate version:** 0.0.29 - unstable api +**crate version:** 0.0.30 - unstable api [github.com]: https://github.com/oberrich/phnt-rs [github.com/ci]: https://github.com/oberrich/phnt-rs/actions/workflows/rust.yml diff --git a/src/build.rs b/src/build.rs index ddbf3a1..641b36d 100644 --- a/src/build.rs +++ b/src/build.rs @@ -98,16 +98,24 @@ mod regen { format!("// Generated at {}", chrono::offset::Local::now()), format!("#[cfg(not(target_arch = \"{}\"))]", std::env::consts::ARCH), format!("compile_error!(\"These bindings can only be used on `{}` architectures. To generate bindings for your target architecture, consider using the `regenerate` feature.\");", std::env::consts::ARCH), + "".into(), "use cty;".into(), ]; raw_lines.append(&mut self.raw_lines.clone()); - let clang_args = vec![ - "-Iwindows.h", - "-Iwinnt.h", - concat!("-I", env!("CARGO_MANIFEST_DIR"), "\\deps\\phnt-nightly/"), + let mut clang_args: Vec = vec![ + "-Iwindows.h".to_owned(), + "-Iwinnt.h".to_owned(), + concat!("-I", env!("CARGO_MANIFEST_DIR"), "\\deps\\phnt-nightly/").to_owned(), ]; + for name in ["PHNT_VERSION", "PHNT_MODE"] { + println!("cargo:rerun-if-changed={}", name); + if let Ok(str) = env::var(name) { + clang_args.push(format!("-D{}={}", name, str)); + } + } + bindgen::builder() .disable_header_comment() .header(concat!(env!("CARGO_MANIFEST_DIR"), "/src/ffi/wrapper.h"))