mirror of
https://github.com/icewind1991/ivory.git
synced 2026-06-03 10:44:09 +02:00
Merge pull request #1 from aszlig/php-from-sys
sys: Use includes from php-config --include-dir
This commit is contained in:
commit
abdf06d30c
2 changed files with 85 additions and 70 deletions
|
|
@ -53,25 +53,7 @@ fn exists(path: &str) -> bool {
|
|||
Path::new(target(path).as_str()).exists()
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let cpus = format!("{}", num_cpus::get());
|
||||
#[cfg(all(target_os = "linux"))]
|
||||
let default_link_static = false;
|
||||
#[cfg(all(target_os = "macos"))]
|
||||
let default_link_static = true;
|
||||
let php_version = option_env!("PHP_VERSION").unwrap_or(PHP_VERSION);
|
||||
|
||||
println!("cargo:rerun-if-env-changed=PHP_VERSION");
|
||||
println!("cargo:rerun-if-env-changed=PHP_LINK_STATIC");
|
||||
|
||||
let link_dynamic = env::var_os("PHP_LINK_DYNAMIC")
|
||||
.map(|_| true)
|
||||
.unwrap_or(false);
|
||||
let link_static = env::var_os("PHP_LINK_STATIC")
|
||||
.map(|_| true)
|
||||
.unwrap_or(default_link_static && !link_dynamic);
|
||||
|
||||
if !exists("php-src/LICENSE") {
|
||||
fn compile_php(php_version: &str, link_static: bool) -> () {
|
||||
println_stderr!("Setting up PHP {}", php_version);
|
||||
run_command_or_fail("/".to_string(), "mkdir", &["-p", &target("")]);
|
||||
run_command_or_fail(
|
||||
|
|
@ -136,10 +118,39 @@ fn main() {
|
|||
// "--with-pic",
|
||||
];
|
||||
run_command_or_fail(target("php-src"), "./configure", config);
|
||||
let cpus = format!("{}", num_cpus::get());
|
||||
run_command_or_fail(target("php-src"), "make", &["-j", cpus.as_str()]);
|
||||
}
|
||||
}
|
||||
|
||||
let include_dir = target("php-src");
|
||||
fn main() {
|
||||
#[cfg(all(target_os = "linux"))]
|
||||
let default_link_static = false;
|
||||
#[cfg(all(target_os = "macos"))]
|
||||
let default_link_static = true;
|
||||
let php_version = option_env!("PHP_VERSION").unwrap_or(PHP_VERSION);
|
||||
|
||||
println!("cargo:rerun-if-env-changed=PHP_VERSION");
|
||||
println!("cargo:rerun-if-env-changed=PHP_LINK_STATIC");
|
||||
|
||||
let link_dynamic = env::var_os("PHP_LINK_DYNAMIC")
|
||||
.map(|_| true)
|
||||
.unwrap_or(false);
|
||||
let link_static = env::var_os("PHP_LINK_STATIC")
|
||||
.map(|_| true)
|
||||
.unwrap_or(default_link_static && !link_dynamic);
|
||||
|
||||
let maybe_include_dir = Command::new("php-config")
|
||||
.args(&["--include-dir"])
|
||||
.output()
|
||||
.map(|o| String::from_utf8(o.stdout).unwrap().trim_end().to_string())
|
||||
.ok();
|
||||
|
||||
let include_dir = maybe_include_dir.unwrap_or_else(|| {
|
||||
if !exists("php-src/LICENSE") {
|
||||
compile_php(php_version, link_static);
|
||||
}
|
||||
target("php-src")
|
||||
});
|
||||
|
||||
let includes = ["/", "/TSRM", "/Zend", "/main"]
|
||||
.iter()
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
#ifndef PHP_RS_WRAPPER_H
|
||||
#define PHP_RS_WRAPPER_H
|
||||
/* CLang doesn't support asm goto yet, so let's force-disable it. */
|
||||
#include <main/php_config.h>
|
||||
#undef HAVE_ASM_GOTO
|
||||
|
||||
#include <Zend/zend.h>
|
||||
#include <Zend/zend_compile.h>
|
||||
#include <main/php.h>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue