Skip to content

Commit 1f5e63b

Browse files
committed
Merge branch 'master' into function-helper
2 parents 38cbba0 + 27d4aa8 commit 1f5e63b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+2439
-89
lines changed

.github/actions/embed/Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM php:8.2-bullseye
2+
3+
WORKDIR /tmp
4+
5+
RUN apt update -y && apt upgrade -y
6+
RUN apt install lsb-release wget gnupg software-properties-common -y
7+
RUN bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"
8+
9+
ENV RUSTUP_HOME=/rust
10+
ENV CARGO_HOME=/cargo
11+
ENV PATH=/cargo/bin:/rust/bin:$PATH
12+
13+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path
14+
15+
ENTRYPOINT [ "/cargo/bin/cargo", "test", "--lib", "--release", "--all-features" ]

.github/actions/embed/action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
name: 'PHP Embed and Rust'
2+
description: 'Builds the crate after installing the latest PHP with php embed and stable Rust.'
3+
runs:
4+
using: 'docker'
5+
image: 'Dockerfile'

.github/workflows/build.yml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ jobs:
1515
strategy:
1616
matrix:
1717
os: [ubuntu-latest, macos-latest, windows-latest]
18-
php: ["8.0", "8.1", "8.2"]
18+
php: ["8.0", "8.1", "8.2", "8.3"]
1919
rust: [stable, nightly]
20-
clang: ["14"]
20+
clang: ["15", "17"]
2121
phpts: [ts, nts]
2222
exclude:
2323
# ext-php-rs requires nightly Rust when on Windows.
@@ -28,6 +28,12 @@ jobs:
2828
phpts: ts
2929
- os: ubuntu-latest
3030
phpts: ts
31+
- os: macos-latest
32+
clang: "17"
33+
- os: ubuntu-latest
34+
clang: "15"
35+
- os: windows-latest
36+
clang: "15"
3137
env:
3238
CARGO_TERM_COLOR: always
3339
steps:
@@ -83,10 +89,10 @@ jobs:
8389
- name: Build
8490
env:
8591
EXT_PHP_RS_TEST: ""
86-
run: cargo build --release --all-features --all
92+
run: cargo build --release --features closure,anyhow --all
8793
# Test & lint
8894
- name: Test inline examples
89-
run: cargo test --release --all --all-features
95+
run: cargo test --release --all --features closure,anyhow
9096
- name: Run rustfmt
9197
if: matrix.rust == 'stable' && matrix.os == 'ubuntu-latest' && matrix.php == '8.2'
9298
run: cargo fmt --all -- --check
@@ -110,3 +116,11 @@ jobs:
110116
uses: actions/checkout@v3
111117
- name: Build
112118
uses: ./.github/actions/zts
119+
test-embed:
120+
name: Test with embed
121+
runs-on: ubuntu-latest
122+
steps:
123+
- name: Checkout code
124+
uses: actions/checkout@v3
125+
- name: Test
126+
uses: ./.github/actions/embed

.github/workflows/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
matrix:
1717
os: ["ubuntu-latest"]
1818
php: ["8.2"]
19-
clang: ["14"]
19+
clang: ["17"]
2020
mdbook: ["latest"]
2121
steps:
2222
- name: Checkout code

Cargo.toml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ repository = "https://github.com/davidcole1340/ext-php-rs"
55
homepage = "https://github.com/davidcole1340/ext-php-rs"
66
license = "MIT OR Apache-2.0"
77
keywords = ["php", "ffi", "zend"]
8-
version = "0.10.1"
8+
version = "0.10.5"
99
authors = ["David Cole <[email protected]>"]
1010
edition = "2018"
1111
categories = ["api-bindings"]
@@ -17,30 +17,31 @@ parking_lot = "0.12"
1717
cfg-if = "1.0"
1818
once_cell = "1.17"
1919
anyhow = { version = "1", optional = true }
20-
ext-php-rs-derive = { version = "=0.10.0", path = "./crates/macros" }
20+
ext-php-rs-derive = { version = "=0.10.1", path = "./crates/macros" }
2121

2222
[dev-dependencies]
2323
skeptic = "0.13"
2424

2525
[build-dependencies]
2626
anyhow = "1"
27-
bindgen = "0.65.1"
27+
bindgen = "0.68.1"
2828
cc = "1.0"
2929
skeptic = "0.13"
3030

3131
[target.'cfg(windows)'.build-dependencies]
32-
ureq = { version = "2.4", features = ["native-tls", "gzip"], default-features = false }
32+
ureq = { version = "2.4", features = [
33+
"native-tls",
34+
"gzip",
35+
], default-features = false }
3336
native-tls = "0.2"
3437
zip = "0.6"
3538

3639
[features]
3740
closure = []
41+
embed = []
3842

3943
[workspace]
40-
members = [
41-
"crates/macros",
42-
"crates/cli"
43-
]
44+
members = ["crates/macros", "crates/cli"]
4445

4546
[package.metadata.docs.rs]
4647
rustdoc-args = ["--cfg", "docs"]

allowed_bindings.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ bind! {
2626
_efree,
2727
_emalloc,
2828
_zend_executor_globals,
29+
_sapi_globals_struct,
30+
_sapi_module_struct,
2931
_zend_expected_type,
3032
_zend_expected_type_Z_EXPECTED_ARRAY,
3133
_zend_expected_type_Z_EXPECTED_BOOL,
@@ -55,6 +57,8 @@ bind! {
5557
zend_array_destroy,
5658
zend_array_dup,
5759
zend_call_known_function,
60+
zend_fetch_function_str,
61+
zend_hash_str_find_ptr_lc,
5862
zend_ce_argument_count_error,
5963
zend_ce_arithmetic_error,
6064
zend_ce_compile_error,
@@ -99,6 +103,8 @@ bind! {
99103
zend_objects_clone_members,
100104
zend_register_bool_constant,
101105
zend_register_double_constant,
106+
zend_register_ini_entries,
107+
zend_ini_entry_def,
102108
zend_register_internal_class_ex,
103109
zend_register_long_constant,
104110
zend_register_string_constant,
@@ -157,6 +163,10 @@ bind! {
157163
IS_PTR,
158164
MAY_BE_ANY,
159165
MAY_BE_BOOL,
166+
PHP_INI_USER,
167+
PHP_INI_PERDIR,
168+
PHP_INI_SYSTEM,
169+
PHP_INI_ALL,
160170
USING_ZTS,
161171
ZEND_ACC_ABSTRACT,
162172
ZEND_ACC_ANON_CLASS,
@@ -233,6 +243,8 @@ bind! {
233243
zend_class_serialize_deny,
234244
zend_class_unserialize_deny,
235245
zend_executor_globals,
246+
sapi_globals_struct,
247+
sapi_module_struct,
236248
zend_objects_store_del,
237249
zend_hash_move_forward_ex,
238250
zend_hash_get_current_key_type_ex,
@@ -243,10 +255,19 @@ bind! {
243255
gc_possible_root,
244256
ZEND_ACC_NOT_SERIALIZABLE,
245257
executor_globals,
258+
sapi_globals,
259+
sapi_module,
246260
php_printf,
247261
__zend_malloc,
248262
tsrm_get_ls_cache,
249263
executor_globals_offset,
264+
sapi_globals_offset,
250265
zend_atomic_bool_store,
251-
zend_interrupt_function
266+
zend_interrupt_function,
267+
zend_eval_string,
268+
zend_file_handle,
269+
zend_stream_init_filename,
270+
php_execute_script,
271+
zend_register_module_ex,
272+
_zend_bailout
252273
}

build.rs

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use bindgen::RustTarget;
1616
use impl_::Provider;
1717

1818
const MIN_PHP_API_VER: u32 = 20200930;
19-
const MAX_PHP_API_VER: u32 = 20220829;
19+
const MAX_PHP_API_VER: u32 = 20230831;
2020

2121
pub trait PHPProvider<'a>: Sized {
2222
/// Create a new PHP provider.
@@ -151,9 +151,31 @@ fn build_wrapper(defines: &[(&str, &str)], includes: &[PathBuf]) -> Result<()> {
151151
Ok(())
152152
}
153153

154+
#[cfg(feature = "embed")]
155+
/// Builds the embed library.
156+
fn build_embed(defines: &[(&str, &str)], includes: &[PathBuf]) -> Result<()> {
157+
let mut build = cc::Build::new();
158+
for (var, val) in defines {
159+
build.define(var, *val);
160+
}
161+
build
162+
.file("src/embed/embed.c")
163+
.includes(includes)
164+
.try_compile("embed")
165+
.context("Failed to compile ext-php-rs C embed interface")?;
166+
Ok(())
167+
}
168+
154169
/// Generates bindings to the Zend API.
155170
fn generate_bindings(defines: &[(&str, &str)], includes: &[PathBuf]) -> Result<String> {
156-
let mut bindgen = bindgen::Builder::default()
171+
let mut bindgen = bindgen::Builder::default();
172+
173+
#[cfg(feature = "embed")]
174+
{
175+
bindgen = bindgen.header("src/embed/embed.h");
176+
}
177+
178+
bindgen = bindgen
157179
.header("src/wrapper.h")
158180
.clang_args(
159181
includes
@@ -206,6 +228,8 @@ fn check_php_version(info: &PHPInfo) -> Result<()> {
206228

207229
const PHP_82_API_VER: u32 = 20220829;
208230

231+
const PHP_83_API_VER: u32 = 20230831;
232+
209233
println!("cargo:rustc-cfg=php80");
210234

211235
if (PHP_81_API_VER..PHP_82_API_VER).contains(&version) {
@@ -216,6 +240,10 @@ fn check_php_version(info: &PHPInfo) -> Result<()> {
216240
println!("cargo:rustc-cfg=php82");
217241
}
218242

243+
if version >= PHP_83_API_VER {
244+
println!("cargo:rustc-cfg=php83");
245+
}
246+
219247
Ok(())
220248
}
221249

@@ -226,6 +254,8 @@ fn main() -> Result<()> {
226254
for path in [
227255
manifest.join("src").join("wrapper.h"),
228256
manifest.join("src").join("wrapper.c"),
257+
manifest.join("src").join("embed").join("embed.h"),
258+
manifest.join("src").join("embed").join("embed.c"),
229259
manifest.join("allowed_bindings.rs"),
230260
manifest.join("windows_build.rs"),
231261
manifest.join("unix_build.rs"),
@@ -257,6 +287,10 @@ fn main() -> Result<()> {
257287

258288
check_php_version(&info)?;
259289
build_wrapper(&defines, &includes)?;
290+
291+
#[cfg(feature = "embed")]
292+
build_embed(&defines, &includes)?;
293+
260294
let bindings = generate_bindings(&defines, &includes)?;
261295

262296
let out_file =

crates/cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ repository = "https://github.com/davidcole1340/ext-php-rs"
55
homepage = "https://github.com/davidcole1340/ext-php-rs"
66
license = "MIT OR Apache-2.0"
77
keywords = ["php", "ffi", "zend"]
8-
version = "0.1.8"
8+
version = "0.1.9"
99
authors = ["David Cole <[email protected]>"]
1010
edition = "2018"
1111
categories = ["api-bindings", "command-line-interface"]

crates/cli/src/ext.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use anyhow::{Context, Result};
44
use ext_php_rs::describe::Description;
55
use libloading::os::unix::{Library, Symbol};
66

7+
#[allow(improper_ctypes_definitions)]
78
pub struct Ext {
89
// These need to be here to keep the libraries alive. The extension library needs to be alive
910
// to access the describe function. Missing here is the lifetime on `Symbol<'a, fn() ->

crates/macros/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description = "Derive macros for ext-php-rs."
44
repository = "https://github.com/davidcole1340/ext-php-rs"
55
homepage = "https://github.com/davidcole1340/ext-php-rs"
66
license = "MIT OR Apache-2.0"
7-
version = "0.10.0"
7+
version = "0.10.1"
88
authors = ["David Cole <[email protected]>"]
99
edition = "2018"
1010

0 commit comments

Comments
 (0)