Commit Graph

34 Commits

Author SHA1 Message Date
Joel Wurtz
2d0e587c7e
feat(embed): add embed features, add test example which run php inside it (#270)
* feat(embed): add embed features, add test example which run php inside it

* feat(embed): use a guard to prevent running in parallel

* chore(ci): update actions to not build and test with embed, add a specific build for embed testing

* feat(embed): correcly start / shutdown embed api

* chore(ci): use stable for rust in embed test

* feat(embed): add documentation, manage potential errors
2023-10-20 14:08:10 +02:00
Pierre Tondereau
8b87e4038e
Bump cargo-php to 0.1.8 (#248)
* Bump cargo-php to 0.1.8

* Fix docker zts installation
2023-06-26 21:34:45 +02:00
Pierre Tondereau
11e0998bc4
feat: Add support for PHP 8.2 (#212)
## Small Fixes due to PHP8.2 upgrade:
- Internal PHP `ZendHashmap` changed the way that we access to the bucket ([commit](90b7bde615 (diff-dca4782c62f10b418ea7193e4641e688ffd7a9c97869f2b1a3a96e28da5653aaL371)))
- Internal PHP `ArrayIterator` doesn't support parent `get_iterator` ([commit](15bbf6f337 (diff-bc002b59b592b4d44c13d898f9dc3ca60b1b1c8505a51a2a3557dfde51dfeb61L273)))
2022-12-20 17:11:35 +01:00
Pierre Tondereau
6965f4a198
Prepare v0.9.0 (#211) 2022-12-11 22:10:25 +01:00
ju1ius
9a105abb63
fixes CI workflow configuration (#195)
* upgrades LLVM to v14
* migrates from the unmaintained `action-rs/*` actions to [dtolnay/rust-toolchain](https://github.com/dtolnay/rust-toolchain), using [Swatinem/rust-cache](https://github.com/Swatinem/rust-cache/) as a cache layer.
* adds a cache layer for LLVM build
* adds a weekly cron schedule for all workflows
* fixes an issue in the docblocks
2022-11-24 09:05:36 +01:00
David Cole
3b1e2e3848
check docs warnings in CI (#180)
* check docs warnings in CI

* works

* format
2022-11-13 21:13:25 +13:00
Tobias Bengtsson
199962ce3f
Merge pull request #151 from striezel-stash/gh-action-update
update actions/checkout in GitHub Actions workflows to v3
2022-09-28 23:04:44 +02:00
Dirk Stolle
a13f2b99cc update actions/checkout in GitHub Actions workflows to v3 2022-09-28 22:11:20 +02:00
Dirk Stolle
ca5a7c21f7 ci: run clippy only on stable Rust channel
Sparked by the comments about nightly clippy breaking the build
too often (see <https://github.com/davidcole1340/ext-php-rs/pull/151#issuecomment-1261151479>),
this change will limit clippy to builds with a stable Rust
version only.
2022-09-28 22:08:10 +02:00
David Cole
664981f4fb
Windows support (#128)
* Preliminary Windows support

* Start work on cross-platform build script

* Fix compilation on macOS

* Updated README, tidied up build script

* Check linker version before starting compilation

It doesn't seem like it's possible to change the linker from within the
build script, however, we can retrieve the linker in use and give the
user a suggestion if the linker will not work.

* Switch to using Github repository for bindgen

* Split Windows and Unix implementations into two files

* Fix building on Windows

* Remove `reqwest` and `zip` as dependencies on Unix

* Fix guide tests on Windows

* Started work on Windows CI

* runs -> run

* Use preinstalled LLVM on Windows

* Debugging for Windows CI

* Switch to upstream `rust-bindgen` master branch

* Switch to `rust-lld` for Windows linking

* Don't compile `cargo-php` on Windows

* Switch to using skeptic for tests

* cargo-php: Disable stub generation, fix ext install/remove

The plan is to replace the stub generation by generating them with PHP
code. This is cross-platform and means we don't need to worry about ABI.
We also don't need to embed information into the library.

* cargo-php: Fix on unix OS

* Fix clippy lint

* Updated README

* Re-add CI for Unix + PHP 8.0

* Fix building on thread-safe PHP

* Tidy up build scripts

* Use dynamic lookup on Linux, test with TS Windows

* Define `ZTS` when compiling PHP ZTS

* Combine Windows and Unix CI, fix linking for Win32TS

* Fix exclusions in build CI

* rust-toolchain -> rust

* Set LLVM version

* Only build docs.rs on Ubuntu PHP 8.1

* Fix build on Linux thread-safe

* Update guide example
2022-03-18 16:36:51 +13:00
David Cole
75ea32346c
Fix CI on macOS (#126)
* Attempt to fix CI on macOS by not installing LLVM

* Download LLVM even on macOS

* Only set LIBCLANG_PATH on non-macOS

* Fix yaml

* Try to set SDK path for macOS

* Multi-line run

* Clippy lint

* Only check docs on PHP 8.1

* When running with docs stub, use PHP 8.1

* Only build docs on Ubuntu

* Remove `macos-ci` branch from actions

* Trigger actions
2022-03-06 16:01:27 +13:00
David Cole
a776d3eaae Fix CI on macOS + docs stubs 2022-02-22 11:24:39 +13:00
David Cole
6fd31621f2
Add preliminary PHP 8.1 support (#109)
* Bump PHP API version, remove flags removed from PHP API

See following commits:
- 70195c3561
- b5746a4c7f

* Add PHP 8.1 to CI

* Clippy lint

* Fix PHP 8.1 support with new features
2021-11-21 20:00:51 +13:00
David Cole
6df362b714
Added CLI crate for stubs, installation and removal (#107)
* started work on stub generator

* Worked on stub CLI tool

* Unused import

* Account for namespaces in function and class names

* Add support for docblocks on structs

* Push Rust comments to stubs

* Add indentation to stub generation

* Add CLI application to install and generate stubs

This time CLI application is defined on user side, called with `cargo
run -- ..args..`

* Export anyhow result

* Add constants to stub file

* Removed stub symbols

No longer required as we are now building while also linking to PHP.
Keeping the stubs causes the stubs to override the real symbols in the
extension.

* Fix stubs for real this time

Removed stub symbols as they were being included in the extension
dylib, fix by loading the PHP executable as a dylib, loading the
required symbols globally.

* Maybe actually fix stubs this time

* Forgot to remove PHP binary loading

* let's give this another go... cargo subcommand

Now called via `cargo php <install,stubs>`.

* Added `remove` command

* Tidied up cargo-php, commented, set up CI

* Fix return types with non-ident types

* define namespace ordering

* Fix tests, replace `Self` when in outer context

* Moved allowed bindings into separate file

* Update guide with CLI instructions
2021-11-20 14:19:02 +13:00
David Cole
7812b7ff1e Test docs.rs stub file in lint build 2021-10-10 22:57:38 +13:00
David
3403cba7bf
Add ZBox<T> to replace owned variants (#94)
* Added `ZBox` and `ZBoxable`

* Implement `ZBoxable` for `ZendStr`

Build for all f eatures on CI

* Replace `OwnedZendObject` with `ZBox<ZendObject>`

* Replace `ClassObject` with `ZBox<ZendClassObject>`

Fixed deserialization bug

Panic when uninitialized - better than UB

* Replace `OwnedHashTable` with `ZBox<HashTable>`

* Remove `MaybeUninit` from `ZendClassObject`
2021-10-05 16:59:41 +13:00
David
afdac8e4b3
Add support for field and method properties (#69)
* Rough implementation of struct properties

* Store properties hashtable once

* Tidy up handler functions with exceptions

* Add stub `get_properties` function for codegen structs

* Remove nightly features

* Revert storing properties

Technically, the zend object _could_ move in memory, leaving dangling
references in the properties hashtable. We will just build the hashtable
when required.

* Added `#[prop]` attribute

* Add pointer type to zval, tidy up zend string

* Add support for method properties

* Add `#[getter]` and `#[setter]` attributes

* Update documentation with method properties

* Tidy up macros code

* Remove string gc checks (done on PHP side)

* Move `RegisteredClass` implementation to module, update docs

* Fix read property `rv` segfault

* Fixed doctests
2021-09-28 00:54:23 +13:00
David Cole
5bf24588c9 v0.4.0: bump version 2021-09-05 18:46:38 +12:00
David Cole
0056db3392 Fix docs build 2021-09-05 18:00:52 +12:00
David
b50a6c64bf
Allowlist types generated by bindgen (#60)
* 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
2021-09-05 17:56:29 +12:00
David Cole
20e8c16ff0 Build docs on nightly 2021-09-05 14:24:56 +12:00
David Cole
31a1e3d5e1 Document features, fix documentation links 2021-09-05 14:18:03 +12:00
David
4a4370c817
Add ability to send Rust closures to PHP (#58)
* Start work on returning new objects

Change `IntoZval` to consume `self`

* Add conversion from vector reference to PHP hashtable through clones

* `set_binary` now only takes `Vec`

Used to take `AsRef<[T]>` to allow users to pass arrays, however, this
causes the data to be cloned even if the user passes a `Vec`.

* Rename `as_zval` to `into_zval` to match Rust conventions

* Started work on closures

* Finish implementation of closures

* Document closures, add to prelude, feature gate

* Fixed closure example
2021-09-05 13:45:59 +12:00
David Cole
46de219ea9 Run cargo and mdbook tests on build 2021-08-22 01:33:22 +12:00
David Cole
a2cc921ab0 Use binary mdbook rather than compiling 2021-08-22 01:24:51 +12:00
David
bd84f28054
Added ext-php-rs guide (#52)
* Started work on guide, added types

* Rewrite argument parser to allow referencs

Primarly so that `&str` is a valid parameter type.

* Remove generic `Into<String>` conversion to exception

* Worked on guide, added macros

* Build guide when building docs

* Allow manual trigger of docs build

* `cargo fmt`
2021-08-22 01:00:14 +12:00
David
0db6888c46
Added support for PHP ZTS (#37)
* Added support for PHP ZTS

* Added GitHub action for ZTS

Runs seperate from the other tests, as the setup-php action does not
support ZTS, therefore we run the tests in a Docker container.

* Source Rust env file before building

* No `source` command on docker

* Another attempt at fixing Rust in Docker
2021-05-19 20:45:39 +12:00
David
fcdd9332f5
Build and deploy docs to Github pages (#35)
* Added Github action for building and publishing docs

* Create index redirect page for docs

* Only deploy on master, fixed redirect
2021-05-04 11:42:52 +12:00
David
d1e719ef7a
Only run CI on pushes to master and PRs 2021-04-24 13:29:53 +12:00
David Cole
5f89a5f970 Fixed typo v2 2021-04-17 00:25:07 +12:00
David Cole
b08fad5aad Fixed typo 2021-04-17 00:20:17 +12:00
David Cole
53e69f3820 Fixed CI by installing LLVM 2021-04-17 00:17:02 +12:00
Will Browning
cea3cb2dc4
Updated Bindgen to 0.58.1 (#20)
* Update bindgen

* Fix failing test

* Add env llvm and libclang variables

* Fixed doc comment for table macros

* Removed newline

Co-authored-by: David Cole <david.cole1340@gmail.com>
2021-04-17 00:05:17 +12:00
David
e1ca2129fe
Add github actions for building and linting (#12)
* Added github build workflow

* Added lint workflow

* Fixed clippy errors

* Fixed clippy warnings

* Allow warnings on generated code

* Final clippy fix... hopefully
2021-03-11 13:41:05 +13:00