From b7e9d4b6d453ef9acb3020455d9db68f57c38f7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abi=20=D8=A3=D8=A8?= Date: Tue, 21 Oct 2025 17:38:16 +0700 Subject: [PATCH 1/4] feat: introduce static feature --- Cargo.toml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d627a927c..0eee3c4ea 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,7 +28,7 @@ skeptic = "0.13" [build-dependencies] anyhow = "1" -bindgen = "0.72" +bindgen = { version = "0.72", default-features = false, features = ["logging", "prettyplease"] } cc = "1.2" skeptic = "0.13" @@ -41,11 +41,13 @@ native-tls = "0.2" zip = "6.0" [features] -default = ["enum"] +default = ["enum", "runtime"] closure = [] embed = [] anyhow = ["dep:anyhow"] enum = [] +runtime = ["bindgen/runtime"] +static = ["bindgen/static"] [workspace] members = [ From c49819f9ec786642b300bd011eda8ddbd3e9d0d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abi=20=D8=A3=D8=A8?= Date: Thu, 23 Oct 2025 17:02:01 +0700 Subject: [PATCH 2/4] feat: replace --all-features with explicit --features --- .github/actions/embed/Dockerfile | 2 +- .github/workflows/build.yml | 6 +++--- .github/workflows/coverage.yml | 2 +- .lefthook.yml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/actions/embed/Dockerfile b/.github/actions/embed/Dockerfile index 75d61876a..a16d96b48 100644 --- a/.github/actions/embed/Dockerfile +++ b/.github/actions/embed/Dockerfile @@ -12,4 +12,4 @@ ENV PATH=/cargo/bin:/rust/bin:$PATH RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path && cargo install cargo-expand -ENTRYPOINT [ "/cargo/bin/cargo", "test", "--workspace", "--release", "--all-features", "--no-fail-fast" ] +ENTRYPOINT [ "/cargo/bin/cargo", "test", "--workspace", "--release", "--features", "closure,embed,anyhow", "--no-fail-fast" ] diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 029c2e817..0e69aef8e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -72,7 +72,7 @@ jobs: - name: Run rustfmt run: cargo fmt --all -- --check - name: Run clippy - run: cargo clippy --workspace --all-targets --all-features -- -W clippy::pedantic -D warnings + run: cargo clippy --workspace --all-targets --features closure,embed,anyhow -- -W clippy::pedantic -D warnings # Docs - name: Run rustdoc run: cargo rustdoc -- -D warnings @@ -162,12 +162,12 @@ jobs: - name: Build env: EXT_PHP_RS_TEST: "" - run: cargo build --release --features closure,anyhow --workspace ${{ matrix.php == '8.0' && '--no-default-features' || '' }} + run: cargo build --release --features closure,anyhow,runtime --workspace ${{ matrix.php == '8.0' && '--no-default-features' || '' }} # Test - name: Test inline examples # Macos fails on unstable rust. We skip the inline examples test for now. if: "!(contains(matrix.os, 'macos') && matrix.rust == 'nightly')" - run: cargo test --release --workspace --features closure,anyhow --no-fail-fast ${{ matrix.php == '8.0' && '--no-default-features' || '' }} + run: cargo test --release --workspace --features closure,anyhow,runtime --no-fail-fast ${{ matrix.php == '8.0' && '--no-default-features' || '' }} build-zts: name: Build with ZTS runs-on: ubuntu-latest diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 1b725ff03..449ab665d 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -63,6 +63,6 @@ jobs: cargo tarpaulin --version - name: Run tests run: | - cargo tarpaulin --engine llvm --workspace --all-features --tests --exclude tests --exclude-files docsrs_bindings.rs --exclude-files "crates/macros/tests/expand/*.expanded.rs" --timeout 120 --out Xml + cargo tarpaulin --engine llvm --workspace --features closure,embed,anyhow --tests --exclude tests --exclude-files docsrs_bindings.rs --exclude-files "crates/macros/tests/expand/*.expanded.rs" --timeout 120 --out Xml - name: Upload coverage uses: coverallsapp/github-action@v2 diff --git a/.lefthook.yml b/.lefthook.yml index 8d518ea07..31eb5fc47 100644 --- a/.lefthook.yml +++ b/.lefthook.yml @@ -8,7 +8,7 @@ pre-commit: - "crates/macros/tests/expand/*.expanded.rs" stage_fixed: true - name: clippy - run: cargo clippy --workspace --all-targets --all-features -- -W clippy::pedantic -D warnings + run: cargo clippy --workspace --all-targets --features closure,embed,anyhow -- -W clippy::pedantic -D warnings glob: "*.rs" - name: bindings run: tools/update_bindings.sh && git diff --exit-code docsrs_bindings.rs From 2be41762b85db9af30405efad6f45cb2d0b98570 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abi=20=D8=A3=D8=A8?= Date: Thu, 23 Oct 2025 17:48:48 +0700 Subject: [PATCH 3/4] feat: add runtime feature dep to tests package --- tests/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Cargo.toml b/tests/Cargo.toml index 8feadcc08..1f95058fb 100644 --- a/tests/Cargo.toml +++ b/tests/Cargo.toml @@ -6,7 +6,7 @@ publish = false license = "MIT OR Apache-2.0" [dependencies] -ext-php-rs = { path = "../", default-features = false, features = ["closure"] } +ext-php-rs = { path = "../", default-features = false, features = ["closure", "runtime"] } [features] default = ["enum"] From cf99dee1ab9609c74338482e8c01a13aae17c66d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abi=20=D8=A3=D8=A8?= Date: Thu, 23 Oct 2025 18:50:59 +0700 Subject: [PATCH 4/4] feat: add feature description in README --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index b3ecc4d5a..435bc2896 100644 --- a/README.md +++ b/README.md @@ -162,6 +162,9 @@ All features are disabled by default. class type, `RustClosure`. - `anyhow` - Implements `Into` for `anyhow::Error`, allowing you to return anyhow results from PHP functions. Supports anyhow v1.x. +- `static` - Allows building the library against + [statically linked clang](https://github.com/KyleMayes/clang-sys?tab=readme-ov-file#static), + for example with [static-php-cli](https://static-php.dev/) ## Usage