Skip to content

Commit 81356a2

Browse files
committed
Cleanup + remove vrzno for now
1 parent 7993e00 commit 81356a2

File tree

4 files changed

+40
-204
lines changed

4 files changed

+40
-204
lines changed

Makefile

+20-33
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ OPTIMIZE ?=-O1
1010
RELEASE_SUFFIX ?=
1111

1212
PHP_BRANCH ?=PHP-7.4
13-
VRZNO_BRANCH ?=DomAccess
1413
ICU_TAG ?=release-67-1
1514
LIBXML2_TAG ?=v2.9.10
1615
TIDYHTML_TAG ?=5.6.0
@@ -23,12 +22,13 @@ DOCKER_ENV=docker-compose -p phpwasm run --rm \
2322
-e PKG_CONFIG_PATH=${PKG_CONFIG_PATH} \
2423
-e LIBXML_LIBS="-L/src/lib/lib" \
2524
-e LIBXML_CFLAGS="-I/src/lib/include/libxml2" \
25+
-e SQLITE_CFLAGS="-I/src/third_party/sqlite-src" \
26+
-e SQLITE_LIBS="-L/src/third_party/sqlite-src" \
2627
-e PRELOAD_ASSETS='${PRELOAD_ASSETS}' \
2728
-e ENVIRONMENT=${ENVIRONMENT}
2829

2930
DOCKER_RUN =${DOCKER_ENV} emscripten-builder
30-
DOCKER_RUN_IN_PHP =${DOCKER_ENV} -w /src/third_party/php7.4-src/ emscripten-builder
31-
DOCKER_RUN_IN_ICU4C =${DOCKER_ENV} -w /src/third_party/libicu-src/icu4c/source/ emscripten-builder
31+
DOCKER_RUN_IN_PHP =${DOCKER_ENV} -w /src/third_party/php-src/ emscripten-builder
3232
DOCKER_RUN_IN_LIBXML =${DOCKER_ENV} -w /src/third_party/libxml2/ emscripten-builder
3333

3434
.PHONY: web all clean image js hooks push-image pull-image
@@ -39,33 +39,21 @@ all: php-web.wasm php-webview.wasm php-node.wasm php-shell.wasm php-worker.wasm
3939

4040
########### Collect & patch the source code. ###########
4141

42-
third_party/sqlite3.33-src/sqlite3.c:
42+
third_party/sqlite-src/sqlite3.c:
4343
wget https://sqlite.org/2020/sqlite-amalgamation-3330000.zip
4444
${DOCKER_RUN} unzip sqlite-amalgamation-3330000.zip
4545
${DOCKER_RUN} rm sqlite-amalgamation-3330000.zip
46-
${DOCKER_RUN} mv sqlite-amalgamation-3330000 third_party/sqlite3.33-src
46+
${DOCKER_RUN} mv sqlite-amalgamation-3330000 third_party/sqlite-src
4747

48-
third_party/php7.4-src/patched: third_party/sqlite3.33-src/sqlite3.c
49-
${DOCKER_RUN} git clone https://github.com/php/php-src.git third_party/php7.4-src \
48+
third_party/php-src/patched: third_party/sqlite-src/sqlite3.c
49+
${DOCKER_RUN} git clone https://github.com/php/php-src.git third_party/php-src \
5050
--branch ${PHP_BRANCH} \
5151
--single-branch \
5252
--depth 1
53-
${DOCKER_RUN} cp -v third_party/sqlite3.33-src/sqlite3.h third_party/php7.4-src/main/sqlite3.h
54-
${DOCKER_RUN} cp -v third_party/sqlite3.33-src/sqlite3.c third_party/php7.4-src/main/sqlite3.c
55-
${DOCKER_RUN} git apply --directory=third_party/php7.4-src --no-index patch/php7.4.patch
56-
${DOCKER_RUN} touch third_party/php7.4-src/patched
57-
58-
third_party/php7.4-src/ext/vrzno/vrzno.c: third_party/php7.4-src/patched
59-
${DOCKER_RUN} git clone https://github.com/seanmorris/vrzno.git third_party/php7.4-src/ext/vrzno \
60-
--branch ${VRZNO_BRANCH} \
61-
--single-branch \
62-
--depth 1
63-
64-
# third_party/libicu-src:
65-
# @ ${DOCKER_RUN} git clone https://github.com/unicode-org/icu.git third_party/libicu-src \
66-
# --branch ${ICU_TAG} \
67-
# --single-branch \
68-
# --depth 1;
53+
${DOCKER_RUN} cp -v third_party/sqlite-src/sqlite3.h third_party/php-src/main/sqlite3.h
54+
${DOCKER_RUN} cp -v third_party/sqlite-src/sqlite3.c third_party/php-src/main/sqlite3.c
55+
${DOCKER_RUN} git apply --directory=third_party/php-src --no-index patch/php7.4.patch
56+
${DOCKER_RUN} touch third_party/php-src/patched
6957

7058
third_party/libxml2/README:
7159
${DOCKER_RUN} git clone https://gitlab.gnome.org/GNOME/libxml2.git third_party/libxml2 \
@@ -77,12 +65,12 @@ third_party/libxml2/configure: third_party/libxml2/README
7765
${DOCKER_RUN_IN_LIBXML} ./autogen.sh
7866
${DOCKER_RUN_IN_LIBXML} emconfigure ./configure --prefix=/src/lib/ --enable-static --disable-shared \
7967
--with-python=no --with-threads=no
80-
${DOCKER_RUN_IN_LIBXML} emmake make
68+
${DOCKER_RUN_IN_LIBXML} emmake make -j6
8169
${DOCKER_RUN_IN_LIBXML} emmake make install
8270

8371
########### Build the objects. ###########
8472

85-
third_party/php7.4-src/configure: third_party/php7.4-src/ext/vrzno/vrzno.c third_party/php7.4-src/patched third_party/libxml2/configure
73+
third_party/php-src/configure: third_party/php-src/patched third_party/libxml2/configure
8674
${DOCKER_RUN_IN_PHP} bash -c "./buildconf --force && emconfigure ./configure \
8775
--enable-embed=static \
8876
--with-layout=GNU \
@@ -109,14 +97,13 @@ third_party/php7.4-src/configure: third_party/php7.4-src/ext/vrzno/vrzno.c third
10997
--enable-mbstring \
11098
--disable-mbregex \
11199
--enable-tokenizer \
112-
--enable-vrzno \
113100
--enable-simplexml \
114101
PKG_CONFIG_PATH=/src/lib/lib/pkgconfig \
115102
"
116103

117-
lib/libphp7.a: third_party/php7.4-src/configure third_party/php7.4-src/patched third_party/sqlite3.33-src/sqlite3.c
118-
${DOCKER_RUN_IN_PHP} emmake make
119-
${DOCKER_RUN} cp -v third_party/php7.4-src/.libs/libphp7.la third_party/php7.4-src/.libs/libphp7.a lib/
104+
lib/libphp7.a: third_party/php-src/configure third_party/php-src/patched third_party/sqlite-src/sqlite3.c
105+
${DOCKER_RUN_IN_PHP} emmake make -j6
106+
${DOCKER_RUN} cp -v third_party/php-src/.libs/libphp7.la third_party/php-src/.libs/libphp7.a lib/
120107

121108
lib/pib_eval.o: lib/libphp7.a source/pib_eval.c
122109
${DOCKER_RUN_IN_PHP} emcc ${OPTIMIZE} \
@@ -125,6 +112,7 @@ lib/pib_eval.o: lib/libphp7.a source/pib_eval.c
125112
-I main \
126113
-I TSRM/ \
127114
-I /src/third_party/libxml2 \
115+
-I /src/third_party/sqlite-src \
128116
-c \
129117
/src/source/pib_eval.c \
130118
-o /src/lib/pib_eval.o \
@@ -135,7 +123,7 @@ lib/pib_eval.o: lib/libphp7.a source/pib_eval.c
135123
FINAL_BUILD=${DOCKER_RUN_IN_PHP} emcc ${OPTIMIZE} \
136124
-o ../../build/php-${ENVIRONMENT}${RELEASE_SUFFIX}.js \
137125
--llvm-lto 2 \
138-
-s EXPORTED_FUNCTIONS='["_pib_init", "_pib_destroy", "_pib_run", "_pib_exec", "_pib_refresh", "_main", "_php_embed_init", "_php_embed_shutdown", "_php_embed_shutdown", "_zend_eval_string", "_exec_callback", "_del_callback"]' \
126+
-s EXPORTED_FUNCTIONS='["_pib_init", "_pib_destroy", "_pib_run", "_pib_exec", "_pib_refresh", "_main", "_php_embed_init", "_php_embed_shutdown", "_php_embed_shutdown", "_zend_eval_string"]' \
139127
-s EXTRA_EXPORTED_RUNTIME_METHODS='["ccall", "UTF8ToString", "lengthBytesUTF8"]' \
140128
-s ENVIRONMENT=${ENVIRONMENT} \
141129
-s FORCE_FILESYSTEM=1 \
@@ -174,10 +162,9 @@ php-webview.wasm: lib/libphp7.a lib/pib_eval.o
174162
clean:
175163
${DOCKER_RUN} rm -fv *.js *.wasm *.data
176164
${DOCKER_RUN} rm -rfv build/* lib/*
177-
${DOCKER_RUN} rm -rfv third_party/php7.4-src
165+
${DOCKER_RUN} rm -rfv third_party/php-src
178166
${DOCKER_RUN} rm -rfv third_party/libxml2
179-
${DOCKER_RUN} rm -rfv third_party/libicu-src
180-
${DOCKER_RUN} rm -rfv third_party/sqlite3.33-src
167+
${DOCKER_RUN} rm -rfv third_party/sqlite-src
181168

182169
hooks:
183170
@ git config core.hooksPath githooks

patch/php7.4.patch

+20-144
Original file line numberDiff line numberDiff line change
@@ -1,167 +1,43 @@
1-
diff --git a/ext/pdo/config.m4 b/ext/pdo/config.m4
2-
index 9b9a3e36..11481231 100644
3-
--- a/ext/pdo/config.m4
4-
+++ b/ext/pdo/config.m4
5-
@@ -4,15 +4,14 @@ PHP_ARG_ENABLE([pdo],
6-
[Disable PHP Data Objects support])],
7-
[yes])
1+
diff --git a/ext/pdo_sqlite/php_pdo_sqlite_int.h b/ext/pdo_sqlite/php_pdo_sqlite_int.h
2+
index c1d3a953..55c18393 100644
3+
--- a/ext/pdo_sqlite/php_pdo_sqlite_int.h
4+
+++ b/ext/pdo_sqlite/php_pdo_sqlite_int.h
5+
@@ -19,7 +19,7 @@
6+
#ifndef PHP_PDO_SQLITE_INT_H
7+
#define PHP_PDO_SQLITE_INT_H
88

9-
-if test "$PHP_PDO" != "no"; then
10-
-
11-
- dnl Make sure $PHP_PDO is 'yes' when it's not 'no' :)
12-
- PHP_PDO=yes
13-
+dnl Make sure $PHP_PDO is 'yes' when it's not 'no' :)
14-
+PHP_PDO=yes
15-
16-
+if test "$PHP_PDO" != "no"; then
17-
+ dnl so we always include the known-good working hack.
18-
PHP_NEW_EXTENSION(pdo, pdo.c pdo_dbh.c pdo_stmt.c pdo_sql_parser.c pdo_sqlstate.c, $ext_shared)
19-
PHP_ADD_EXTENSION_DEP(pdo, spl, true)
20-
PHP_INSTALL_HEADERS(ext/pdo, [php_pdo.h php_pdo_driver.h php_pdo_error.h])
21-
22-
- dnl so we always include the known-good working hack.
23-
PHP_ADD_MAKEFILE_FRAGMENT
24-
fi
25-
diff --git a/ext/pdo_sqlite/config.m4 b/ext/pdo_sqlite/config.m4
26-
index fbb3d05c..42a8fd47 100644
27-
--- a/ext/pdo_sqlite/config.m4
28-
+++ b/ext/pdo_sqlite/config.m4
29-
@@ -10,25 +10,7 @@ if test "$PHP_PDO_SQLITE" != "no"; then
30-
AC_MSG_ERROR([PDO is not enabled! Add --enable-pdo to your configure line.])
31-
fi
32-
33-
- PHP_CHECK_PDO_INCLUDES
34-
-
35-
- PKG_CHECK_MODULES([SQLITE], [sqlite3 > 3.7.4])
36-
-
37-
- PHP_EVAL_INCLINE($SQLITE_CFLAGS)
38-
- PHP_EVAL_LIBLINE($SQLITE_LIBS, PDO_SQLITE_SHARED_LIBADD)
39-
- AC_DEFINE(HAVE_PDO_SQLITELIB, 1, [Define to 1 if you have the pdo_sqlite extension enabled.])
40-
-
41-
- PHP_CHECK_LIBRARY(sqlite3, sqlite3_close_v2, [
42-
- AC_DEFINE(HAVE_SQLITE3_CLOSE_V2, 1, [have sqlite3_close_v2])
43-
- ], [], [$PDO_SQLITE_SHARED_LIBADD])
44-
-
45-
- PHP_CHECK_LIBRARY(sqlite3, sqlite3_column_table_name, [
46-
- AC_DEFINE(HAVE_SQLITE3_COLUMN_TABLE_NAME, 1, [have sqlite3_column_table_name])
47-
- ], [], [$PDO_SQLITE_SHARED_LIBADD])
48-
-
49-
- PHP_SUBST(PDO_SQLITE_SHARED_LIBADD)
50-
PHP_NEW_EXTENSION(pdo_sqlite, pdo_sqlite.c sqlite_driver.c sqlite_statement.c,
51-
- $ext_shared,,-I$pdo_cv_inc_path)
52-
-
53-
+ $ext_shared,,-I$pdo_cv_inc_path)
54-
PHP_ADD_EXTENSION_DEP(pdo_sqlite, pdo)
55-
fi
56-
diff --git a/ext/pdo_sqlite/pdo_sqlite.c b/ext/pdo_sqlite/pdo_sqlite.c
57-
index 5c2fd63c..e237600c 100644
58-
--- a/ext/pdo_sqlite/pdo_sqlite.c
59-
+++ b/ext/pdo_sqlite/pdo_sqlite.c
60-
@@ -23,8 +23,7 @@
61-
#include "php.h"
62-
#include "php_ini.h"
63-
#include "ext/standard/info.h"
64-
-#include "pdo/php_pdo.h"
65-
-#include "pdo/php_pdo_driver.h"
66-
+#include "../pdo/php_pdo_driver.h"
67-
#include "php_pdo_sqlite.h"
68-
#include "php_pdo_sqlite_int.h"
69-
#include "zend_exceptions.h"
70-
diff --git a/ext/pdo_sqlite/sqlite_driver.c b/ext/pdo_sqlite/sqlite_driver.c
71-
index 0595bd09..e2d6f6ec 100644
72-
--- a/ext/pdo_sqlite/sqlite_driver.c
73-
+++ b/ext/pdo_sqlite/sqlite_driver.c
74-
@@ -23,8 +23,7 @@
75-
#include "php.h"
76-
#include "php_ini.h"
77-
#include "ext/standard/info.h"
78-
-#include "pdo/php_pdo.h"
79-
-#include "pdo/php_pdo_driver.h"
80-
+#include "../pdo/php_pdo_driver.h"
81-
#include "php_pdo_sqlite.h"
82-
#include "php_pdo_sqlite_int.h"
83-
#include "zend_exceptions.h"
84-
diff --git a/ext/pdo_sqlite/sqlite_statement.c b/ext/pdo_sqlite/sqlite_statement.c
85-
index a8723da6..9f28701b 100644
86-
--- a/ext/pdo_sqlite/sqlite_statement.c
87-
+++ b/ext/pdo_sqlite/sqlite_statement.c
88-
@@ -23,8 +23,7 @@
89-
#include "php.h"
90-
#include "php_ini.h"
91-
#include "ext/standard/info.h"
92-
-#include "pdo/php_pdo.h"
93-
-#include "pdo/php_pdo_driver.h"
94-
+#include "../pdo/php_pdo_driver.h"
95-
#include "php_pdo_sqlite.h"
96-
#include "php_pdo_sqlite_int.h"
97-
98-
diff --git a/ext/sqlite3/config0.m4 b/ext/sqlite3/config0.m4
99-
index e83ec5f2..b94508f3 100644
100-
--- a/ext/sqlite3/config0.m4
101-
+++ b/ext/sqlite3/config0.m4
102-
@@ -5,26 +5,6 @@ PHP_ARG_WITH([sqlite3],
103-
[yes])
9+
-#include <sqlite3.h>
10+
+#include "main/sqlite3.h"
10411

105-
if test $PHP_SQLITE3 != "no"; then
106-
- PKG_CHECK_MODULES([SQLITE], [sqlite3 > 3.7.4])
107-
-
108-
- PHP_EVAL_INCLINE($SQLITE_CFLAGS)
109-
- PHP_EVAL_LIBLINE($SQLITE_LIBS, SQLITE3_SHARED_LIBADD)
110-
- AC_DEFINE(HAVE_SQLITE3, 1, [Define to 1 if you have the sqlite3 extension enabled.])
111-
-
112-
- PHP_CHECK_LIBRARY(sqlite3, sqlite3_errstr, [
113-
- AC_DEFINE(HAVE_SQLITE3_ERRSTR, 1, [have sqlite3_errstr function])
114-
- ], [], [$SQLITE3_SHARED_LIBADD])
115-
-
116-
- PHP_CHECK_LIBRARY(sqlite3, sqlite3_expanded_sql, [
117-
- AC_DEFINE(HAVE_SQLITE3_EXPANDED_SQL, 1, [have sqlite3_expanded_sql function])
118-
- ], [], [$SQLITE3_SHARED_LIBADD])
119-
-
120-
- PHP_CHECK_LIBRARY(sqlite3,sqlite3_load_extension,
121-
- [],
122-
- [AC_DEFINE(SQLITE_OMIT_LOAD_EXTENSION, 1, [have sqlite3 with extension support])],
123-
- [$SQLITE3_SHARED_LIBADD]
124-
- )
125-
-
126-
PHP_NEW_EXTENSION(sqlite3, sqlite3.c, $ext_shared,,-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
127-
PHP_SUBST(SQLITE3_SHARED_LIBADD)
128-
fi
12+
typedef struct {
13+
const char *file;
12914
diff --git a/ext/sqlite3/php_sqlite3_structs.h b/ext/sqlite3/php_sqlite3_structs.h
130-
index 3de8aac0..9b2af538 100644
15+
index 3de8aac0..401e93d7 100644
13116
--- a/ext/sqlite3/php_sqlite3_structs.h
13217
+++ b/ext/sqlite3/php_sqlite3_structs.h
133-
@@ -19,8 +19,6 @@
18+
@@ -19,7 +19,7 @@
13419
#ifndef PHP_SQLITE_STRUCTS_H
13520
#define PHP_SQLITE_STRUCTS_H
13621

13722
-#include <sqlite3.h>
138-
-
23+
+#include "main/sqlite3.h"
24+
13925
/* for backwards compatibility reasons */
14026
#ifndef SQLITE_OPEN_READONLY
141-
#define SQLITE_OPEN_READONLY 0x00000001
14227
diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c
143-
index f4d8066a..d5df7114 100644
28+
index f4d8066a..afb61446 100644
14429
--- a/ext/sqlite3/sqlite3.c
14530
+++ b/ext/sqlite3/sqlite3.c
146-
@@ -20,6 +20,9 @@
147-
#include "config.h"
148-
#endif
149-
150-
+#include "../../main/sqlite3.h"
151-
+#include "../../main/sqlite3.c"
152-
+
153-
#include "php.h"
154-
#include "php_ini.h"
155-
#include "ext/standard/info.h"
156-
@@ -27,8 +30,6 @@
31+
@@ -27,7 +27,8 @@
15732
#include "php_sqlite3_structs.h"
15833
#include "main/SAPI.h"
15934

16035
-#include <sqlite3.h>
161-
-
36+
+#include "main/sqlite3.c"
37+
+#include "main/sqlite3.h"
38+
16239
#include "zend_exceptions.h"
16340
#include "zend_interfaces.h"
164-
#include "SAPI.h"
16541
diff --git a/sapi/embed/php_embed.c b/sapi/embed/php_embed.c
16642
index 4c7dec6d..65762b8a 100644
16743
--- a/sapi/embed/php_embed.c

patch/sqlite3-wasm.patch

-11
This file was deleted.

source/pib_eval.c

-16
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
#include "zend_exceptions.h"
77
#include "zend_closures.h"
88

9-
#include "../php7.4-src/ext/vrzno/php_vrzno.h"
10-
119
int main() { return 0; }
1210

1311
int EMSCRIPTEN_KEEPALIVE pib_init()
@@ -95,17 +93,3 @@ int EMSCRIPTEN_KEEPALIVE pib_refresh()
9593

9694
return pib_init();
9795
}
98-
99-
int EMSCRIPTEN_KEEPALIVE exec_callback(zend_function *fptr)
100-
{
101-
int retVal = vrzno_exec_callback(fptr);
102-
103-
fflush(stdout);
104-
105-
return retVal;
106-
}
107-
108-
int EMSCRIPTEN_KEEPALIVE del_callback(zend_function *fptr)
109-
{
110-
return vrzno_del_callback(fptr);
111-
}

0 commit comments

Comments
 (0)