Skip to content

Commit 58b115d

Browse files
committed
Merge branch 'PHP-8.4'
2 parents 95262bc + 9a39c6b commit 58b115d

File tree

5 files changed

+55
-52
lines changed

5 files changed

+55
-52
lines changed

cmake/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ block()
8282
endforeach()
8383
endblock()
8484

85+
# Rebuild all targets as needed.
86+
if(NOT PHPSystem_EXECUTABLE)
87+
include(PHP/Rebuild)
88+
endif()
89+
8590
# Enable testing and configure test settings.
8691
include(cmake/Testing.cmake)
8792

cmake/cmake/Bootstrap.cmake

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,6 @@ include(cmake/Configuration.cmake)
4646
# Check requirements.
4747
include(cmake/Requirements.cmake)
4848

49-
# Rebuild all targets when needed.
50-
if(NOT PHPSystem_EXECUTABLE)
51-
include(PHP/Rebuild)
52-
endif()
53-
5449
message("
5550
Running system checks
5651
---------------------

cmake/cmake/modules/FindRE2C.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ re2c_target(
6262
* `<input>` - The re2c template file input. Relative source file path is
6363
interpreted as being relative to the current source directory.
6464
* `<output>` - The output file. Relative output file path is interpreted as
65-
being relative to the current source directory.
65+
being relative to the current binary directory.
6666
* `HEADER` - Generate a <header> file. Relative header file path is interpreted
6767
as being relative to the current binary directory.
6868
* `OPTIONS` - List of additional options to pass to re2c command-line tool.

cmake/cmake/modules/PHP/ConfigureFile.cmake

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,15 @@ php_configure_file(
1818
)
1919
```
2020
21-
* `VARIABLES`
21+
* `INPUT` or `CONTENT` specify the input template (either a file or a content
22+
string). Relative <template-file> is interpreted as being relative to the
23+
current source directory.
2224
23-
Pairs of variable names and values. Variable values support generator
24-
expressions.
25+
* `OUTPUT` specifies the output file. Relative file path is interpreted as being
26+
relative to the current binary directory.
27+
28+
* `VARIABLES` represent the pairs of variable names and values. Variable values
29+
support generator expressions.
2530
2631
The `$<INSTALL_PREFIX>` generator expression can be used in variable values,
2732
which is replaced with installation prefix either set via the
@@ -155,6 +160,12 @@ function(php_configure_file)
155160
"${CMAKE_CURRENT_FUNCTION} expects either INPUT or CONTENT keyword to "
156161
"specify template."
157162
)
163+
elseif(parsed_INPUT AND parsed_CONTENT)
164+
message(
165+
FATAL_ERROR
166+
"${CMAKE_CURRENT_FUNCTION} requires either INPUT or CONTENT keyword. To "
167+
"specify input template only one is required."
168+
)
158169
endif()
159170

160171
if(NOT parsed_OUTPUT)
Lines changed: 35 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
#[=============================================================================[
2-
Rebuild all project targets.
2+
Ensure all project targets are rebuilt as needed.
33
4-
When PHP is not found on the system, PHP generates some files during development
5-
using the php_cli target itself, which can bring cyclic dependencies among
6-
targets if custom commands would depend on the php_cli target. Although not a
7-
good practice, this helps bringing all targets to updated state.
4+
When PHP is not found on the system, the `php_cli` target is used to generate
5+
certain files during development. This can lead to cyclic dependencies among
6+
targets if custom commands depend on the `php_cli` target. While such automatic
7+
rebuilding is not considered good practice, it ensures that all targets are kept
8+
up to date.
9+
10+
TODO: This works only for a limited set of cases for now and will be refactored.
811
#]=============================================================================]
912

1013
include_guard(GLOBAL)
1114

1215
# Store a list of all targets inside the given <dir> into the <result> variable.
13-
function(_php_get_all_targets result dir)
16+
function(_php_rebuild_get_all_targets result dir)
1417
get_property(targets DIRECTORY ${dir} PROPERTY BUILDSYSTEM_TARGETS)
1518
get_property(subdirs DIRECTORY ${dir} PROPERTY SUBDIRECTORIES)
1619

@@ -22,43 +25,32 @@ function(_php_get_all_targets result dir)
2225
set(${result} ${targets} PARENT_SCOPE)
2326
endfunction()
2427

25-
# Ensure all project targets are rebuilt as needed.
26-
function(_php_rebuild)
27-
_php_get_all_targets(targets ${CMAKE_CURRENT_SOURCE_DIR})
28-
list(REMOVE_ITEM targets "php_rebuild")
29-
30-
add_custom_command(
31-
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/php_rebuild.timestamp
32-
COMMAND
33-
${CMAKE_COMMAND}
34-
-E cmake_echo_color --magenta --bold " Updating targets"
35-
COMMAND
36-
${CMAKE_COMMAND}
37-
-E touch ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/php_rebuild.timestamp
38-
COMMAND
39-
${CMAKE_COMMAND}
40-
--build . --target php_rebuild -j
41-
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
42-
DEPENDS ${targets}
43-
)
44-
45-
add_custom_target(
46-
php_update_targets ALL
47-
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/php_rebuild.timestamp
48-
)
28+
_php_rebuild_get_all_targets(targets ${CMAKE_CURRENT_SOURCE_DIR})
29+
30+
add_custom_command(
31+
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/php_rebuild.timestamp
32+
COMMAND
33+
${CMAKE_COMMAND}
34+
-E cmake_echo_color --magenta --bold "Updating targets"
35+
COMMAND
36+
${CMAKE_COMMAND}
37+
-E touch ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/php_rebuild.timestamp
38+
COMMAND
39+
${CMAKE_COMMAND}
40+
--build . --target php_rebuild -j
41+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
42+
DEPENDS ${targets}
43+
)
4944

50-
add_custom_target(
51-
php_rebuild
52-
COMMAND
53-
${CMAKE_COMMAND}
54-
-E rm -f ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/php_rebuild.timestamp
55-
DEPENDS ${targets}
56-
)
57-
endfunction()
45+
add_custom_target(
46+
php_rebuild_update_targets ALL
47+
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/php_rebuild.timestamp
48+
)
5849

59-
# Run at the end of the configuration.
60-
cmake_language(
61-
DEFER
62-
DIRECTORY ${PROJECT_SOURCE_DIR}
63-
CALL _php_rebuild
50+
add_custom_target(
51+
php_rebuild
52+
COMMAND
53+
${CMAKE_COMMAND}
54+
-E rm -f ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/php_rebuild.timestamp
55+
DEPENDS ${targets}
6456
)

0 commit comments

Comments
 (0)