Skip to content

Commit cdc207b

Browse files
committed
require cli sapi instead?
1 parent 059fe19 commit cdc207b

File tree

10 files changed

+49
-50
lines changed

10 files changed

+49
-50
lines changed

sapi/cli/cli_win32_main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#define PHP_CLI_WIN32_NO_CONSOLE 1
2+
#include "php_cli_main.c"

sapi/cli/config.m4

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ PHP_ARG_ENABLE([cli],
55
[yes],
66
[no])
77

8-
dnl Embed SAPI builds cli files too, so run the feature checks
9-
if test "$PHP_CLI" != "no" || test "$PHP_EMBED" != "no"; then
8+
if test "$PHP_CLI" != "no"; then
109
AC_CHECK_FUNCS([setproctitle])
1110

1211
AC_CHECK_HEADERS([sys/pstat.h])
@@ -24,9 +23,7 @@ if test "$PHP_CLI" != "no" || test "$PHP_EMBED" != "no"; then
2423
[php_cv_var_PS_STRINGS=no])])
2524
AS_VAR_IF([php_cv_var_PS_STRINGS], [yes],
2625
[AC_DEFINE([HAVE_PS_STRINGS], [], [Define if the PS_STRINGS exists.])])
27-
fi
2826

29-
if test "$PHP_CLI" != "no"; then
3027
PHP_ADD_MAKEFILE_FRAGMENT([$abs_srcdir/sapi/cli/Makefile.frag])
3128

3229
dnl Set filename.
@@ -35,7 +32,7 @@ if test "$PHP_CLI" != "no"; then
3532
dnl Select SAPI.
3633
PHP_SELECT_SAPI([cli],
3734
[program],
38-
[php_cli.c php_http_parser.c php_cli_server.c ps_title.c php_cli_process_title.c],
35+
[php_cli.c php_cli_main.c php_http_parser.c php_cli_server.c ps_title.c php_cli_process_title.c],
3936
[-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1])
4037

4138
AS_CASE([$host_alias],

sapi/cli/config.w32

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ARG_ENABLE('cli', 'Build CLI version of PHP', 'yes');
44
ARG_ENABLE('cli-win32', 'Build console-less CLI version of PHP', 'no');
55

66
if (PHP_CLI == "yes") {
7-
SAPI('cli', 'php_cli.c php_http_parser.c php_cli_server.c', 'php.exe', '/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1');
7+
SAPI('cli', 'php_cli.c php_cli_main.c php_http_parser.c php_cli_server.c', 'php.exe', '/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1');
88
ADD_SOURCES(configure_module_dirname, 'php_cli_process_title.c ps_title.c', 'cli');
99
ADD_FLAG("LIBS_CLI", "ws2_32.lib");
1010
ADD_FLAG("LIBS_CLI", "shell32.lib");
@@ -18,7 +18,7 @@ if (PHP_CLI == "yes") {
1818
}
1919

2020
if (PHP_CLI_WIN32 == "yes") {
21-
SAPI('cli_win32', 'cli_win32.c', 'php-win.exe', '/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1');
21+
SAPI('cli_win32', 'cli_win32.c cli_win32_main.c', 'php-win.exe', '/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1');
2222
ADD_SOURCES(configure_module_dirname, ' php_cli_process_title.c ps_title.c', 'cli_win32', undefined, PHP_CLI == "yes");
2323
ADD_FLAG("LDFLAGS_CLI_WIN32", "/stack:67108864");
2424
ADD_FLAG("LIBS_CLI_WIN32", "shell32.lib");

sapi/cli/php_cli.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1388,19 +1388,3 @@ PHP_CLI_API int do_php_cli(int argc, char *argv[])
13881388
return exit_status;
13891389
}
13901390
/* }}} */
1391-
1392-
/* {{{ main */
1393-
#ifndef PHP_EMBED_SAPI
1394-
# ifdef PHP_CLI_WIN32_NO_CONSOLE
1395-
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
1396-
{
1397-
exit(do_php_cli(__argc, __argv));
1398-
}
1399-
# else
1400-
int main(int argc, char *argv[])
1401-
{
1402-
exit(do_php_cli(argc, argv));
1403-
}
1404-
# endif
1405-
#endif /* PHP_EMBED_SAPI */
1406-
/* }}} */

sapi/cli/php_cli_main.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
+----------------------------------------------------------------------+
3+
| Copyright (c) The PHP Group |
4+
+----------------------------------------------------------------------+
5+
| This source file is subject to version 3.01 of the PHP license, |
6+
| that is bundled with this package in the file LICENSE, and is |
7+
| available through the world-wide-web at the following url: |
8+
| https://www.php.net/license/3_01.txt |
9+
| If you did not receive a copy of the PHP license and are unable to |
10+
| obtain it through the world-wide-web, please send a note to |
11+
| license@php.net so we can mail you a copy immediately. |
12+
+----------------------------------------------------------------------+
13+
*/
14+
15+
#include "cli.h"
16+
#include <stdlib.h>
17+
18+
#ifdef PHP_WIN32
19+
#include <windows.h>
20+
#endif
21+
22+
/* {{{ main */
23+
#ifdef PHP_CLI_WIN32_NO_CONSOLE
24+
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
25+
{
26+
exit(do_php_cli(__argc, __argv));
27+
}
28+
#else
29+
int main(int argc, char *argv[])
30+
{
31+
exit(do_php_cli(argc, argv));
32+
}
33+
#endif
34+
/* }}} */

sapi/embed/Makefile.frag

Lines changed: 0 additions & 18 deletions
This file was deleted.

sapi/embed/config.m4

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,8 @@ if test "$PHP_EMBED" != "no"; then
2626
[php_embed.c],
2727
[-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1])
2828
29-
dnl Include CLI sources in embed SAPI so do_php_cli() is available
30-
PHP_ADD_BUILD_DIR([sapi/embed/cli])
31-
PHP_ADD_MAKEFILE_FRAGMENT([$abs_srcdir/sapi/embed/Makefile.frag])
32-
PHP_SAPI_OBJS="$PHP_SAPI_OBJS sapi/embed/cli/php_cli.lo sapi/embed/cli/php_http_parser.lo sapi/embed/cli/php_cli_server.lo sapi/embed/cli/ps_title.lo sapi/embed/cli/php_cli_process_title.lo"
29+
dnl Reuse CLI object files (excluding php_cli_main.lo) for do_php_cli()
30+
PHP_SAPI_OBJS="$PHP_SAPI_OBJS sapi/cli/php_cli.lo sapi/cli/php_http_parser.lo sapi/cli/php_cli_server.lo sapi/cli/ps_title.lo sapi/cli/php_cli_process_title.lo"
3331
3432
PHP_INSTALL_HEADERS([sapi/embed], [php_embed.h])
3533
])

sapi/embed/config.w32

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ var PHP_EMBED_PGO = false;
66

77
if (PHP_EMBED != "no") {
88
SAPI('embed', 'php_embed.c', 'php' + PHP_VERSION + 'embed.lib', '/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1');
9-
ADD_SOURCES("sapi/cli", "php_cli.c php_http_parser.c php_cli_server.c ps_title.c php_cli_process_title.c", "embed", "/DPHP_EMBED_SAPI");
9+
ADD_SOURCES("sapi/cli", "php_cli.c php_http_parser.c php_cli_server.c ps_title.c php_cli_process_title.c", "embed");
1010
ADD_FLAG("LIBS_EMBED", "ws2_32.lib");
1111
ADD_FLAG("LIBS_EMBED", "shell32.lib");
1212
PHP_INSTALL_HEADERS("sapi/embed", "php_embed.h");

sapi/embed/config0.m4

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
dnl Check if embed SAPI is enable before running CLI SAPI feature checks, they are required for embed's do_php_cli too
21
PHP_ARG_ENABLE([embed],,
32
[AS_HELP_STRING([[--enable-embed[=TYPE]]],
43
[Enable building of embedded SAPI library TYPE is either
54
'shared' or 'static'. [TYPE=shared]])],
65
[no],
76
[no])
7+
8+
dnl Embed SAPI reuses CLI object files, so force CLI on.
9+
if test "$PHP_EMBED" != "no"; then
10+
enable_cli=yes
11+
fi

sapi/embed/php_embed.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <main/php_variables.h>
2424
#include <main/php_ini.h>
2525
#include <zend_ini.h>
26+
#include <sapi/cli/cli.h>
2627

2728
#define PHP_EMBED_START_BLOCK(x,y) { \
2829
php_embed_init(x, y); \
@@ -49,9 +50,6 @@ BEGIN_EXTERN_C()
4950
EMBED_SAPI_API int php_embed_init(int argc, char **argv);
5051
EMBED_SAPI_API void php_embed_shutdown(void);
5152
extern EMBED_SAPI_API sapi_module_struct php_embed_module;
52-
53-
#define HAVE_EMBED_CLI 1
54-
EMBED_SAPI_API int do_php_cli(int argc, char *argv[]);
5553
END_EXTERN_C()
5654

5755

0 commit comments

Comments
 (0)