Skip to content
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

Experiment feature #801

Merged
merged 12 commits into from
Oct 6, 2024
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -341,4 +341,5 @@ ext/ssh2/
LICENSE
swoole-cli-*
php-cli-*

php-fpm-*
!sapi/patches
3 changes: 3 additions & 0 deletions docs/upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ php sync-source-code.php
php sync-source-code.php --action run


./bin/runtime/php -c ./bin/runtime/php.ini sync-source-code.php
./bin/runtime/php -c ./bin/runtime/php.ini sync-source-code.php --action run

```

## 目录说明
Expand Down
19 changes: 2 additions & 17 deletions ext/readline/readline_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -744,24 +744,9 @@ typedef cli_shell_callbacks_t *(__cdecl *get_cli_shell_callbacks)(void);
} while(0)

#else
/*
#ifdef COMPILE_DL_READLINE
This dlsym() is always used as even the CGI SAPI is linked against "CLI"-only
extensions. If that is being changed dlsym() should only be used when building
this extension sharedto offer compatibility.
*/
#define GET_SHELL_CB(cb) \
do { \
(cb) = NULL; \
cli_shell_callbacks_t *(*get_callbacks)(void); \
get_callbacks = dlsym(RTLD_DEFAULT, "php_cli_get_shell_callbacks"); \
if (get_callbacks) { \
(cb) = get_callbacks(); \
} \
} while(0)
/*#else

#define GET_SHELL_CB(cb) (cb) = php_cli_get_shell_callbacks()
#endif*/

#endif

PHP_MINIT_FUNCTION(cli_readline)
Expand Down
43 changes: 43 additions & 0 deletions sapi/patches/0001-fix-readline-not-work.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
From 2a15bd4c55d8d2f46d2e17d4f7e642a2387d6e01 Mon Sep 17 00:00:00 2001
From: jingjingxyk <zonghengbaihe521@qq.com>
Date: Sun, 6 Oct 2024 18:59:27 +0800
Subject: [PATCH] fix readline not work

---
ext/readline/readline_cli.c | 19 ++-----------------
1 file changed, 2 insertions(+), 17 deletions(-)

diff --git a/ext/readline/readline_cli.c b/ext/readline/readline_cli.c
index 8bf5d23df..0adecf42a 100644
--- a/ext/readline/readline_cli.c
+++ b/ext/readline/readline_cli.c
@@ -744,24 +744,9 @@ typedef cli_shell_callbacks_t *(__cdecl *get_cli_shell_callbacks)(void);
} while(0)

#else
-/*
-#ifdef COMPILE_DL_READLINE
-This dlsym() is always used as even the CGI SAPI is linked against "CLI"-only
-extensions. If that is being changed dlsym() should only be used when building
-this extension sharedto offer compatibility.
-*/
-#define GET_SHELL_CB(cb) \
- do { \
- (cb) = NULL; \
- cli_shell_callbacks_t *(*get_callbacks)(void); \
- get_callbacks = dlsym(RTLD_DEFAULT, "php_cli_get_shell_callbacks"); \
- if (get_callbacks) { \
- (cb) = get_callbacks(); \
- } \
- } while(0)
-/*#else
+
#define GET_SHELL_CB(cb) (cb) = php_cli_get_shell_callbacks()
-#endif*/
+
#endif

PHP_MINIT_FUNCTION(cli_readline)
--
2.46.2

26 changes: 17 additions & 9 deletions sync-source-code.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@

sed -i.backup 's/ext_shared=yes/ext_shared=no/g' ext/opcache/config.m4
sed -i.backup 's/shared,,/$ext_shared,,/g' ext/opcache/config.m4
# sed -i 's/-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1/-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -DPHP_ENABLE_OPCACHE/g' ext/opcache/config.m4
# echo '#include "php.h"\n\nextern zend_module_entry opcache_module_entry;\n#define phpext_opcache_ptr &opcache_module_entry\n' > ext/opcache/php_opcache.h
cat > ext/opcache/php_opcache.h <<PHP_OPCACHE_H_EOF
#include "php.h"
Expand Down Expand Up @@ -140,8 +141,8 @@
# build
cp -rf $SRC/build/ ./build

# TSRM
cp -rf $SRC/TSRM/ ./TSRM
# TSRM (more info: https://github.com/swoole/swoole-cli/commit/172c76445a631abb1b32fc2a721a2dd9d5a5fc0d)
# cp -rf $SRC/TSRM/ ./TSRM

cp -f $SRC/configure.ac ./configure.ac
cp -f $SRC/buildconf ./buildconf
Expand All @@ -153,22 +154,29 @@
# 在sed命令中,常见的需要转义的字符有:\、/、$、&、.、*、[、]等
# 反斜杠、正斜杠、美元符号、引用符号、点号、星号、方括号等

test -f main/main.c.backup && rm -f main/main.c.backup
test -f ext/opcache/config.m4.backup && rm -f ext/opcache/config.m4.backup


# fpm
cp -rf $SRC/sapi/fpm/fpm ./sapi/cli/
# fpm [Need to manually compare fpm_main.c]
# cp -rf $SRC/sapi/fpm/fpm ./sapi/cli/
sed -i.backup 's/int main(int argc, char \*argv\[\])/int fpm_main(int argc, char \*argv\[\])/g' ./sapi/cli/fpm/fpm_main.c
sed -i.backup 's/{'-', 0, NULL}/{'P', 0, "fpm"},\n {'-', 0, NULL}/g' ./sapi/cli/fpm/fpm_main.c


# sed -i.backup "s/{'-', 0, NULL}/{'P', 0, \"fpm\"},\n {'-', 0, NULL}/g" ./sapi/cli/fpm/fpm_main.c

# cli
cp -rf $SRC/sapi/cli/ps_title.c ./sapi/cli
cp -rf $SRC/sapi/cli/generate_mime_type_map.php ./sapi/cli
cp -rf $SRC/sapi/cli/php.1.in ./sapi/cli


# clean file
test -f main/main.c.backup && rm -f main/main.c.backup
test -f ext/opcache/config.m4.backup && rm -f ext/opcache/config.m4.backup
test -f sapi/cli/fpm/fpm_main.c.backup && rm -f sapi/cli/fpm/fpm_main.c.backup

# ext readline_cli patch
cp -f sapi/patches/0001-fix-readline-not-work.patch 0001-fix-readline-not-work.patch
{ git apply --check 0001-fix-readline-not-work.patch ; } && { git apply 0001-fix-readline-not-work.patch ; }


EOF;

echo PHP_EOL;
Expand Down
Loading