Skip to content

Commit 6a598de

Browse files
fix building docs on docs.rs (#165)
* fix building docs on docs.rs accidentally removed the docs.rs stub bindings feature in 664981f. docs.rs only has php 7.4 and therefore cannot build ext-php-rs, so stub bindings are generated prior. * update docs.rs stub bindings
1 parent 6766786 commit 6a598de

File tree

2 files changed

+14
-31
lines changed

2 files changed

+14
-31
lines changed

build.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,8 @@ fn check_php_version(info: &PHPInfo) -> Result<()> {
206206
}
207207

208208
fn main() -> Result<()> {
209+
let out_dir = env::var_os("OUT_DIR").context("Failed to get OUT_DIR")?;
210+
let out_path = PathBuf::from(out_dir).join("bindings.rs");
209211
let manifest: PathBuf = std::env::var("CARGO_MANIFEST_DIR").unwrap().into();
210212
for path in [
211213
manifest.join("src").join("wrapper.h"),
@@ -217,6 +219,16 @@ fn main() -> Result<()> {
217219
println!("cargo:rerun-if-changed={}", path.to_string_lossy());
218220
}
219221

222+
// docs.rs runners only have PHP 7.4 - use pre-generated bindings
223+
if env::var("DOCS_RS").is_ok() {
224+
println!("cargo:warning=docs.rs detected - using stub bindings");
225+
println!("cargo:rustc-cfg=php_debug");
226+
println!("cargo:rustc-cfg=php81");
227+
std::fs::copy("docsrs_bindings.rs", out_path)
228+
.expect("failed to copy docs.rs stub bindings to out directory");
229+
return Ok(());
230+
}
231+
220232
let php = find_php()?;
221233
let info = PHPInfo::get(&php)?;
222234
let provider = Provider::new(&info)?;
@@ -228,8 +240,6 @@ fn main() -> Result<()> {
228240
build_wrapper(&defines, &includes)?;
229241
let bindings = generate_bindings(&defines, &includes)?;
230242

231-
let out_dir = env::var_os("OUT_DIR").context("Failed to get OUT_DIR")?;
232-
let out_path = PathBuf::from(out_dir).join("bindings.rs");
233243
let out_file =
234244
File::create(&out_path).context("Failed to open output bindings file for writing")?;
235245
let mut out_writer = BufWriter::new(out_file);

docsrs_bindings.rs

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
/* automatically generated by rust-bindgen 0.59.1 */
1+
/* automatically generated by rust-bindgen 0.60.1 */
22

33
pub const ZEND_DEBUG: u32 = 1;
4-
pub const ZEND_MM_ALIGNMENT: u32 = 8;
54
pub const _ZEND_TYPE_NAME_BIT: u32 = 16777216;
65
pub const _ZEND_TYPE_NULLABLE_BIT: u32 = 2;
76
pub const HT_MIN_SIZE: u32 = 8;
@@ -32,7 +31,6 @@ pub const IS_OBJECT_EX: u32 = 776;
3231
pub const IS_RESOURCE_EX: u32 = 265;
3332
pub const IS_REFERENCE_EX: u32 = 266;
3433
pub const IS_CONSTANT_AST_EX: u32 = 267;
35-
pub const ZEND_MM_ALIGNMENT_MASK: i32 = -8;
3634
pub const ZEND_PROPERTY_ISSET: u32 = 0;
3735
pub const ZEND_PROPERTY_EXISTS: u32 = 2;
3836
pub const ZEND_ACC_PUBLIC: u32 = 1;
@@ -1185,7 +1183,7 @@ pub struct _zend_vm_stack {
11851183
pub prev: zend_vm_stack,
11861184
}
11871185
#[repr(C)]
1188-
#[derive(Debug, Copy, Clone)]
1186+
#[derive(Copy, Clone)]
11891187
pub struct _zend_function_entry {
11901188
pub fname: *const ::std::os::raw::c_char,
11911189
pub handler: zif_handler,
@@ -1407,28 +1405,3 @@ extern "C" {
14071405
extern "C" {
14081406
pub fn zend_do_implement_interface(ce: *mut zend_class_entry, iface: *mut zend_class_entry);
14091407
}
1410-
extern "C" {
1411-
pub fn ext_php_rs_zend_string_init(
1412-
str_: *const ::std::os::raw::c_char,
1413-
len: size_t,
1414-
persistent: bool,
1415-
) -> *mut zend_string;
1416-
}
1417-
extern "C" {
1418-
pub fn ext_php_rs_zend_string_release(zs: *mut zend_string);
1419-
}
1420-
extern "C" {
1421-
pub fn ext_php_rs_php_build_id() -> *const ::std::os::raw::c_char;
1422-
}
1423-
extern "C" {
1424-
pub fn ext_php_rs_zend_object_alloc(
1425-
obj_size: size_t,
1426-
ce: *mut zend_class_entry,
1427-
) -> *mut ::std::os::raw::c_void;
1428-
}
1429-
extern "C" {
1430-
pub fn ext_php_rs_zend_object_release(obj: *mut zend_object);
1431-
}
1432-
extern "C" {
1433-
pub fn ext_php_rs_executor_globals() -> *mut zend_executor_globals;
1434-
}

0 commit comments

Comments
 (0)