Skip to content

Commit 73e5f34

Browse files
committed
Merge branch 'PHP-8.3' into PHP-8.4
2 parents deb5514 + d782809 commit 73e5f34

File tree

9 files changed

+167
-74
lines changed

9 files changed

+167
-74
lines changed

bin/init.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ cmake_minimum_required(VERSION 3.25 FATAL_ERROR)
1919
# The PHP MAJOR.MINOR version currently in development (the master branch).
2020
set(PHP_DEVELOPMENT_VERSION "8.5")
2121

22-
# Check if git command is available.
23-
find_program(GIT_EXECUTABLE git DOC "Path to the Git executable")
22+
# Find Git.
23+
find_package(Git)
2424

25-
if(NOT GIT_EXECUTABLE)
25+
if(NOT GIT_FOUND)
2626
message(FATAL_ERROR "Git not found. Please install Git: https://git-scm.com")
2727
endif()
2828

bin/php.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,10 @@ if(NOT DOWNLOAD_TOOL)
160160
message(FATAL_ERROR "Please install curl or wget.")
161161
endif()
162162

163-
# Check if git command is available.
164-
find_program(GIT_EXECUTABLE git DOC "Path to the Git executable")
163+
# Find Git.
164+
find_package(Git)
165165

166-
if(NOT GIT_EXECUTABLE)
166+
if(NOT GIT_FOUND)
167167
message(FATAL_ERROR "Git not found. Please install Git: https://git-scm.com")
168168
endif()
169169

cmake/CMakeLists.txt

Lines changed: 4 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -83,58 +83,13 @@ block()
8383
endblock()
8484

8585
# Enable testing and configure test settings.
86-
if(TARGET php_cli)
87-
enable_testing()
88-
89-
block()
90-
include(ProcessorCount)
91-
processorcount(processors)
92-
93-
if(NOT processors EQUAL 0)
94-
set(parallel -j${processors})
95-
endif()
96-
97-
get_cmake_property(extensions PHP_EXTENSIONS)
98-
foreach(extension ${extensions})
99-
get_target_property(type php_${extension} TYPE)
100-
if(type MATCHES "^(MODULE|SHARED)_LIBRARY$")
101-
get_target_property(
102-
zend
103-
php_${extension}
104-
PHP_ZEND_EXTENSION
105-
)
106-
if(zend)
107-
list(APPEND options -d zend_extension=${extension})
108-
elseif(NOT extension STREQUAL "dl_test")
109-
list(APPEND options -d extension=${extension})
110-
endif()
111-
endif()
112-
endforeach()
113-
114-
add_test(
115-
NAME PHP
116-
COMMAND
117-
php_cli
118-
-n
119-
-d open_basedir=
120-
-d output_buffering=0
121-
-d memory_limit=-1
122-
run-tests.php
123-
-n
124-
-d extension_dir=${PHP_BINARY_DIR}/modules
125-
--show-diff
126-
${options}
127-
${parallel}
128-
-q
129-
WORKING_DIRECTORY ${PHP_SOURCE_DIR}
130-
)
131-
endblock()
132-
endif()
133-
134-
include(PHP/FeatureSummary)
86+
include(cmake/Testing.cmake)
13587

88+
# Enable and configure CPack module.
13689
include(cmake/CPack.cmake)
13790

91+
include(PHP/FeatureSummary)
92+
13893
message("
13994
License
14095
-------

cmake/Zend/CMakeLists.txt

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,8 @@ if(BISON_FOUND)
382382
zend_ini_parser
383383
zend_ini_parser.y
384384
${CMAKE_CURRENT_SOURCE_DIR}/zend_ini_parser.c
385-
COMPILE_FLAGS "-Wall -v -d"
385+
COMPILE_FLAGS "-Wall -d"
386+
VERBOSE REPORT_FILE ${CMAKE_CURRENT_BINARY_DIR}/zend_ini_parser.output
386387
DEFINES_FILE ${CMAKE_CURRENT_SOURCE_DIR}/zend_ini_parser.h
387388
)
388389

@@ -393,7 +394,8 @@ if(BISON_FOUND)
393394
zend_language_parser
394395
zend_language_parser.y
395396
${CMAKE_CURRENT_SOURCE_DIR}/zend_language_parser.c
396-
COMPILE_FLAGS "-Wall -v -d"
397+
COMPILE_FLAGS "-Wall -d"
398+
VERBOSE REPORT_FILE ${CMAKE_CURRENT_BINARY_DIR}/zend_language_parser.output
397399
DEFINES_FILE ${CMAKE_CURRENT_SOURCE_DIR}/zend_language_parser.h
398400
)
399401

@@ -404,33 +406,53 @@ if(BISON_FOUND)
404406
GENERATE
405407
OUTPUT CMakeFiles/PatchLanguageParser.cmake
406408
CONTENT [[
407-
file(READ "${SRC}/zend_language_parser.h" content)
409+
file(READ "${SOURCE_DIR}/zend_language_parser.h" content)
408410
string(
409411
REPLACE
410412
"int zendparse"
411413
"ZEND_API int zendparse"
412-
content
414+
content_2
413415
"${content}"
414416
)
415-
file(WRITE "${SRC}/zend_language_parser.h" "${content}")
416-
file(READ "${SRC}/zend_language_parser.c" content)
417+
if(
418+
NOT content MATCHES "ZEND_API int zendparse"
419+
AND NOT content STREQUAL "${content_2}"
420+
)
421+
execute_process(
422+
COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --blue --bold
423+
" [Zend] Patching Zend/zend_language_parser.h"
424+
)
425+
file(WRITE "${SOURCE_DIR}/zend_language_parser.h" "${content_2}")
426+
endif()
427+
428+
file(READ "${SOURCE_DIR}/zend_language_parser.c" content)
417429
string(
418430
REPLACE
419431
"int zendparse"
420432
"ZEND_API int zendparse"
421-
content
433+
content_2
422434
"${content}"
423435
)
424-
file(WRITE "${SRC}/zend_language_parser.c" "${content}")
436+
if(
437+
NOT content MATCHES "ZEND_API int zendparse"
438+
AND NOT content STREQUAL "${content_2}"
439+
)
440+
execute_process(
441+
COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --blue --bold
442+
" [Zend] Patching Zend/zend_language_parser.c"
443+
)
444+
file(WRITE "${SOURCE_DIR}/zend_language_parser.c" "${content_2}")
445+
endif()
425446
]]
426447
)
448+
427449
add_custom_target(
428450
zend_patch_language_parser
429451
COMMAND ${CMAKE_COMMAND}
430-
-D SRC=${CMAKE_CURRENT_SOURCE_DIR}
452+
-D SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}
431453
-P "CMakeFiles/PatchLanguageParser.cmake"
432454
DEPENDS ${BISON_zend_language_parser_OUTPUTS}
433-
COMMENT "[Zend] Patching Zend language parser files"
455+
VERBATIM
434456
)
435457

436458
add_dependencies(zend zend_patch_language_parser)

cmake/cmake/Testing.cmake

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#[=============================================================================[
2+
Enable and configure tests.
3+
#]=============================================================================]
4+
5+
if(NOT TARGET php_cli)
6+
return()
7+
endif()
8+
9+
enable_testing()
10+
11+
block()
12+
include(ProcessorCount)
13+
processorcount(processors)
14+
15+
if(NOT processors EQUAL 0)
16+
set(parallel -j${processors})
17+
endif()
18+
19+
get_cmake_property(extensions PHP_EXTENSIONS)
20+
foreach(extension ${extensions})
21+
get_target_property(type php_${extension} TYPE)
22+
if(type MATCHES "^(MODULE|SHARED)_LIBRARY$")
23+
get_target_property(isZendExtension php_${extension} PHP_ZEND_EXTENSION)
24+
if(isZendExtension)
25+
list(APPEND options -d zend_extension=${extension})
26+
elseif(NOT extension STREQUAL "dl_test")
27+
list(APPEND options -d extension=${extension})
28+
endif()
29+
endif()
30+
endforeach()
31+
32+
add_test(
33+
NAME PHP
34+
COMMAND
35+
php_cli
36+
-n
37+
-d open_basedir=
38+
-d output_buffering=0
39+
-d memory_limit=-1
40+
run-tests.php
41+
-n
42+
-d extension_dir=${PHP_BINARY_DIR}/modules
43+
--show-diff
44+
${options}
45+
${parallel}
46+
-q
47+
WORKING_DIRECTORY ${PHP_SOURCE_DIR}
48+
)
49+
endblock()

cmake/ext/tokenizer/CMakeLists.txt

Lines changed: 70 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,82 @@ elseif(CMAKE_CROSSCOMPILING AND CMAKE_CROSSCOMPILING_EMULATOR)
4646
endif()
4747

4848
if(PHP_EXECUTABLE)
49+
# Patch tokenizer_data_gen.php to generate output only when needed.
50+
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/tokenizer_data_gen.php" content)
51+
string(
52+
REPLACE
53+
[[$infile = __DIR__ . '/../../Zend/zend_language_parser.y';]]
54+
"$infile = '${PHP_SOURCE_DIR}/Zend/zend_language_parser.y';"
55+
content
56+
"${content}"
57+
)
58+
string(
59+
REPLACE
60+
[[$outfile_stub = __DIR__ . '/tokenizer_data.stub.php';]]
61+
"$outfile_stub = '${CMAKE_CURRENT_SOURCE_DIR}/tokenizer_data.stub.php';"
62+
content
63+
"${content}"
64+
)
65+
string(
66+
REPLACE
67+
[[$outfile_c = __DIR__ . '/tokenizer_data.c';]]
68+
"$outfile_c = '${CMAKE_CURRENT_SOURCE_DIR}/tokenizer_data.c';"
69+
content
70+
"${content}"
71+
)
72+
string(
73+
REPLACE
74+
[[file_put_contents($outfile_stub, $result);
75+
76+
echo "Wrote $outfile_stub\n";]]
77+
[[
78+
if (file_exists($outfile_stub)) {
79+
$currentContent = file_get_contents($outfile_stub);
80+
}
81+
if ($currentContent !== $result) {
82+
file_put_contents($outfile_stub, $result);
83+
echo "Wrote $outfile_stub\n";
84+
}
85+
]]
86+
content
87+
"${content}"
88+
)
89+
string(
90+
REPLACE
91+
[[file_put_contents($outfile_c, $result);
92+
93+
echo "Wrote $outfile_c\n";]]
94+
[[
95+
$currentContent = '';
96+
if (file_exists($outfile_c)) {
97+
$currentContent = file_get_contents($outfile_c);
98+
}
99+
if ($currentContent !== $result) {
100+
file_put_contents($outfile_c, $result);
101+
echo "Wrote $outfile_c\n";
102+
}
103+
]]
104+
content
105+
"${content}"
106+
)
107+
file(
108+
WRITE
109+
"${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/tokenizer_data_gen.php"
110+
"${content}"
111+
)
112+
49113
add_custom_command(
50-
OUTPUT php_tokenizer_data
51-
COMMAND ${PHP_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tokenizer_data_gen.php
114+
OUTPUT
115+
php_tokenizer_data
116+
COMMAND
117+
${PHP_EXECUTABLE}
118+
${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/tokenizer_data_gen.php
52119
DEPENDS
53-
php_cli
120+
${CMAKE_CURRENT_SOURCE_DIR}/tokenizer_data_gen.php
54121
${PHP_SOURCE_DIR}/Zend/zend_language_parser.y
55122
COMMENT "[ext/tokenizer] Regenerating ext/tokenizer/tokenizer_data.c"
56123
VERBATIM
57124
)
58-
59125
add_custom_target(php_tokenizer_generate_data ALL DEPENDS php_tokenizer_data)
60-
61126
set_property(SOURCE php_tokenizer_data PROPERTY SYMBOLIC TRUE)
62127
endif()

cmake/pear/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ endif()
5959

6060
message(
6161
DEPRECATION
62-
"The 'PHP_PEAR' option is deprecated and will be removed in future PHP "
63-
"versions. PEAR can also be installed manually from the pear.php.net website."
62+
"The 'PHP_PEAR' option is deprecated as of PHP 7.4 and will be removed in "
63+
"future PHP versions. PEAR can also be installed manually from the "
64+
"pear.php.net website."
6465
)
6566

6667
# Check PEAR dependencies.

cmake/sapi/phpdbg/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ if(BISON_FOUND)
189189
php_phpdbg_parser
190190
phpdbg_parser.y
191191
${CMAKE_CURRENT_SOURCE_DIR}/phpdbg_parser.c
192-
COMPILE_FLAGS "-Wall -v -d"
192+
COMPILE_FLAGS "-Wall -d"
193+
VERBOSE REPORT_FILE ${CMAKE_CURRENT_BINARY_DIR}/phpdbg_parser.output
193194
DEFINES_FILE ${CMAKE_CURRENT_SOURCE_DIR}/phpdbg_parser.h
194195
)
195196

patches/8.5/cmake.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ index e691bd3964..fff9fc09d0 100644
118118
+CMakeScripts/
119119
+/TryRunResults.cmake
120120
diff --git a/run-tests.php b/run-tests.php
121-
index 0dee752d32..b6eb316fa0 100755
121+
index bd03a7f882..9b950396f8 100755
122122
--- a/run-tests.php
123123
+++ b/run-tests.php
124124
@@ -865,10 +865,12 @@ function write_information(array $user_tests, $phpdbg): void

0 commit comments

Comments
 (0)