@@ -22,6 +22,11 @@ use impl_::Provider;
2222const MIN_PHP_API_VER : u32 = 20200930 ;
2323const MAX_PHP_API_VER : u32 = 20240924 ;
2424
25+ const PHP_81_API_VER : u32 = 20210902 ;
26+ const PHP_82_API_VER : u32 = 20220829 ;
27+ const PHP_83_API_VER : u32 = 20230831 ;
28+ const PHP_84_API_VER : u32 = 20240924 ;
29+
2530/// Provides information about the PHP installation.
2631pub trait PHPProvider < ' a > : Sized {
2732 /// Create a new PHP provider.
@@ -178,11 +183,15 @@ fn build_embed(defines: &[(&str, &str)], includes: &[PathBuf]) -> Result<()> {
178183}
179184
180185/// Generates bindings to the Zend API.
181- fn generate_bindings ( defines : & [ ( & str , & str ) ] , includes : & [ PathBuf ] ) -> Result < String > {
186+ fn generate_bindings (
187+ defines : & [ ( & str , & str ) ] ,
188+ includes : & [ PathBuf ] ,
189+ #[ allow( unused) ] info : & PHPInfo ,
190+ ) -> Result < String > {
182191 let mut bindgen = bindgen:: Builder :: default ( ) ;
183192
184193 #[ cfg( feature = "embed" ) ]
185- {
194+ if !info . thread_safety ( ) ? || info . zend_version ( ) ? >= PHP_81_API_VER {
186195 bindgen = bindgen. header ( "src/embed/embed.h" ) ;
187196 }
188197
@@ -245,13 +254,6 @@ fn check_php_version(info: &PHPInfo) -> Result<()> {
245254 //
246255 // The PHP version cfg flags should also stack - if you compile on PHP 8.2 you
247256 // should get both the `php81` and `php82` flags.
248- const PHP_81_API_VER : u32 = 20210902 ;
249-
250- const PHP_82_API_VER : u32 = 20220829 ;
251-
252- const PHP_83_API_VER : u32 = 20230831 ;
253-
254- const PHP_84_API_VER : u32 = 20240924 ;
255257
256258 println ! (
257259 "cargo::rustc-check-cfg=cfg(php80, php81, php82, php83, php84, php_zts, php_debug, docs)"
@@ -324,9 +326,11 @@ fn main() -> Result<()> {
324326 build_wrapper ( & defines, & includes) ?;
325327
326328 #[ cfg( feature = "embed" ) ]
327- build_embed ( & defines, & includes) ?;
329+ if !info. thread_safety ( ) ? || info. zend_version ( ) ? >= PHP_81_API_VER {
330+ build_embed ( & defines, & includes) ?;
331+ }
328332
329- let bindings = generate_bindings ( & defines, & includes) ?;
333+ let bindings = generate_bindings ( & defines, & includes, & info ) ?;
330334
331335 let out_file =
332336 File :: create ( & out_path) . context ( "Failed to open output bindings file for writing" ) ?;
0 commit comments