@@ -34,6 +34,12 @@ pub trait PHPProvider<'a>: Sized {
3434 #[ allow( clippy:: missing_errors_doc) ]
3535 fn get_defines ( & self ) -> Result < Vec < ( & ' static str , & ' static str ) > > ;
3636
37+ /// Retrieve extra clang arguments for bindgen (e.g., system include paths).
38+ #[ allow( clippy:: missing_errors_doc) ]
39+ fn get_extra_clang_args ( & self ) -> Result < Vec < String > > {
40+ Ok ( Vec :: new ( ) )
41+ }
42+
3743 /// Writes the bindings to a file.
3844 #[ allow( clippy:: missing_errors_doc) ]
3945 fn write_bindings ( & self , bindings : String , writer : & mut impl Write ) -> Result < ( ) > {
@@ -211,7 +217,11 @@ fn build_embed(defines: &[(&str, &str)], includes: &[PathBuf]) -> Result<()> {
211217}
212218
213219/// Generates bindings to the Zend API.
214- fn generate_bindings ( defines : & [ ( & str , & str ) ] , includes : & [ PathBuf ] ) -> Result < String > {
220+ fn generate_bindings (
221+ defines : & [ ( & str , & str ) ] ,
222+ includes : & [ PathBuf ] ,
223+ extra_clang_args : & [ String ] ,
224+ ) -> Result < String > {
215225 let mut bindgen = bindgen:: Builder :: default ( ) ;
216226
217227 #[ cfg( feature = "embed" ) ]
@@ -227,6 +237,7 @@ fn generate_bindings(defines: &[(&str, &str)], includes: &[PathBuf]) -> Result<S
227237 . map ( |inc| format ! ( "-I{}" , inc. to_string_lossy( ) ) ) ,
228238 )
229239 . clang_args ( defines. iter ( ) . map ( |( var, val) | format ! ( "-D{var}={val}" ) ) )
240+ . clang_args ( extra_clang_args)
230241 . formatter ( bindgen:: Formatter :: Rustfmt )
231242 . no_copy ( "php_ini_builder" )
232243 . no_copy ( "_zval_struct" )
@@ -268,6 +279,7 @@ enum ApiVersion {
268279 Php82 = 2022_08_29 ,
269280 Php83 = 2023_08_31 ,
270281 Php84 = 2024_09_24 ,
282+ Php85 = 2025_09_25 ,
271283}
272284
273285impl ApiVersion {
@@ -285,7 +297,7 @@ impl ApiVersion {
285297
286298 /// Returns the maximum API version supported by ext-php-rs.
287299 pub const fn max ( ) -> Self {
288- ApiVersion :: Php84
300+ ApiVersion :: Php85
289301 }
290302
291303 pub fn versions ( ) -> Vec < Self > {
@@ -295,6 +307,7 @@ impl ApiVersion {
295307 ApiVersion :: Php82 ,
296308 ApiVersion :: Php83 ,
297309 ApiVersion :: Php84 ,
310+ ApiVersion :: Php85 ,
298311 ]
299312 }
300313
@@ -313,6 +326,7 @@ impl ApiVersion {
313326 ApiVersion :: Php82 => "php82" ,
314327 ApiVersion :: Php83 => "php83" ,
315328 ApiVersion :: Php84 => "php84" ,
329+ ApiVersion :: Php85 => "php85" ,
316330 }
317331 }
318332
@@ -323,6 +337,7 @@ impl ApiVersion {
323337 ApiVersion :: Php82 => "EXT_PHP_RS_PHP_82" ,
324338 ApiVersion :: Php83 => "EXT_PHP_RS_PHP_83" ,
325339 ApiVersion :: Php84 => "EXT_PHP_RS_PHP_84" ,
340+ ApiVersion :: Php85 => "EXT_PHP_RS_PHP_85" ,
326341 }
327342 }
328343}
@@ -344,7 +359,10 @@ impl TryFrom<u32> for ApiVersion {
344359 x if ( ( ApiVersion :: Php83 as u32 ) ..( ApiVersion :: Php84 as u32 ) ) . contains ( & x) => {
345360 Ok ( ApiVersion :: Php83 )
346361 }
347- x if ( ApiVersion :: Php84 as u32 ) == x => Ok ( ApiVersion :: Php84 ) ,
362+ x if ( ( ApiVersion :: Php84 as u32 ) ..( ApiVersion :: Php85 as u32 ) ) . contains ( & x) => {
363+ Ok ( ApiVersion :: Php84 )
364+ }
365+ x if ( ApiVersion :: Php85 as u32 ) == x => Ok ( ApiVersion :: Php85 ) ,
348366 version => Err ( anyhow ! (
349367 "The current version of PHP is not supported. Current PHP API version: {}, requires a version between {} and {}" ,
350368 version,
@@ -371,7 +389,7 @@ fn check_php_version(info: &PHPInfo) -> Result<()> {
371389 // The PHP version cfg flags should also stack - if you compile on PHP 8.2 you
372390 // should get both the `php81` and `php82` flags.
373391 println ! (
374- "cargo::rustc-check-cfg=cfg(php80, php81, php82, php83, php84, php_zts, php_debug, docs)"
392+ "cargo::rustc-check-cfg=cfg(php80, php81, php82, php83, php84, php85, php_zts, php_debug, docs)"
375393 ) ;
376394
377395 if version == ApiVersion :: Php80 {
@@ -416,6 +434,7 @@ fn main() -> Result<()> {
416434 println ! ( "cargo:rustc-cfg=php82" ) ;
417435 println ! ( "cargo:rustc-cfg=php83" ) ;
418436 println ! ( "cargo:rustc-cfg=php84" ) ;
437+ println ! ( "cargo:rustc-cfg=php85" ) ;
419438 std:: fs:: copy ( "docsrs_bindings.rs" , out_path)
420439 . expect ( "failed to copy docs.rs stub bindings to out directory" ) ;
421440 return Ok ( ( ) ) ;
@@ -428,14 +447,15 @@ fn main() -> Result<()> {
428447 let includes = provider. get_includes ( ) ?;
429448 let mut defines = provider. get_defines ( ) ?;
430449 add_php_version_defines ( & mut defines, & info) ?;
450+ let extra_clang_args = provider. get_extra_clang_args ( ) ?;
431451
432452 check_php_version ( & info) ?;
433453 build_wrapper ( & defines, & includes) ?;
434454
435455 #[ cfg( feature = "embed" ) ]
436456 build_embed ( & defines, & includes) ?;
437457
438- let bindings = generate_bindings ( & defines, & includes) ?;
458+ let bindings = generate_bindings ( & defines, & includes, & extra_clang_args ) ?;
439459
440460 let out_file =
441461 File :: create ( & out_path) . context ( "Failed to open output bindings file for writing" ) ?;
0 commit comments