Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions php-rust/crates/php-types/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,21 @@
// carries its own libjpeg-turbo/libpng/libwebp/libavif codec choices, so a
// Rust-crate reimplementation (image/imageproc) would diverge on every encode.
fn main() {
println!("cargo:rustc-link-search=native=/opt/homebrew/opt/gd/lib");
// macOS: gd lives in a Homebrew keg, not the default library path.
// Linux: libgd is in the system library path; no explicit search needed.
if cfg!(target_os = "macos") {
println!("cargo:rustc-link-search=native=/opt/homebrew/opt/gd/lib");
}
println!("cargo:rustc-link-lib=dylib=gd");
// ext/xsl (src/xsltio.rs): the **system** libxslt/libexslt/libxml2 — the
// same /usr/lib dylibs the PHP oracle links (they live in the dyld shared
// cache; the linker resolves them through the SDK .tbd stubs).
// ext/tidy (src/tidyio.rs): the **system** libtidy — the same Homebrew
// keg the PHP oracle was configured against (--with-tidy=tidy-html5).
println!("cargo:rustc-link-search=native=/opt/homebrew/opt/tidy-html5/lib");
// macOS: tidy lives in a Homebrew keg. Linux: system library path.
if cfg!(target_os = "macos") {
println!("cargo:rustc-link-search=native=/opt/homebrew/opt/tidy-html5/lib");
}
println!("cargo:rustc-link-lib=dylib=tidy");
println!("cargo:rustc-link-lib=dylib=xslt");
println!("cargo:rustc-link-lib=dylib=exslt");
Expand Down
4 changes: 4 additions & 0 deletions php-rust/crates/php-types/src/xsltio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,11 @@ const XPATH_NUMBER: c_int = 3;
const XPATH_STRING: c_int = 4;

extern "C" {
// macOS system libxml2 (~2.9.x) exports these as `valuePop`/`valuePush`;
// libxml2 2.x (Linux) renamed them to `xmlXPathValuePop`/`xmlXPathValuePush`.
#[cfg_attr(not(target_os = "macos"), link_name = "xmlXPathValuePop")]
fn valuePop(ctxt: *mut c_void) -> *mut c_void;
#[cfg_attr(not(target_os = "macos"), link_name = "xmlXPathValuePush")]
fn valuePush(ctxt: *mut c_void, value: *mut c_void) -> c_int;
fn xmlXPathFreeObject(obj: *mut c_void);
fn xmlXPathCastToString(obj: *mut c_void) -> *mut c_char;
Expand Down