Skip to content

Commit 1027fa5

Browse files
committed
feat(embed): disable embed for php 80 + phpzts
1 parent 7bda30f commit 1027fa5

File tree

7 files changed

+18
-18
lines changed

7 files changed

+18
-18
lines changed

build.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ use impl_::Provider;
2222
const MIN_PHP_API_VER: u32 = 20200930;
2323
const 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.
2631
pub 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")?;

src/builders/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
mod class;
55
mod function;
66
mod module;
7-
#[cfg(feature = "embed")]
7+
#[cfg(all(feature = "embed", any(php81, not(php_zts))))]
88
mod sapi;
99

1010
pub use class::ClassBuilder;
1111
pub use function::FunctionBuilder;
1212
pub use module::{ModuleBuilder, ModuleStartup};
13-
#[cfg(feature = "embed")]
13+
#[cfg(all(feature = "embed", any(php81, not(php_zts))))]
1414
pub use sapi::SapiBuilder;

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub mod class;
2525
pub mod closure;
2626
pub mod constant;
2727
pub mod describe;
28-
#[cfg(feature = "embed")]
28+
#[cfg(all(feature = "embed", any(php81, not(php_zts))))]
2929
pub mod embed;
3030
#[doc(hidden)]
3131
pub mod internal;

src/types/iterator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ impl<'a> FromZvalMut<'a> for &'a mut ZendIterator {
183183
}
184184

185185
#[cfg(test)]
186-
#[cfg(feature = "embed")]
186+
#[cfg(all(feature = "embed", any(php81, not(php_zts))))]
187187
mod tests {
188188
use crate::embed::Embed;
189189

src/types/string.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ impl<'a> FromZval<'a> for &'a str {
456456
}
457457

458458
#[cfg(test)]
459-
#[cfg(feature = "embed")]
459+
#[cfg(all(feature = "embed", any(php81, not(php_zts))))]
460460
mod tests {
461461
use crate::embed::Embed;
462462

src/zend/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub use ini_entry_def::IniEntryDef;
3434
pub use linked_list::ZendLinkedList;
3535
pub use module::ModuleEntry;
3636
pub use streams::*;
37-
#[cfg(feature = "embed")]
37+
#[cfg(all(feature = "embed", any(php81, not(php_zts))))]
3838
pub(crate) use try_catch::panic_wrapper;
3939
pub use try_catch::{bailout, try_catch, try_catch_first};
4040

src/zend/try_catch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ pub unsafe fn bailout() -> ! {
102102
ext_php_rs_zend_bailout();
103103
}
104104

105-
#[cfg(feature = "embed")]
105+
#[cfg(all(feature = "embed", any(php81, not(php_zts))))]
106106
#[cfg(test)]
107107
mod tests {
108108
use crate::embed::Embed;

0 commit comments

Comments
 (0)