Skip to content

Commit 53b14f1

Browse files
committed
feat(sys): import types from pcre2-sys
The change introduces an optional feature nginx-sys/pcre2-sys that replaces some generated types with corresponding imports from "pcre2-sys".
1 parent 37627c4 commit 53b14f1

File tree

3 files changed

+81
-4
lines changed

3 files changed

+81
-4
lines changed

Cargo.lock

Lines changed: 63 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nginx-sys/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ targets = []
2222
[dependencies]
2323
libc = { optional = true, workspace = true }
2424
openssl-sys = { version = "0.9.109", optional = true }
25+
pcre2-sys = { version = "0.2.9", optional = true }
2526

2627
[target.'cfg(not(windows))'.dependencies]
2728
errno = { version = "0.3", default-features = false }
@@ -40,4 +41,6 @@ libc = ["dep:libc"]
4041
# Reexport types from "openssl-sys" instead of generating our own bindings.
4142
# Note that openssl-sys depends on "std".
4243
openssl-sys = ["dep:openssl-sys"]
44+
# Reexport types from "pcre2-sys" instead of generating our own bindings.
45+
pcre2-sys = ["dep:pcre2-sys"]
4346
vendored = ["dep:nginx-src"]

nginx-sys/build/main.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,11 @@ fn generate_binding(nginx: &NginxSource) {
250250
.rust_target(rust_target)
251251
.use_core();
252252

253-
if cfg!(any(feature = "libc", feature = "openssl-sys")) {
253+
if cfg!(any(
254+
feature = "libc",
255+
feature = "openssl-sys",
256+
feature = "pcre2-sys"
257+
)) {
254258
use bindgen_callbacks::TypeFlags as TF;
255259

256260
let mut callbacks = bindgen_callbacks::NgxBindgenCallbacks::new();
@@ -302,6 +306,16 @@ fn generate_binding(nginx: &NginxSource) {
302306
)
303307
}
304308

309+
if cfg!(feature = "pcre2-sys") {
310+
callbacks.add_external_types(
311+
"pcre2_sys",
312+
[
313+
("pcre2_code_8", TF::COPY | TF::DEBUG),
314+
("pcre2_real_code_8", TF::COPY | TF::DEBUG),
315+
],
316+
);
317+
}
318+
305319
bindings = callbacks.add_to_builder(bindings);
306320
}
307321

0 commit comments

Comments
 (0)