Skip to content

Commit

Permalink
fix building docs on docs.rs (davidcole1340#165)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
davidcole1340 authored Oct 15, 2022
1 parent 6766786 commit 6a598de
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 31 deletions.
14 changes: 12 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ fn check_php_version(info: &PHPInfo) -> Result<()> {
}

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

// docs.rs runners only have PHP 7.4 - use pre-generated bindings
if env::var("DOCS_RS").is_ok() {
println!("cargo:warning=docs.rs detected - using stub bindings");
println!("cargo:rustc-cfg=php_debug");
println!("cargo:rustc-cfg=php81");
std::fs::copy("docsrs_bindings.rs", out_path)
.expect("failed to copy docs.rs stub bindings to out directory");
return Ok(());
}

let php = find_php()?;
let info = PHPInfo::get(&php)?;
let provider = Provider::new(&info)?;
Expand All @@ -228,8 +240,6 @@ fn main() -> Result<()> {
build_wrapper(&defines, &includes)?;
let bindings = generate_bindings(&defines, &includes)?;

let out_dir = env::var_os("OUT_DIR").context("Failed to get OUT_DIR")?;
let out_path = PathBuf::from(out_dir).join("bindings.rs");
let out_file =
File::create(&out_path).context("Failed to open output bindings file for writing")?;
let mut out_writer = BufWriter::new(out_file);
Expand Down
31 changes: 2 additions & 29 deletions docsrs_bindings.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* automatically generated by rust-bindgen 0.59.1 */
/* automatically generated by rust-bindgen 0.60.1 */

pub const ZEND_DEBUG: u32 = 1;
pub const ZEND_MM_ALIGNMENT: u32 = 8;
pub const _ZEND_TYPE_NAME_BIT: u32 = 16777216;
pub const _ZEND_TYPE_NULLABLE_BIT: u32 = 2;
pub const HT_MIN_SIZE: u32 = 8;
Expand Down Expand Up @@ -32,7 +31,6 @@ pub const IS_OBJECT_EX: u32 = 776;
pub const IS_RESOURCE_EX: u32 = 265;
pub const IS_REFERENCE_EX: u32 = 266;
pub const IS_CONSTANT_AST_EX: u32 = 267;
pub const ZEND_MM_ALIGNMENT_MASK: i32 = -8;
pub const ZEND_PROPERTY_ISSET: u32 = 0;
pub const ZEND_PROPERTY_EXISTS: u32 = 2;
pub const ZEND_ACC_PUBLIC: u32 = 1;
Expand Down Expand Up @@ -1185,7 +1183,7 @@ pub struct _zend_vm_stack {
pub prev: zend_vm_stack,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
#[derive(Copy, Clone)]
pub struct _zend_function_entry {
pub fname: *const ::std::os::raw::c_char,
pub handler: zif_handler,
Expand Down Expand Up @@ -1407,28 +1405,3 @@ extern "C" {
extern "C" {
pub fn zend_do_implement_interface(ce: *mut zend_class_entry, iface: *mut zend_class_entry);
}
extern "C" {
pub fn ext_php_rs_zend_string_init(
str_: *const ::std::os::raw::c_char,
len: size_t,
persistent: bool,
) -> *mut zend_string;
}
extern "C" {
pub fn ext_php_rs_zend_string_release(zs: *mut zend_string);
}
extern "C" {
pub fn ext_php_rs_php_build_id() -> *const ::std::os::raw::c_char;
}
extern "C" {
pub fn ext_php_rs_zend_object_alloc(
obj_size: size_t,
ce: *mut zend_class_entry,
) -> *mut ::std::os::raw::c_void;
}
extern "C" {
pub fn ext_php_rs_zend_object_release(obj: *mut zend_object);
}
extern "C" {
pub fn ext_php_rs_executor_globals() -> *mut zend_executor_globals;
}

0 comments on commit 6a598de

Please sign in to comment.