Skip to content

Commit 278722a

Browse files
authored
Add document Integrate with PECL. (#78)
1 parent 9b1d180 commit 278722a

File tree

6 files changed

+410
-6
lines changed

6 files changed

+410
-6
lines changed

.licenserc.yaml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,17 @@ header:
1515
software-name: PHPER
1616

1717
paths-ignore:
18-
- 'LICENSE'
19-
- 'NOTICE'
20-
- '**/*.md'
2118
- '**/*.lock'
19+
- '**/*.md'
2220
- '**/.gitignore'
2321
- '**/.gitmodules'
24-
- 'vendor'
2522
- '.cargo'
26-
- '.vscode'
2723
- '.idea'
24+
- '.vscode'
25+
- 'LICENSE'
26+
- 'NOTICE'
27+
- 'config.m4'
28+
- 'vendor'
2829

2930
comment: on-failure
3031

examples/hello/.gitignore

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Generated by Cargo, will have compiled files and executables.
2+
/target/
3+
4+
# These are backup files generated by rustfmt.
5+
**/*.rs.bk
6+
7+
hello-*.tgz
8+
*.lo
9+
*.la
10+
.libs
11+
acinclude.m4
12+
aclocal.m4
13+
autom4te.cache
14+
build
15+
config.guess
16+
config.h
17+
config.h.in
18+
config.h.in~
19+
config.log
20+
config.nice
21+
config.status
22+
config.sub
23+
configure
24+
configure.ac
25+
configure.in
26+
include
27+
install-sh
28+
libtool
29+
ltmain.sh
30+
Makefile
31+
Makefile.fragments
32+
Makefile.global
33+
Makefile.objects
34+
missing
35+
mkinstalldirs
36+
modules
37+
php_test_results_*.txt
38+
phpt.*
39+
run-test-info.php
40+
run-tests.php
41+
tests/**/*.diff
42+
tests/**/*.out
43+
tests/**/*.exp
44+
tests/**/*.log
45+
tests/**/*.db
46+
tests/**/*.mem
47+
tmp-php.ini

examples/hello/config.m4

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
dnl Copyright (c) 2022 PHPER Framework Team
2+
dnl PHPER is licensed under Mulan PSL v2.
3+
dnl You can use this software according to the terms and conditions of the Mulan
4+
dnl PSL v2. You may obtain a copy of Mulan PSL v2 at:
5+
dnl http://license.coscl.org.cn/MulanPSL2
6+
dnl THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY
7+
dnl KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
8+
dnl NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
9+
dnl See the Mulan PSL v2 for more details.
10+
11+
PHP_ARG_ENABLE([hello],
12+
[whether to enable hello support],
13+
[AS_HELP_STRING([--enable-hello],
14+
[Enable hello support])],
15+
[no])
16+
17+
dnl If not enable, `cargo build` run with argument `--release`.
18+
PHP_ARG_ENABLE([cargo_debug], [whether to enable cargo debug mode],
19+
[ --enable-cargo-debug Enable cargo debug], no, no)
20+
21+
if test "$PHP_hello" != "no"; then
22+
dnl Check cargo command exists or not.
23+
AC_PATH_PROG(CARGO, cargo, no)
24+
if ! test -x "$CARGO"; then
25+
AC_MSG_ERROR([cargo command missing, please reinstall the cargo distribution])
26+
fi
27+
28+
AC_DEFINE(HAVE_hello, 1, [ Have hello support ])
29+
30+
PHP_NEW_EXTENSION(hello, [ ], $ext_shared)
31+
32+
CARGO_MODE_FLAGS="--release"
33+
CARGO_MODE_DIR="release"
34+
35+
if test "$PHP_CARGO_DEBUG" != "no"; then
36+
CARGO_MODE_FLAGS=""
37+
CARGO_MODE_DIR="debug"
38+
fi
39+
40+
cat >>Makefile.objects<< EOF
41+
all: cargo_build
42+
43+
clean: cargo_clean
44+
45+
cargo_build:
46+
# Build the extension file
47+
PHP_CONFIG=$PHP_PHP_CONFIG cargo build $CARGO_MODE_FLAGS
48+
49+
# Copy the extension file from target dir to modules
50+
if [[ -f ./target/$CARGO_MODE_DIR/libhello.dylib ]] ; then \\
51+
cp ./target/$CARGO_MODE_DIR/libhello.dylib ./modules/hello.so ; fi
52+
if [[ -f ./target/$CARGO_MODE_DIR/libhello.so ]] ; then \\
53+
cp ./target/$CARGO_MODE_DIR/libhello.so ./modules/hello.so ; fi
54+
55+
cargo_clean:
56+
cargo clean
57+
58+
.PHONY: cargo_build cargo_clean
59+
EOF
60+
61+
dnl Symbolic link the files for `cargo build`
62+
AC_CONFIG_LINKS([ \
63+
Cargo.lock:Cargo.lock \
64+
Cargo.toml:Cargo.toml \
65+
build.rs:build.rs \
66+
src:src \
67+
])
68+
fi

examples/hello/package.xml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
Copyright (c) 2022 PHPER Framework Team
4+
PHPER is licensed under Mulan PSL v2.
5+
You can use this software according to the terms and conditions of the Mulan
6+
PSL v2. You may obtain a copy of Mulan PSL v2 at:
7+
http://license.coscl.org.cn/MulanPSL2
8+
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY
9+
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
10+
NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
11+
See the Mulan PSL v2 for more details.
12+
-->
13+
<package version="2.0"
14+
xmlns="http://pear.php.net/dtd/package-2.0"
15+
xmlns:tasks="http://pear.php.net/dtd/tasks-1.0"
16+
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">
17+
<name>hello</name>
18+
<channel>pecl.php.net</channel>
19+
<summary>Hello world example.</summary>
20+
<description>The Hello world example of phper.</description>
21+
<lead>
22+
<name>jmjoy</name>
23+
<user>jmjoy</user>
24+
<email>jmjoy@apache.org</email>
25+
<active>yes</active>
26+
</lead>
27+
<date>1970-01-01</date>
28+
<version>
29+
<release>0.0.0</release>
30+
<api>0.0.0</api>
31+
</version>
32+
<stability>
33+
<release>stable</release>
34+
<api>stable</api>
35+
</stability>
36+
<license uri="http://license.coscl.org.cn/MulanPSL2/">MulanPSL-2.0</license>
37+
<notes> Release notes. </notes>
38+
<contents>
39+
<dir name="/">
40+
<file name="Cargo.lock" role="src" />
41+
<file name="Cargo.toml" role="src" />
42+
<file name="README.md" role="doc" />
43+
<file name="build.rs" role="src" />
44+
<file name="config.m4" role="src" />
45+
<file name="src/lib.rs" role="src" />
46+
</dir>
47+
</contents>
48+
<dependencies>
49+
<required>
50+
<php>
51+
<min>7.2.0</min>
52+
</php>
53+
<pearinstaller>
54+
<min>1.4.0</min>
55+
</pearinstaller>
56+
</required>
57+
</dependencies>
58+
<providesextension>hello</providesextension>
59+
<extsrcrelease>
60+
<configureoption default="no" name="enable-cargo-debug" prompt="enable cargo debug?" />
61+
</extsrcrelease>
62+
</package>

0 commit comments

Comments
 (0)