You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// Checks the PHP Zend API version for compatibility with ext-php-rs, setting
182
+
/// any configuration flags required.
183
+
fncheck_php_version(info:&PHPInfo) -> Result<()>{
184
+
let version = info.zend_version()?;
185
+
186
+
if !(MIN_PHP_API_VER..=MAX_PHP_API_VER).contains(&version){
187
+
bail!("The current version of PHP is not supported. Current PHP API version: {}, requires a version between {} and {}", version,MIN_PHP_API_VER,MAX_PHP_API_VER);
188
+
}
189
+
190
+
// Infra cfg flags - use these for things that change in the Zend API that don't
191
+
// rely on a feature and the crate user won't care about (e.g. struct field
192
+
// changes). Use a feature flag for an actual feature (e.g. enums being
193
+
// introduced in PHP 8.1).
194
+
//
195
+
// PHP 8.0 is the baseline - no feature flags will be introduced here.
196
+
//
197
+
// The PHP version cfg flags should also stack - if you compile on PHP 8.2 you
198
+
// should get both the `php81` and `php82` flags.
199
+
constPHP_81_API_VER:u32 = 20210902;
200
+
201
+
if version >= PHP_81_API_VER{
202
+
println!("cargo:rustc-cfg=php81");
203
+
}
204
+
205
+
Ok(())
206
+
}
207
+
141
208
fnmain() -> Result<()>{
142
209
let out_dir = env::var_os("OUT_DIR").context("Failed to get OUT_DIR")?;
143
210
let out_path = PathBuf::from(out_dir).join("bindings.rs");
@@ -162,12 +229,14 @@ fn main() -> Result<()> {
162
229
returnOk(());
163
230
}
164
231
165
-
let php_build = find_php()?;
166
-
let provider = Provider::new(&php_build)?;
232
+
let php = find_php()?;
233
+
let info = PHPInfo::get(&php)?;
234
+
let provider = Provider::new(&info)?;
167
235
168
236
let includes = provider.get_includes()?;
169
237
let defines = provider.get_defines()?;
170
238
239
+
check_php_version(&info)?;
171
240
build_wrapper(&defines,&includes)?;
172
241
let bindings = generate_bindings(&defines,&includes)?;
let devel = DevelPack::new(version, is_zts, arch)?;
47
40
ifletOk(linker) = get_rustc_linker(){
48
41
iflooks_like_msvc_linker(&linker){
49
42
println!("cargo:warning=It looks like you are using a MSVC linker. You may encounter issues when attempting to load your compiled extension into PHP if your MSVC linker version is not compatible with the linker used to compile your PHP. It is recommended to use `rust-lld` as your linker.");
50
43
}
51
44
}
52
45
53
-
Ok(Self{build, devel })
46
+
Ok(Self{info, devel })
54
47
}
55
48
56
49
fnget_includes(&self) -> Result<Vec<PathBuf>>{
@@ -63,9 +56,9 @@ impl<'a> PHPProvider<'a> for Provider<'a> {
0 commit comments