From 8101ba079b8b358a015f4de9acbfc85d89c335da Mon Sep 17 00:00:00 2001 From: nsfisis Date: Wed, 25 Oct 2023 17:34:54 +0900 Subject: 作成 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- files/1 | 3 +++ files/2 | 3 +++ files/3 | 12 ++++++++++++ files/4 | 2 ++ files/5 | 9 +++++++++ files/6 | 9 +++++++++ files/php-wasm.c | 8 ++++++++ 7 files changed, 46 insertions(+) create mode 100644 files/1 create mode 100644 files/2 create mode 100644 files/3 create mode 100644 files/4 create mode 100644 files/5 create mode 100644 files/6 create mode 100644 files/php-wasm.c (limited to 'files') diff --git a/files/1 b/files/1 new file mode 100644 index 0000000..3139084 --- /dev/null +++ b/files/1 @@ -0,0 +1,3 @@ +$ ./buildconf +$ ./configure +$ make diff --git a/files/2 b/files/2 new file mode 100644 index 0000000..efc4a65 --- /dev/null +++ b/files/2 @@ -0,0 +1,3 @@ +$ ./buildconf +$ emconfigure ./configure +$ emmake make diff --git a/files/3 b/files/3 new file mode 100644 index 0000000..2488b0c --- /dev/null +++ b/files/3 @@ -0,0 +1,12 @@ +$ emconfigure configure \ + --disable-all \ + --disable-mbregex \ + --disable-fiber-asm \ + --disable-cli \ + --disable-cgi \ + --disable-phpdbg \ + --without-iconv \ + --without-libxml \ + --without-pcre-jit \ + --without-pdo-sqlite \ + --without-sqlite3 diff --git a/files/4 b/files/4 new file mode 100644 index 0000000..e534707 --- /dev/null +++ b/files/4 @@ -0,0 +1,2 @@ +$ EMCC_CFLAGS='-s ERROR_ON_UNDEFINED_SYMBOLS=0' \ + emmake make diff --git a/files/5 b/files/5 new file mode 100644 index 0000000..a8cfe55 --- /dev/null +++ b/files/5 @@ -0,0 +1,9 @@ +$ emcc \ + -s ERROR_ON_UNDEFINED_SYMBOLS=0 \ + -s ENVIRONMENT=node \ + -s INITIAL_MEMORY=16777216 \ + -s EXPORT_ES6=1 \ + -s INVOKE_RUN=0 \ + -s MODULARIZE=1 \ + -o php-wasm.js \ + php-wasm.o libphp.a diff --git a/files/6 b/files/6 new file mode 100644 index 0000000..27a5416 --- /dev/null +++ b/files/6 @@ -0,0 +1,9 @@ +import PHPWasm from './php-wasm.js' + +const { ccall } = await PHPWasm(); +const result = ccall( + 'php_wasm_run', + 'number', ['string'], + [`echo "Hello, World!";`], +); +console.log(`exit code: ${result}`); diff --git a/files/php-wasm.c b/files/php-wasm.c new file mode 100644 index 0000000..c124af0 --- /dev/null +++ b/files/php-wasm.c @@ -0,0 +1,8 @@ +#include +#include + +int EMSCRIPTEN_KEEPALIVE php_wasm_run(const char* code) { + zend_result result = + zend_eval_string_ex(code, NULL, "php.wasm code", 1); + return result == SUCCESS ? 0 : 1; +} -- cgit v1.2.3-70-g09d2