Skip to content

Commit

Permalink
feat(regenerate): forward PHNT_VERSION and PHNT_MODE from env
Browse files Browse the repository at this point in the history
  • Loading branch information
oberrich committed Sep 6, 2024
1 parent 20ea1d2 commit b4dec87
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "phnt"
version = "0.0.29"
version = "0.0.30"
license = "MIT"
authors = ["oberrich <oberrich.llvm@proton.me>"]
repository = "https://github.com/oberrich/phnt-rs"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 12 additions & 4 deletions src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> = 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"))
Expand Down

0 comments on commit b4dec87

Please sign in to comment.