Skip to content

Commit 83e71a8

Browse files
committed
Merge branch 'PHP-8.4'
2 parents 3f975af + cd6159c commit 83e71a8

File tree

7 files changed

+110
-3
lines changed

7 files changed

+110
-3
lines changed

bin/check-cmake.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ function checkAll(array $options): int
708708
{
709709
$status = 0;
710710

711-
output($options['script'] . ': Working tree ' . realpath($options['path']));
711+
output($options['script'] . ': Working tree ' . $options['path']);
712712

713713
output($options['script'] . ': Checking CMake modules');
714714
$allCMakeFiles = getAllCMakeFiles($options['path']);

bin/init.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ Usage:
1616

1717
cmake_minimum_required(VERSION 3.25)
1818

19+
if(NOT CMAKE_SCRIPT_MODE_FILE)
20+
message(FATAL_ERROR "This is a command-line script.")
21+
endif()
22+
1923
# The PHP MAJOR.MINOR version currently in development (the master branch).
2024
set(PHP_DEVELOPMENT_VERSION "8.5")
2125

bin/php.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ Usage examples:
3535

3636
cmake_minimum_required(VERSION 3.25)
3737

38+
if(NOT CMAKE_SCRIPT_MODE_FILE)
39+
message(FATAL_ERROR "This is a command-line script.")
40+
endif()
41+
3842
################################################################################
3943
# Set default variables.
4044
################################################################################
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/usr/bin/env -S cmake -P
2+
#
3+
# Command-line script to regenerate the ext/standard/credits_*.h headers from
4+
# CREDITS files.
5+
#
6+
# Run with: `cmake -P cmake/scripts/GenerateCredits.cmake`
7+
8+
if(NOT CMAKE_SCRIPT_MODE_FILE)
9+
message(FATAL_ERROR "This is a command-line script.")
10+
endif()
11+
12+
set(PHP_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../../)
13+
14+
if(NOT EXISTS ${PHP_SOURCE_DIR}/ext/standard/credits.h)
15+
message(FATAL_ERROR "This script should be run inside the php-src repository")
16+
endif()
17+
18+
set(template [[
19+
/*
20+
DO NOT EDIT THIS FILE!
21+
22+
it has been automatically created by scripts/dev/credits from
23+
the information found in the various ext/.../CREDITS and
24+
sapi/.../CREDITS files
25+
26+
if you want to change an entry you have to edit the appropriate
27+
CREDITS file instead
28+
29+
*/
30+
31+
]])
32+
33+
file(GLOB credits ${PHP_SOURCE_DIR}/*/*/CREDITS)
34+
35+
foreach(credit ${credits})
36+
cmake_path(GET credit PARENT_PATH parent)
37+
cmake_path(GET parent PARENT_PATH parent)
38+
cmake_path(GET parent FILENAME dir)
39+
40+
list(APPEND dirs ${dir})
41+
file(STRINGS ${credit} lines ENCODING UTF-8)
42+
list(GET lines 0 title)
43+
list(GET lines 1 authors)
44+
list(APPEND ${dir}_credits "CREDIT_LINE(\"${title}\", \"${authors}\")")
45+
endforeach()
46+
47+
list(REMOVE_DUPLICATES dirs)
48+
49+
foreach(dir ${dirs})
50+
list(SORT ${dir}_credits CASE INSENSITIVE)
51+
list(JOIN ${dir}_credits ";\n" credits)
52+
set(content "${template}${credits};\n")
53+
54+
if(EXISTS ${PHP_SOURCE_DIR}/ext/standard/credits_${dir}.h)
55+
file(READ ${PHP_SOURCE_DIR}/ext/standard/credits_${dir}.h current)
56+
if(content STREQUAL "${current}")
57+
continue()
58+
endif()
59+
endif()
60+
61+
file(WRITE ${PHP_SOURCE_DIR}/ext/standard/credits_${dir}.h "${content}")
62+
message("Updated ext/standard/credits_${dir}.h")
63+
endforeach()

cmake/ext/standard/CMakeLists.txt

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,41 @@ check_symbol_exists(
439439
HAVE_ELF_AUX_INFO
440440
)
441441

442+
################################################################################
443+
# Regenerate credits_*.h files.
444+
################################################################################
445+
446+
block()
447+
file(GLOB credits ${PHP_SOURCE_DIR}/*/*/CREDITS)
448+
449+
# The CODEGEN keyword adds the custom command to a global 'codegen' target.
450+
set(codegen)
451+
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.31)
452+
set(codegen CODEGEN)
453+
endif()
454+
455+
add_custom_command(
456+
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/php_credits.timestamp
457+
DEPENDS ${credits}
458+
COMMAND
459+
${CMAKE_COMMAND}
460+
-E touch ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/php_credits.timestamp
461+
COMMAND
462+
${CMAKE_COMMAND} -P ${PHP_SOURCE_DIR}/cmake/scripts/GenerateCredits.cmake
463+
COMMENT "Regenerating ext/standard/credits_*.h"
464+
VERBATIM
465+
${codegen}
466+
)
467+
468+
add_custom_target(
469+
php_standard_credits
470+
DEPENDS
471+
${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/php_credits.timestamp
472+
)
473+
474+
add_dependencies(php_standard php_standard_credits)
475+
endblock()
476+
442477
# TODO: Check whether to enable the chroot() function by checking which SAPI is
443478
# being built.
444479
set(ENABLE_CHROOT_FUNC 1 CACHE INTERNAL "Whether to enable chroot() function")

cmake/scripts/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ block()
2121
)
2222
endblock()
2323

24+
# The php-config and phpize scripts.
2425
block()
2526
find_program(
2627
SED_EXECUTABLE
@@ -46,7 +47,6 @@ block()
4647
endif()
4748
endif()
4849

49-
# The php-config script.
5050
message(STATUS "Creating scripts/php-config")
5151

5252
# Replace the upstream php-config script hardcoded php include directory to a
@@ -100,7 +100,6 @@ block()
100100
RENAME ${PHP_PROGRAM_PREFIX}php-config${PHP_PROGRAM_SUFFIX}
101101
)
102102

103-
# The phpize script.
104103
message(STATUS "Creating scripts/phpize")
105104

106105
# Replace the upstream phpize script hardcoded php include directory to a

docs/cmake.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,8 @@ version available on the operating system.
277277
* `INSTALL_PREFIX` generator expression in `install(CODE)`
278278
* 3.29
279279
* `CMAKE_LINKER_TYPE`
280+
* 3.31
281+
* `add_custom_command()` keyword `CODEGEN`
280282

281283
Currently, the CMake minimum version is set to **3.25** without looking at CMake
282284
available version on the current systems out there. This will be updated more

0 commit comments

Comments
 (0)