generated from colopl/pskel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
558 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"name": "pskel", | ||
"name": "extension_example", | ||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
{ | ||
"$schema": "https://docs.renovatebot.com/renovate-schema.json", | ||
"extends": [ | ||
"config:recommended" | ||
], | ||
"timezone": "Asia/Tokyo", | ||
"git-submodules": { | ||
"enabled": true, | ||
"versioning": "git", | ||
"fileMatch": [ | ||
"(^|/)\\.gitmodules$" | ||
] | ||
}, | ||
"packageRules": [ | ||
{ | ||
"matchManagers": [ | ||
"git-submodules" | ||
], | ||
"enabled": false | ||
}, | ||
{ | ||
"matchDepNames": [ | ||
"jedisct1/libsodium" | ||
], | ||
"matchManagers": [ | ||
"regex" | ||
], | ||
"versioning": "regex:^(?<major>\\d+)\\.(?<minor>\\d+)\\.(?<patch>\\d+)\\-RELEASE$", | ||
"allowedVersions": "/^[0-9]+\\.[0-9]+\\.[0-9]+\\-RELEASE$/" | ||
} | ||
], | ||
"customManagers": [ | ||
{ | ||
"customType": "regex", | ||
"fileMatch": [ | ||
"^\\.gitmodules$" | ||
], | ||
"matchStrings": [ | ||
"\\[submodule \"(?<depName>.+)\"\\][^\\[]*?\\n\\s*branch\\s*=\\s*(?<currentValue>.*)" | ||
], | ||
"datasourceTemplate": "github-tags", | ||
"versioningTemplate": "{{#if versioning}}{{versioning}}{{else}}semver{{/if}}" | ||
} | ||
], | ||
"postUpgradeTasks": { | ||
"commands": [ | ||
"(test \"{{{manager}}}\" = \"regex\" && git submodule update && git submodule init \"$(git config --file \".gitmodules\" submodule.{{{depName}}}.path)\" && git submodule update \"$(git config --file \".gitmodules\" submodule.{{{depName}}}.path)\" && (cd \"$(git config --file \".gitmodules\" submodule.{{{depName}}}.path)\" && git fetch --tags && git checkout \"{{{newVersion}}}\")) || true" | ||
] | ||
} | ||
} | ||
{ | ||
"$schema": "https://docs.renovatebot.com/renovate-schema.json", | ||
"extends": [ | ||
"config:recommended" | ||
], | ||
"timezone": "Asia/Tokyo", | ||
"git-submodules": { | ||
"enabled": true, | ||
"versioning": "git", | ||
"fileMatch": [ | ||
"(^|/)\\.gitmodules$" | ||
] | ||
}, | ||
"packageRules": [ | ||
{ | ||
"matchManagers": [ | ||
"git-submodules" | ||
], | ||
"enabled": false | ||
}, | ||
{ | ||
"matchDepNames": [ | ||
"jedisct1/libsodium" | ||
], | ||
"matchManagers": [ | ||
"regex" | ||
], | ||
"versioning": "regex:^(?<major>\\d+)\\.(?<minor>\\d+)\\.(?<patch>\\d+)\\-RELEASE$", | ||
"allowedVersions": "/^[0-9]+\\.[0-9]+\\.[0-9]+\\-RELEASE$/" | ||
} | ||
], | ||
"customManagers": [ | ||
{ | ||
"customType": "regex", | ||
"fileMatch": [ | ||
"^\\.gitmodules$" | ||
], | ||
"matchStrings": [ | ||
"\\[submodule \"(?<depName>.+)\"\\][^\\[]*?\\n\\s*branch\\s*=\\s*(?<currentValue>.*)" | ||
], | ||
"datasourceTemplate": "github-tags", | ||
"versioningTemplate": "{{#if versioning}}{{versioning}}{{else}}semver{{/if}}" | ||
} | ||
], | ||
"postUpgradeTasks": { | ||
"commands": [ | ||
"(test \"{{{manager}}}\" = \"regex\" && git submodule update && git submodule init \"$(git config --file \".gitmodules\" submodule.{{{depName}}}.path)\" && git submodule update \"$(git config --file \".gitmodules\" submodule.{{{depName}}}.path)\" && (cd \"$(git config --file \".gitmodules\" submodule.{{{depName}}}.path)\" && git fetch --tags && git checkout \"{{{newVersion}}}\")) || true" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,12 +6,14 @@ jobs: | |
strategy: | ||
matrix: | ||
arch: ["amd64", "arm64v8", "s390x"] | ||
version: ["8.1", "8.2", "8.3"] | ||
version: ["8.2", "8.3"] | ||
type: ["cli", "zts"] | ||
distro: ["bookworm", "alpine"] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: true | ||
- name: Setup QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
with: | ||
|
@@ -20,7 +22,7 @@ jobs: | |
uses: docker/setup-buildx-action@v3 | ||
- name: Build container | ||
run: | | ||
docker compose build --pull --no-cache --build-arg IMAGE=${{ matrix.arch }}/php --build-arg TAG=${{ matrix.version }}-${{ matrix.type }}-${{ matrix.distro }} --build-arg PSKEL_SKIP_DEBUG=${{ matrix.arch != 'amd64' && '1' || '' }} | ||
docker compose build --pull --no-cache --build-arg IMAGE=${{ matrix.arch }}/php --build-arg TAG=${{ matrix.version }}-${{ matrix.type }}-${{ matrix.distro }} --build-arg PSKEL_SKIP_DEBUG=${{ matrix.arch != 'amd64' && '1' || '' }} | ||
- name: Run tests | ||
run: | | ||
docker compose run --rm --entrypoint=/usr/bin/pskel_test --env TEST_EXTENSION=1 dev | ||
|
@@ -44,40 +46,3 @@ jobs: | |
if: matrix.arch == 'amd64' && matrix.distro != 'alpine' | ||
run: | | ||
docker compose run --rm --entrypoint=/usr/bin/pskel_test --env TEST_EXTENSION_UBSAN=1 dev | ||
# Windows: | ||
# runs-on: windows-2022 | ||
# defaults: | ||
# run: | ||
# shell: cmd | ||
# strategy: | ||
# matrix: | ||
# arch: ["x64"] | ||
# version: ["8.1", "8.2", "8.3"] | ||
# ts: ["nts", "ts"] | ||
# steps: | ||
# - name: Checkout | ||
# uses: actions/checkout@v4 | ||
# - name: Setup PHP | ||
# id: setup-php | ||
# uses: php/[email protected] | ||
# with: | ||
# arch: ${{ matrix.arch }} | ||
# version: ${{ matrix.version }} | ||
# ts: ${{ matrix.ts }} | ||
# - name: Enable developer command prompt | ||
# uses: ilammy/msvc-dev-cmd@v1 | ||
# with: | ||
# arch: ${{ matrix.arch }} | ||
# toolset: ${{ steps.setup-php.outputs.toolset }} | ||
# - name: phpize | ||
# working-directory: ext | ||
# run: phpize | ||
# - name: configure | ||
# working-directory: ext | ||
# run: configure --enable-skeleton --with-prefix=${{ steps.setup-php.outputs.prefix }} | ||
# - name: make | ||
# working-directory: ext | ||
# run: nmake | ||
# - name: test | ||
# working-directory: ext | ||
# run: nmake test TESTS="--show-diff tests" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[submodule "jedisct1/libsodium"] | ||
path = ext/third_party/libsodium | ||
url = https://github.com/jedisct1/libsodium.git | ||
branch = 1.0.20-RELEASE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,23 @@ | ||
# Pskel | ||
# extension_example | ||
|
||
A skeleton project for quickly setting up an environment to develop extensions for PHP. | ||
[`zeriyoshi/pskel`](https://github.com/zeriyoshi/pskel) を用いた PHP Extension のサンプルです。 | ||
|
||
### How to use | ||
PHP 8.2 から利用できる `ext-random` ビルトイン拡張機能に [`libsodium`](https://github.com/jedisct1/libsodium) を用いた乱数生成器を追加するサンプル実装を含んでいます。 | ||
|
||
1. Install [Visual Studio Code](https://code.visualstudio.com/) and Docker Desktop (or an alternative engine). | ||
1. Install the [Remote Container](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) extension in VSCode. | ||
1. Open the directory and open it with the `Remote Container` extension. | ||
1. Run `pskel_init_extension` command. | ||
2. Run `pskel_test` command for testing. | ||
|
||
### Q&A | ||
|
||
#### Can I set up an environment using MySQL, Redis, etc.? | ||
|
||
Yes. Pskel comes pre-setup with MySQL as a example. If you want to add something, you can easily do so by editing the `compose.yaml`. | ||
|
||
#### Can I use a debug version of PHP? | ||
|
||
A debug build of PHP is included in advance. Debug builds using GCC and Clang are available, and Valgrind support is enabled. With the Clang build, you can also use MemorySanitizer. | ||
|
||
They each have the following binary prefixes. The build toolchains are the same. | ||
|
||
- `debug-php` | ||
- `gcc-valgrind-php` | ||
- `clang-msan-php` | ||
- `clang-asan-php` | ||
- `clang-ubsan-php` | ||
|
||
For example, the method to test the extension using GCC + Valgrind is as follows: | ||
|
||
``` | ||
# gcc-valgrind-phpize | ||
# ./configure --with-php-config=$(which gcc-valgrind-php-config) | ||
# TEST_PHP_ARGS="-q -m --show-diff" make -j$(nproc) test | ||
``` | ||
|
||
#### Can I debug using gdb? | ||
|
||
Yes. Build using the debug version of PHP and run as follows: | ||
### Usage | ||
|
||
``` | ||
# gdb --args gcc-valgrind-php -dextension=./modules/your_extension_name.so example.php | ||
$ git clone --recursive "https://github.com/colopl/php-extension_example" "extension_example" | ||
$ cd "extension_example/ext" | ||
$ phpize && ./configure --with-php-config="$(which php-config)" | ||
$ make -j"$(nproc)" && make test | ||
$ [sudo] make install | ||
``` | ||
|
||
#### Can I develop using something other than Visual Studio Code? | ||
### Development | ||
|
||
While it's not recommended, it's possible. You can using Docker Compose (or a alternative engine). | ||
このプロジェクトは [`zeriyoshi/pskel`](https://github.com/zeriyoshi/pskel) をベースに作成されています。基本的な使い方は Pskel と同様です。 | ||
|
||
### License | ||
### LICENSE | ||
|
||
PHP License 3.01 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
*.lo | ||
*.la | ||
*.dep | ||
.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~ | ||
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/**/*.php | ||
tests/**/*.exp | ||
tests/**/*.log | ||
tests/**/*.sh | ||
tests/**/*.db | ||
tests/**/*.mem | ||
tmp-php.ini |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
dnl config.m4 for extension_example extension | ||
|
||
PHP_ARG_WITH([extension_example], [for extension_example support], [AS_HELP_STRING([--with-extension_example]), [Include extension_example support]]) | ||
|
||
if test "${PHP_EXTENSION_EXAMPLE}" != "no"; then | ||
dnl check for required libraries and headers | ||
AC_CHECK_LIB([sodium], [sodium_version_string], [], [ | ||
AC_MSG_ERROR([Required library sodium not found. Please install libsodium library]) | ||
]) | ||
|
||
AC_CHECK_HEADER([sodium.h], [], [ | ||
AC_MSG_ERROR([Required header sodium.h not found. Please install libsodium library]) | ||
]) | ||
|
||
PHP_ADD_INCLUDE("/usr/local/include") | ||
PHP_ADD_LIBRARY_WITH_PATH(sodium, "/usr/local/lib", EXTENSION_EXAMPLE_SHARED_LIBADD) | ||
|
||
PHP_SUBST(EXTENSION_EXAMPLE_SHARED_LIBADD) | ||
PHP_SUBST(EXTENSION_EXAMPLE_LIBS) | ||
|
||
PHP_NEW_EXTENSION(extension_example, extension_example.c sodium.c, $ext_shared) | ||
fi |
Oops, something went wrong.