Skip to content

Add document Integrate with PECL. #78

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions .licenserc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@ header:
software-name: PHPER

paths-ignore:
- 'LICENSE'
- 'NOTICE'
- '**/*.md'
- '**/*.lock'
- '**/*.md'
- '**/.gitignore'
- '**/.gitmodules'
- 'vendor'
- '.cargo'
- '.vscode'
- '.idea'
- '.vscode'
- 'LICENSE'
- 'NOTICE'
- 'config.m4'
- 'vendor'

comment: on-failure

Expand Down
47 changes: 47 additions & 0 deletions examples/hello/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Generated by Cargo, will have compiled files and executables.
/target/

# These are backup files generated by rustfmt.
**/*.rs.bk

hello-*.tgz
*.lo
*.la
.libs
acinclude.m4
aclocal.m4
autom4te.cache
build
config.guess
config.h
config.h.in
config.h.in~
config.log
config.nice
config.status
config.sub
configure
configure.ac
configure.in
include
install-sh
libtool
ltmain.sh
Makefile
Makefile.fragments
Makefile.global
Makefile.objects
missing
mkinstalldirs
modules
php_test_results_*.txt
phpt.*
run-test-info.php
run-tests.php
tests/**/*.diff
tests/**/*.out
tests/**/*.exp
tests/**/*.log
tests/**/*.db
tests/**/*.mem
tmp-php.ini
68 changes: 68 additions & 0 deletions examples/hello/config.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
dnl Copyright (c) 2022 PHPER Framework Team
dnl PHPER is licensed under Mulan PSL v2.
dnl You can use this software according to the terms and conditions of the Mulan
dnl PSL v2. You may obtain a copy of Mulan PSL v2 at:
dnl http://license.coscl.org.cn/MulanPSL2
dnl THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY
dnl KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
dnl NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
dnl See the Mulan PSL v2 for more details.

PHP_ARG_ENABLE([hello],
[whether to enable hello support],
[AS_HELP_STRING([--enable-hello],
[Enable hello support])],
[no])

dnl If not enable, `cargo build` run with argument `--release`.
PHP_ARG_ENABLE([cargo_debug], [whether to enable cargo debug mode],
[ --enable-cargo-debug Enable cargo debug], no, no)

if test "$PHP_hello" != "no"; then
dnl Check cargo command exists or not.
AC_PATH_PROG(CARGO, cargo, no)
if ! test -x "$CARGO"; then
AC_MSG_ERROR([cargo command missing, please reinstall the cargo distribution])
fi

AC_DEFINE(HAVE_hello, 1, [ Have hello support ])

PHP_NEW_EXTENSION(hello, [ ], $ext_shared)

CARGO_MODE_FLAGS="--release"
CARGO_MODE_DIR="release"

if test "$PHP_CARGO_DEBUG" != "no"; then
CARGO_MODE_FLAGS=""
CARGO_MODE_DIR="debug"
fi

cat >>Makefile.objects<< EOF
all: cargo_build

clean: cargo_clean

cargo_build:
# Build the extension file
PHP_CONFIG=$PHP_PHP_CONFIG cargo build $CARGO_MODE_FLAGS

# Copy the extension file from target dir to modules
if [[ -f ./target/$CARGO_MODE_DIR/libhello.dylib ]] ; then \\
cp ./target/$CARGO_MODE_DIR/libhello.dylib ./modules/hello.so ; fi
if [[ -f ./target/$CARGO_MODE_DIR/libhello.so ]] ; then \\
cp ./target/$CARGO_MODE_DIR/libhello.so ./modules/hello.so ; fi

cargo_clean:
cargo clean

.PHONY: cargo_build cargo_clean
EOF

dnl Symbolic link the files for `cargo build`
AC_CONFIG_LINKS([ \
Cargo.lock:Cargo.lock \
Cargo.toml:Cargo.toml \
build.rs:build.rs \
src:src \
])
fi
62 changes: 62 additions & 0 deletions examples/hello/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?xml version="1.0"?>
<!--
Copyright (c) 2022 PHPER Framework Team
PHPER is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan
PSL v2. You may obtain a copy of Mulan PSL v2 at:
http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
-->
<package version="2.0"
xmlns="http://pear.php.net/dtd/package-2.0"
xmlns:tasks="http://pear.php.net/dtd/tasks-1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd">
<name>hello</name>
<channel>pecl.php.net</channel>
<summary>Hello world example.</summary>
<description>The Hello world example of phper.</description>
<lead>
<name>jmjoy</name>
<user>jmjoy</user>
<email>jmjoy@apache.org</email>
<active>yes</active>
</lead>
<date>1970-01-01</date>
<version>
<release>0.0.0</release>
<api>0.0.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<license uri="http://license.coscl.org.cn/MulanPSL2/">MulanPSL-2.0</license>
<notes> Release notes. </notes>
<contents>
<dir name="/">
<file name="Cargo.lock" role="src" />
<file name="Cargo.toml" role="src" />
<file name="README.md" role="doc" />
<file name="build.rs" role="src" />
<file name="config.m4" role="src" />
<file name="src/lib.rs" role="src" />
</dir>
</contents>
<dependencies>
<required>
<php>
<min>7.2.0</min>
</php>
<pearinstaller>
<min>1.4.0</min>
</pearinstaller>
</required>
</dependencies>
<providesextension>hello</providesextension>
<extsrcrelease>
<configureoption default="no" name="enable-cargo-debug" prompt="enable cargo debug?" />
</extsrcrelease>
</package>
Loading