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
* Allowlist types generated by bindgen
Tidied up build script as well, layout tests are no longer generated
unless `EXT_PHP_RS_TEST` env variable is set. Much quicker build times
and smaller output size.
* Fix build
* Override Rust toolchain when running CI
use bindgen::callbacks::{MacroParsingBehavior,ParseCallbacks};
9
-
use regex::{Captures,Regex};
10
+
use regex::Regex;
10
11
11
12
externcrate bindgen;
12
13
@@ -53,28 +54,23 @@ fn main() {
53
54
.expect("Unable to run `php -i`. Please ensure it is visible in your PATH.");
54
55
55
56
if !php_i_cmd.status.success(){
56
-
let stderr = String::from_utf8(includes_cmd.stderr)
57
-
.unwrap_or_else(|_| String::from("Unable to read stderr"));
57
+
let stderr = str::from_utf8(&includes_cmd.stderr).unwrap_or("Unable to read stderr");
58
58
panic!("Error running `php -i`: {}", stderr);
59
59
}
60
60
61
-
let php_i = String::from_utf8(php_i_cmd.stdout).expect("unable to parse `php -i` stdout");
62
-
let php_api_regex = Regex::new(r"PHP API => ([0-9]+)").unwrap();
63
-
let api_ver:Vec<Captures> = php_api_regex.captures_iter(php_i.as_ref()).collect();
64
-
65
-
match api_ver.first(){
66
-
Some(api_ver) => match api_ver.get(1){
67
-
Some(api_ver) => {
68
-
let api_ver:u32 = api_ver.as_str().parse().unwrap();
61
+
let api_ver = Regex::new(r"PHP API => ([0-9]+)")
62
+
.unwrap()
63
+
.captures_iter(
64
+
str::from_utf8(&php_i_cmd.stdout).expect("Unable to parse `php -i` stdout as UTF-8"),
65
+
)
66
+
.next()
67
+
.and_then(|ver| ver.get(1))
68
+
.and_then(|ver| ver.as_str().parse::<u32>().ok())
69
+
.expect("Unable to retrieve PHP API version from `php -i`.");
69
70
70
-
if api_ver < MIN_PHP_API_VER || api_ver > MAX_PHP_API_VER{
71
-
panic!("The current version of PHP is not supported. Current PHP API version: {}, requires a version between {} and {}", api_ver,MIN_PHP_API_VER,MAX_PHP_API_VER);
72
-
}
73
-
},
74
-
None => panic!("Unable to retrieve PHP API version from `php -i`. Please check the installation and ensure it is callable.")
75
-
},
76
-
None => panic!("Unable to retrieve PHP API version from `php -i`. Please check the installation and ensure it is callable.")
77
-
};
71
+
if api_ver < MIN_PHP_API_VER || api_ver > MAX_PHP_API_VER{
72
+
panic!("The current version of PHP is not supported. Current PHP API version: {}, requires a version between {} and {}", api_ver,MIN_PHP_API_VER,MAX_PHP_API_VER);
73
+
}
78
74
79
75
let includes =
80
76
String::from_utf8(includes_cmd.stdout).expect("unable to parse `php-config` stdout");
@@ -109,13 +105,23 @@ fn main() {
109
105
);
110
106
111
107
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
0 commit comments