Skip to content

Commit f3f0875

Browse files
authored
Provide static feature (#562)
1 parent 73f3d21 commit f3f0875

File tree

7 files changed

+14
-9
lines changed

7 files changed

+14
-9
lines changed

.github/actions/embed/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ ENV PATH=/cargo/bin:/rust/bin:$PATH
1212

1313
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path && cargo install cargo-expand
1414

15-
ENTRYPOINT [ "/cargo/bin/cargo", "test", "--workspace", "--release", "--all-features", "--no-fail-fast" ]
15+
ENTRYPOINT [ "/cargo/bin/cargo", "test", "--workspace", "--release", "--features", "closure,embed,anyhow", "--no-fail-fast" ]

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ jobs:
7272
- name: Run rustfmt
7373
run: cargo fmt --all -- --check
7474
- name: Run clippy
75-
run: cargo clippy --workspace --all-targets --all-features -- -W clippy::pedantic -D warnings
75+
run: cargo clippy --workspace --all-targets --features closure,embed,anyhow -- -W clippy::pedantic -D warnings
7676
# Docs
7777
- name: Run rustdoc
7878
run: cargo rustdoc -- -D warnings
@@ -162,12 +162,12 @@ jobs:
162162
- name: Build
163163
env:
164164
EXT_PHP_RS_TEST: ""
165-
run: cargo build --release --features closure,anyhow --workspace ${{ matrix.php == '8.0' && '--no-default-features' || '' }}
165+
run: cargo build --release --features closure,anyhow,runtime --workspace ${{ matrix.php == '8.0' && '--no-default-features' || '' }}
166166
# Test
167167
- name: Test inline examples
168168
# Macos fails on unstable rust. We skip the inline examples test for now.
169169
if: "!(contains(matrix.os, 'macos') && matrix.rust == 'nightly')"
170-
run: cargo test --release --workspace --features closure,anyhow --no-fail-fast ${{ matrix.php == '8.0' && '--no-default-features' || '' }}
170+
run: cargo test --release --workspace --features closure,anyhow,runtime --no-fail-fast ${{ matrix.php == '8.0' && '--no-default-features' || '' }}
171171
build-zts:
172172
name: Build with ZTS
173173
runs-on: ubuntu-latest

.github/workflows/coverage.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,6 @@ jobs:
6363
cargo tarpaulin --version
6464
- name: Run tests
6565
run: |
66-
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
66+
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
6767
- name: Upload coverage
6868
uses: coverallsapp/github-action@v2

.lefthook.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pre-commit:
88
- "crates/macros/tests/expand/*.expanded.rs"
99
stage_fixed: true
1010
- name: clippy
11-
run: cargo clippy --workspace --all-targets --all-features -- -W clippy::pedantic -D warnings
11+
run: cargo clippy --workspace --all-targets --features closure,embed,anyhow -- -W clippy::pedantic -D warnings
1212
glob: "*.rs"
1313
- name: bindings
1414
run: tools/update_bindings.sh && git diff --exit-code docsrs_bindings.rs

Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ skeptic = "0.13"
2828

2929
[build-dependencies]
3030
anyhow = "1"
31-
bindgen = "0.72"
31+
bindgen = { version = "0.72", default-features = false, features = ["logging", "prettyplease"] }
3232
cc = "1.2"
3333
skeptic = "0.13"
3434

@@ -41,11 +41,13 @@ native-tls = "0.2"
4141
zip = "6.0"
4242

4343
[features]
44-
default = ["enum"]
44+
default = ["enum", "runtime"]
4545
closure = []
4646
embed = []
4747
anyhow = ["dep:anyhow"]
4848
enum = []
49+
runtime = ["bindgen/runtime"]
50+
static = ["bindgen/static"]
4951

5052
[workspace]
5153
members = [

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,9 @@ All features are disabled by default.
162162
class type, `RustClosure`.
163163
- `anyhow` - Implements `Into<PhpException>` for `anyhow::Error`, allowing you
164164
to return anyhow results from PHP functions. Supports anyhow v1.x.
165+
- `static` - Allows building the library against
166+
[statically linked clang](https://github.com/KyleMayes/clang-sys?tab=readme-ov-file#static),
167+
for example with [static-php-cli](https://static-php.dev/)
165168

166169
## Usage
167170

tests/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ publish = false
66
license = "MIT OR Apache-2.0"
77

88
[dependencies]
9-
ext-php-rs = { path = "../", default-features = false, features = ["closure"] }
9+
ext-php-rs = { path = "../", default-features = false, features = ["closure", "runtime"] }
1010

1111
[features]
1212
default = ["enum"]

0 commit comments

Comments
 (0)