Skip to content

Commit

Permalink
feat(regenerate): manually insert mode/version consts from env
Browse files Browse the repository at this point in the history
  • Loading branch information
oberrich committed Sep 14, 2024
1 parent b4dec87 commit 63791c1
Show file tree
Hide file tree
Showing 6 changed files with 515 additions and 259 deletions.
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.30"
version = "0.0.31"
license = "MIT"
authors = ["oberrich <[email protected]>"]
repository = "https://github.com/oberrich/phnt-rs"
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ Crate Overview
- [Functions][docs.rs/ext/functions]
- [Macros][docs.rs/ext/macros]

**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
[github.com/ci/img]: https://github.com/oberrich/phnt-rs/actions/workflows/rust.yml/badge.svg
Expand Down
2 changes: 1 addition & 1 deletion deps/phnt-nightly
Submodule phnt-nightly updated 12 files
+2 −2 ntexapi.h
+143 −0 ntldr.h
+25 −0 ntpebteb.h
+59 −2 ntpoapi.h
+412 −58 ntpsapi.h
+553 −30 ntregapi.h
+125 −8 ntrtl.h
+11 −13 ntseapi.h
+1 −1 ntuser.h
+5 −1 phnt.h
+12 −0 phnt_ntdef.h
+11 −0 phnt_windows.h
16 changes: 12 additions & 4 deletions src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,10 @@ mod regen {

pub fn generate_bindings(&self) -> Result<bindgen::Bindings, bindgen::BindgenError> {
let allowlist_regexpr = Regex::new(
format!(
&format!(
r"({}\\deps\\phnt-nightly\\.*\.h)|winnt\.h|ntstatus\.h",
regex::escape(env!("CARGO_MANIFEST_DIR"))
)
.as_str(),
),
)
.unwrap();

Expand All @@ -102,6 +101,7 @@ mod regen {
"use cty;".into(),
];
raw_lines.append(&mut self.raw_lines.clone());
raw_lines.push(String::default());

let mut clang_args: Vec<String> = vec![
"-Iwindows.h".to_owned(),
Expand All @@ -110,9 +110,17 @@ mod regen {
];

for name in ["PHNT_VERSION", "PHNT_MODE"] {
println!("cargo:rerun-if-changed={}", name);
println!("cargo:rerun-if-env-changed={}", name);
if let Ok(str) = env::var(name) {
clang_args.push(format!("-D{}={}", name, str));

let value = if let Ok(_) = str.parse::<u32>() {
str
} else {
format!("self::{}", str)
};

raw_lines.push(format!("pub const {}: u32 = {};", name, value));
}
}

Expand Down
Loading

0 comments on commit 63791c1

Please sign in to comment.