@@ -26,6 +26,7 @@ const NGX_CONF_FEATURES: &[&str] = &[
26
26
"have_file_aio" ,
27
27
"have_kqueue" ,
28
28
"have_variadic_macros" ,
29
+ "http" ,
29
30
"http_cache" ,
30
31
"http_dav" ,
31
32
"http_gzip" ,
@@ -40,6 +41,7 @@ const NGX_CONF_FEATURES: &[&str] = &[
40
41
"pcre2" ,
41
42
"quic" ,
42
43
"ssl" ,
44
+ "stream" ,
43
45
"stream_ssl" ,
44
46
"stream_upstream_zone" ,
45
47
"threads" ,
@@ -328,17 +330,26 @@ pub fn print_cargo_metadata<T: AsRef<Path>>(includes: &[T]) -> Result<(), Box<dy
328
330
) ;
329
331
330
332
// A quoted list of all recognized features to be passed to rustc-check-cfg.
333
+ let values = NGX_CONF_FEATURES . join ( "\" ,\" " ) ;
334
+ println ! ( "cargo::metadata=features_check=\" {}\" " , values) ;
331
335
println ! (
332
- "cargo::metadata=features_check= \" {}\" " ,
333
- NGX_CONF_FEATURES . join ( " \" , \" " )
336
+ "cargo::rustc-check-cfg=cfg(ngx_feature, values( \" {}\" )) " ,
337
+ values
334
338
) ;
339
+
335
340
// A list of features enabled in the nginx build we're using
336
341
println ! ( "cargo::metadata=features={}" , ngx_features. join( "," ) ) ;
342
+ for feature in ngx_features {
343
+ println ! ( "cargo::rustc-cfg=ngx_feature=\" {}\" " , feature) ;
344
+ }
337
345
338
346
// A quoted list of all recognized operating systems to be passed to rustc-check-cfg.
339
- println ! ( "cargo::metadata=os_check=\" {}\" " , NGX_CONF_OS . join( "\" ,\" " ) ) ;
347
+ let values = NGX_CONF_OS . join ( "\" ,\" " ) ;
348
+ println ! ( "cargo::metadata=os_check=\" {}\" " , values) ;
349
+ println ! ( "cargo::rustc-check-cfg=cfg(ngx_os, values(\" {}\" ))" , values) ;
340
350
// Current detected operating system
341
351
println ! ( "cargo::metadata=os={ngx_os}" ) ;
352
+ println ! ( "cargo::rustc-cfg=ngx_os=\" {ngx_os}\" " ) ;
342
353
343
354
Ok ( ( ) )
344
355
}
@@ -353,6 +364,22 @@ fn expand_definitions<T: AsRef<Path>>(includes: &[T]) -> Result<Vec<u8>, Box<dyn
353
364
#include <ngx_config.h>
354
365
#include <ngx_core.h>
355
366
367
+ /* C23 or Clang/GCC/MSVC >= 15.3 extension */
368
+ #if defined(__has_include)
369
+
370
+ #if __has_include(<ngx_http.h>)
371
+ RUST_CONF_HTTP=1
372
+ #endif
373
+
374
+ #if __has_include(<ngx_stream.h>)
375
+ RUST_CONF_STREAM=1
376
+ #endif
377
+
378
+ #else
379
+ /* fallback */
380
+ RUST_CONF_HTTP=1
381
+ #endif
382
+
356
383
RUST_CONF_NGINX_BUILD=NGINX_VER_BUILD
357
384
RUST_CONF_NGINX_VERSION=NGINX_VER
358
385
RUST_CONF_NGINX_VERSION_NUMBER=nginx_version
0 commit comments