@@ -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,11 @@ 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 ( defines : & [ ( & str , & str ) ] , includes : & [ PathBuf ] , # [ allow ( unused ) ] info : & PHPInfo ) -> Result < String > {
182187 let mut bindgen = bindgen:: Builder :: default ( ) ;
183188
184189 #[ cfg( feature = "embed" ) ]
185- {
190+ if !info . thread_safety ( ) ? || info . zend_version ( ) ? >= PHP_81_API_VER {
186191 bindgen = bindgen. header ( "src/embed/embed.h" ) ;
187192 }
188193
@@ -245,13 +250,6 @@ fn check_php_version(info: &PHPInfo) -> Result<()> {
245250 //
246251 // The PHP version cfg flags should also stack - if you compile on PHP 8.2 you
247252 // 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 ;
255253
256254 println ! (
257255 "cargo::rustc-check-cfg=cfg(php80, php81, php82, php83, php84, php_zts, php_debug, docs)"
@@ -324,9 +322,11 @@ fn main() -> Result<()> {
324322 build_wrapper ( & defines, & includes) ?;
325323
326324 #[ cfg( feature = "embed" ) ]
327- build_embed ( & defines, & includes) ?;
325+ if !info. thread_safety ( ) ? || info. zend_version ( ) ? >= PHP_81_API_VER {
326+ build_embed ( & defines, & includes) ?;
327+ }
328328
329- let bindings = generate_bindings ( & defines, & includes) ?;
329+ let bindings = generate_bindings ( & defines, & includes, & info ) ?;
330330
331331 let out_file =
332332 File :: create ( & out_path) . context ( "Failed to open output bindings file for writing" ) ?;
0 commit comments