Commit Graph

43 Commits

Author SHA1 Message Date
3fb905afdb
Fix borrowing of parameters in async functions 2023-06-19 11:40:14 +02:00
2088fadf38
A small hack to workaround known good lifetimes 2023-06-19 11:40:14 +02:00
10d3c50181
Update 2023-06-19 11:40:13 +02:00
cc50781903
Add async support 2023-06-19 11:40:13 +02:00
Pierre Tondereau
6b6489fddb
chore: fix clippy warnings. (#235) 2023-03-13 18:00:45 +01:00
Pierre Tondereau
e6afecbddd
chore(clippy): Fix clippy warnings. (#228) 2023-02-07 22:52:56 +01:00
Joe Hoyle
1875e99e93
Pass args to startup function (#226) 2023-02-07 22:24:33 +01:00
Pierre Tondereau
7ed31ebda9
chore: Prepare 0.10.0 (#215) 2022-12-22 22:55:07 +01:00
Pierre Tondereau
6965f4a198
Prepare v0.9.0 (#211) 2022-12-11 22:10:25 +01:00
David Cole
a160f2a2a0 Bump version to v0.8.2 2022-11-11 12:11:33 +13:00
Pierre Tondereau
b72d0555d6
chore(cli): Bump Clap for CLI tool (#177) 2022-11-10 10:59:49 +01:00
David Cole
5f33598fcf
add before flag to #[php_startup] (#170)
* add `before` flag to `#[php_startup]`

this calls the user-provided startup function _before_ the classes and
constants registered by the macro system are registered with PHP. by
default the behaviour is to run this function after, which means you
cannot define an interface and use it on a struct.

* cargo fmt
2022-11-10 13:51:05 +13:00
David Cole
76358ede3c rustfmt... 2022-10-23 12:06:22 +13:00
David Cole
1f0582b10d
fix describe when using #[implements] (#169)
[ci skip]
2022-10-23 12:02:00 +13:00
David Cole
669e024feb Bump version to v0.8.1 2022-10-12 11:18:22 +13:00
Robert O'Rourke
8a81c4b7f8
Allow passing --yes parameter to bypass prompts (#135)
* Allow passing `--yes` parameter to bypass prompts

Makes this tool usable in automated builds such as Docker containers.

Addresses https://github.com/davidcole1340/ext-php-rs/issues/133

* Update readme and guides

* rustfmt

Co-authored-by: David Cole <david.cole1340@gmail.com>
2022-10-01 12:14:15 +13:00
Robert O'Rourke
7dac4010a0
Fix INI file truncation and duplication (#136)
Addresses https://github.com/davidcole1340/ext-php-rs/issues/134

Also prevents adding the extension include line twice.
2022-10-01 11:24:36 +13:00
Joe Hoyle
d4ef116b31
Support marking methods as abstract (#154)
For classes that are registered with `#[php_impl]` this allows functions to be marked as abstract.
2022-10-01 11:24:04 +13:00
Joe Hoyle
5d1fda4666
Support marking classes as interfaces (#155)
* Support marking classes as interfaces

This allows passing flags as part of `#[php_class(flags=Interface]` etc, which allows one to mark a class as being an interface.

When a class is an interface, it also shouldn't get a constructor created for it.

* rustfmt
2022-10-01 11:23:48 +13:00
Joe Hoyle
18ede97712 Add ability to set function name on php_function macro
This is much the same as `php_class(name="ABC")`
2022-09-30 12:01:35 +02:00
Dirk Stolle
7b238eede1 attempt to fix errors related to clap
This should fix the errors from the build at
<https://github.com/davidcole1340/ext-php-rs/actions/runs/3145521955/jobs/5112909446>:

       Compiling clap v4.0.0
    error: Unknown `#[clap(long)]` attribute (`#[arg(long)] exists)
      --> crates/cli/src/lib.rs:92:12
       |
    92 |     #[clap(long)]
       |            ^^^^

    error: Unknown `#[clap(long)]` attribute (`#[arg(long)] exists)
       --> crates/cli/src/lib.rs:115:12
        |
    115 |     #[clap(long)]
        |            ^^^^

    error: Unknown `#[clap(short)]` attribute (`#[arg(short)] exists)
       --> crates/cli/src/lib.rs:134:12
        |
    134 |     #[clap(short, long)]
        |            ^^^^^

    error: could not compile `cargo-php` due to 3 previous errors
    warning: build failed, waiting for other jobs to finish...
    Error: Process completed with exit code 101.

These errors were probably caused by the release of `clap` 4.0.0
a few hours ago.
2022-09-28 21:05:56 +02:00
Dirk Stolle
ee45e8dc73 fix more causes of clippy warnings
Clippy linting had more errors:

    error: iterating on a map's values
    Error:   --> crates/macros/src/module.rs:56:36
       |
    56 |       let registered_classes_impls = state
       |  ____________________________________^
    57 | |         .classes
    58 | |         .iter()
    59 | |         .map(|(_, class)| generate_registered_class_impl(class))
       | |________________________________________________________________^
       |
       = note: `-D clippy::iter-kv-map` implied by `-D warnings`
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#iter_kv_map
    help: try
       |
    56 ~     let registered_classes_impls = state
    57 +         .classes.values().map(|class| generate_registered_class_impl(class))
       |

    error: iterating on a map's values
    Error:    --> crates/macros/src/module.rs:366:23
        |
    366 |         let classes = self.classes.iter().map(|(_, class)| class.describe());
        |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `self.classes.values().map(|class| class.describe())`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#iter_kv_map

    error: could not compile `ext-php-rs-derive` due to 2 previous errors
2022-09-28 12:34:12 +02:00
Dirk Stolle
4bb0559ab8 Fix a few typos 2022-09-10 16:40:38 +02:00
Tobias Bengtsson
fb9d0797cc Release 0.8.0 2022-08-14 11:50:42 +02:00
Pierre Tondereau
f6207e033c Update clap. 2022-06-16 10:25:04 +02:00
Pierre Tondereau
d1cb7cc114 Update dependancies. 2022-06-14 10:45:27 +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
7520720558 Release 0.7.4 2022-03-17 23:57:56 +13:00
David Cole
4468656563
Add ability to pass modifier function for classes (#127) 2022-03-08 15:01:16 +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
a3fbc24aa3 Updated clap, closes #125 2022-03-05 13:03:39 +13:00
David Cole
705be68882 Release v0.7.3 2021-12-13 21:34:44 +13:00
vkill
745cd132aa
Upgrade dep clap to 3.0.0-rc.0 (#113) 2021-12-09 21:32:03 +13:00
David Cole
06db954912 Release v0.7.2 2021-11-27 13:00:06 +13:00
David Cole
55cc255ba2 CLI: v0.1.2 2021-11-23 19:02:02 +13:00
David Cole
8c1509f62a
Fix registering constants when using expressions (#112) 2021-11-23 19:01:04 +13:00
David Cole
d9e40ea4d2
Ensure CLI-Extension compatibility (#108)
* Change describe types to C ABI, check ext-php-rs version

Rust doesn't have a stable ABI so the describe function and types are
now C ABI compatible, however, the internal types `Cow`, `Vec`, `Option`
aren't.

Check `ext-php-rs` versions to check compatibility between the CLI and
the extension.

* CLI requires 0.7.1

* Bump versions

* Replace standard library types with ABI-stable replacements

* Change option type
2021-11-21 17:27:12 +13:00
David Cole
fa05703c08 Release v0.7.0 2021-11-20 14:33:41 +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
d74b5d54b7 Clean up clippy lints 2021-11-05 23:45:58 +13:00
David Cole
b92202c89b Release v0.6.0 2021-10-10 23:21:39 +13:00
David Cole
b47f8ba160
Allow ZendClassObject as self parameter (#103)
* Allow `ZendClassObject` as `self` parameter

* Fixed tests

* Updated guide

* Updated changelog
2021-10-10 22:46:26 +13:00
David Cole
466c1658e3
Refactor module paths (#101)
* Refactor module layout

* Fixed documentation tests

* Removed skel, moved macro crate

* Ignore folders for crate publish

* Fix builder for zts

* Add `rustfmt.toml`, wrap all comments #96

* Fixed up documentation links, tidied up

* Add `Zend` prefix to callable and hashtable

* Updated guide types

* Updated changelog
2021-10-10 17:51:55 +13:00