Skip to content

Commit 12d0995

Browse files
committed
Sync CS and changes for other pull requests
- checker script now works also for nested namespaces if such complexity will be used by anychance for some module - some absolute paths normalized - some CS nits fixed and synced - patches updated - added re2c patch
1 parent 1d48fac commit 12d0995

16 files changed

+537
-31
lines changed

bin/check-cmake.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -457,12 +457,19 @@ function checkModules(Iterator $modules, Iterator $allCMakeFiles): int
457457
$status = 0;
458458

459459
foreach ($modules as $module) {
460-
$moduleName = $module->getBasename('.cmake');
461-
$prefix = pathinfo(dirname($module->getRealPath()), PATHINFO_FILENAME);
462-
$prefix = (1 === preg_match('/cmake|modules/', $prefix)) ? '' : $prefix . '/';
463-
$moduleNameEscaped = str_replace('/', '\/', $prefix . $moduleName);
464-
$moduleBasename = $module->getBasename();
465-
$moduleBasenameEscaped = str_replace('.', '\.', $moduleBasename);
460+
$namespace = '';
461+
$parent = dirname($module->getRealPath());
462+
$prefix = pathinfo($parent, PATHINFO_FILENAME);
463+
$counter = 0;
464+
while ($counter < 10 && 0 === preg_match('/cmake|modules/', $prefix)) {
465+
$namespace = $prefix . '/' . $namespace;
466+
$parent = dirname($parent);
467+
$prefix = pathinfo($parent, PATHINFO_FILENAME);
468+
++$counter;
469+
}
470+
471+
$moduleNameEscaped = str_replace('/', '\/', $namespace . $module->getBasename('.cmake'));
472+
$moduleBasenameEscaped = str_replace('.', '\.', $module->getBasename());
466473

467474
$found = false;
468475
foreach ($allCMakeFiles as $file) {

cmake/cmake/modules/FindDTrace.cmake

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,17 +162,32 @@ function(dtrace_target)
162162
endif()
163163

164164
if(NOT IS_ABSOLUTE "${parsed_INPUT}")
165-
set(parsed_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/${parsed_INPUT})
165+
cmake_path(
166+
ABSOLUTE_PATH
167+
parsed_INPUT
168+
BASE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
169+
NORMALIZE
170+
)
166171
endif()
167172

168173
if(NOT IS_ABSOLUTE "${parsed_HEADER}")
169-
set(parsed_HEADER ${CMAKE_CURRENT_BINARY_DIR}/${parsed_HEADER})
174+
cmake_path(
175+
ABSOLUTE_PATH
176+
parsed_HEADER
177+
BASE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
178+
NORMALIZE
179+
)
170180
endif()
171181

172182
set(sources "")
173183
foreach(source IN LISTS parsed_SOURCES)
174184
if(NOT IS_ABSOLUTE ${source})
175-
set(source ${CMAKE_CURRENT_SOURCE_DIR}/${source})
185+
cmake_path(
186+
ABSOLUTE_PATH
187+
source
188+
BASE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
189+
NORMALIZE
190+
)
176191
endif()
177192
list(APPEND sources ${source})
178193
endforeach()

cmake/cmake/modules/FindKerberos.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Module defines the following `IMPORTED` target(s):
2525
* `Kerberos_INCLUDE_DIR` - Directory containing package library headers.
2626
* `Kerberos_LIBRARY` - The path to the package library.
2727
* `Kerberos_EXECUTABLE` - Path to the Kerberos command-line helper configuration
28-
script, if found.
28+
script.
2929
* `Kerberos_GSSAPI_INCLUDE_DIR` -Directory containing GSSAPI library headers.
3030
* `Kerberos_GSSAPI_LIBRARY` - The path to the GSSAPI library.
3131
#]=============================================================================]
@@ -78,7 +78,7 @@ endif()
7878
find_program(
7979
Kerberos_EXECUTABLE
8080
NAMES krb5-config
81-
DOC "Path to the Kerberos command-line helper configuration script, if found."
81+
DOC "Path to the Kerberos command-line helper configuration script"
8282
)
8383

8484
# Get version.

cmake/cmake/modules/PHP/ConfigureFile.cmake

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,11 @@ function(php_configure_file)
192192
if(parsed_INPUT)
193193
set(___phpConfigureFileTemplate "${parsed_INPUT}")
194194
if(NOT IS_ABSOLUTE "${___phpConfigureFileTemplate}")
195-
set(
195+
cmake_path(
196+
ABSOLUTE_PATH
196197
___phpConfigureFileTemplate
197-
"${CMAKE_CURRENT_SOURCE_DIR}/${___phpConfigureFileTemplate}"
198+
BASE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
199+
NORMALIZE
198200
)
199201
endif()
200202
else()
@@ -208,9 +210,11 @@ function(php_configure_file)
208210

209211
set(___phpConfigureFileOutput "${parsed_OUTPUT}")
210212
if(NOT IS_ABSOLUTE "${___phpConfigureFileOutput}")
211-
set(
213+
cmake_path(
214+
ABSOLUTE_PATH
212215
___phpConfigureFileOutput
213-
"${CMAKE_CURRENT_BINARY_DIR}/${___phpConfigureFileOutput}"
216+
BASE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
217+
NORMALIZE
214218
)
215219
endif()
216220

cmake/cmake/modules/PHP/PkgConfigGenerator.cmake

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,22 @@ function(pkgconfig_generate_pc)
161161

162162
set(template "${ARGV0}")
163163
if(NOT IS_ABSOLUTE "${template}")
164-
set(template "${CMAKE_CURRENT_SOURCE_DIR}/${template}")
164+
cmake_path(
165+
ABSOLUTE_PATH
166+
template
167+
BASE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
168+
NORMALIZE
169+
)
165170
endif()
166171

167172
set(output "${ARGV1}")
168173
if(NOT IS_ABSOLUTE "${output}")
169-
set(output "${CMAKE_CURRENT_BINARY_DIR}/${output}")
174+
cmake_path(
175+
ABSOLUTE_PATH
176+
output
177+
BASE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
178+
NORMALIZE
179+
)
170180
endif()
171181

172182
file(

cmake/cmake/scripts/GenerateCredits.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ endif()
1212
set(PHP_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../../)
1313

1414
if(NOT EXISTS ${PHP_SOURCE_DIR}/ext/standard/credits.h)
15-
message(FATAL_ERROR "This script should be run inside the php-src repository")
15+
message(FATAL_ERROR "This script should be run in the php-src repository.")
1616
endif()
1717

1818
set(template [[
@@ -31,7 +31,7 @@ set(template [[
3131
]])
3232

3333
file(GLOB credits ${PHP_SOURCE_DIR}/*/*/CREDITS)
34-
# Case-sensitive filtering, GLOB on macOS/Windows is case-insensitive.
34+
# Case-sensitive filtering, GLOB on macOS/Windows/Cygwin is case-insensitive.
3535
list(FILTER credits INCLUDE REGEX ".*CREDITS$")
3636

3737
foreach(credit IN LISTS credits)

cmake/ext/standard/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ check_symbol_exists(
494494

495495
block()
496496
file(GLOB credits ${PHP_SOURCE_DIR}/*/*/CREDITS)
497-
# Case-sensitive filtering, GLOB on macOS/Windows is case-insensitive.
497+
# Case-sensitive filtering, GLOB on macOS/Windows/Cygwin is case-insensitive.
498498
list(FILTER credits INCLUDE REGEX ".*CREDITS$")
499499

500500
# The CODEGEN keyword adds the custom command to a global 'codegen' target.

cmake/pear/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ php_set(
6363
TYPE PATH
6464
IF PHP_PEAR
6565
VALUE "${CMAKE_INSTALL_DATADIR}/pear"
66-
DOC "The PEAR installation directory."
66+
DOC "The PEAR installation directory"
6767
)
6868
mark_as_advanced(PHP_PEAR_DIR)
6969

@@ -77,7 +77,7 @@ php_set(
7777
TYPE PATH
7878
IF PHP_PEAR
7979
VALUE "${tmpDir}"
80-
DOC "The PEAR temporary directory. Default: ${tmpDir}."
80+
DOC "The PEAR temporary directory. Default: ${tmpDir}"
8181
)
8282
mark_as_advanced(PHP_PEAR_TEMP_DIR)
8383

patches/8.3/cmake.patch

Lines changed: 139 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,147 @@
11
From: Peter Kokot <[email protected]>
22
Subject: Add CMake changes for PHP-8.3 branch
33

4-
* CMake added to run-tests.php for info about failing tests and checks
4+
- EditorConfig adjustments for code style support in editors and IDEs
5+
- CMake build system files added to .gitignore
6+
- CMake added to run-tests.php for info about failing tests and checks
7+
- CMake-related modifications added to ext/skeleton template directory
8+
and ext/ext_skel.php script
59
---
6-
run-tests.php | 24 ++++++++++++++++++------
7-
1 file changed, 18 insertions(+), 6 deletions(-)
10+
.editorconfig | 2 +-
11+
.gitignore | 50 ++++++++++++++++++++++++++++++++++++++
12+
ext/ext_skel.php | 2 ++
13+
ext/skeleton/.gitignore.in | 23 ++++++++++++++++++
14+
run-tests.php | 24 +++++++++++++-----
15+
5 files changed, 94 insertions(+), 7 deletions(-)
816

17+
diff --git a/.editorconfig b/.editorconfig
18+
index 7911bf8490..1d9b530947 100644
19+
--- a/.editorconfig
20+
+++ b/.editorconfig
21+
@@ -17,7 +17,7 @@ indent_style = tab
22+
indent_size = 4
23+
indent_style = space
24+
25+
-[*.{ac,m4,sh,yml}]
26+
+[{CMakeLists.{txt,txt.in},*.{ac,cmake,cmake.in,json,m4,sh,yml}}]
27+
indent_size = 2
28+
indent_style = space
29+
30+
diff --git a/.gitignore b/.gitignore
31+
index 449963153f..913ed3d96d 100644
32+
--- a/.gitignore
33+
+++ b/.gitignore
34+
@@ -153,6 +153,7 @@ php
35+
# ------------------------------------------------------------------------------
36+
/ext/json/json_parser.tab.h
37+
/ext/json/json_parser.tab.c
38+
+/ext/json/json_parser.output
39+
/sapi/phpdbg/phpdbg_parser.c
40+
/sapi/phpdbg/phpdbg_parser.h
41+
/sapi/phpdbg/phpdbg_parser.output
42+
@@ -291,9 +292,58 @@ tmp-php.ini
43+
/junit.out.xml
44+
/.ccache/
45+
46+
+# ------------------------------------------------------------------------------
47+
+# CMake-based build system files
48+
+# ------------------------------------------------------------------------------
49+
+cmake_install.cmake
50+
+CMakeCache.txt
51+
+CMakeFiles/
52+
+
53+
+# Generated by FetchContent
54+
+/_deps/
55+
+
56+
+# Graphviz generated files
57+
+/*.dependers
58+
+/*.dot
59+
+
60+
+# Generated by the Ninja build system
61+
+/.ninja*
62+
+/build.ninja
63+
+
64+
+# Local user presets
65+
+/CMakeUserPresets.json
66+
+
67+
+# Generated when CMAKE_EXPORT_COMPILE_COMMANDS is enabled
68+
+/compile-commands.json
69+
+
70+
+# Generated by ctest
71+
+/CTestTestfile.cmake
72+
+/Testing/
73+
+
74+
+# CMake script profiling data output (--profiling-output <path>)
75+
+/profile.json
76+
+
77+
+# Generated by QT Creator
78+
+CMakeLists.txt.user
79+
+
80+
+# Generated by XCode
81+
+CMakeScripts/
82+
+
83+
+# Generated by cmake --install
84+
+/install_manifest.txt
85+
+
86+
+# Generated by cmake when cross-compiling if missing cache variables are found
87+
+/TryRunResults.cmake
88+
+
89+
+# pkg-config .pc files
90+
+/sapi/embed/php-embed.pc
91+
+/scripts/php.pc
92+
+
93+
# ------------------------------------------------------------------------------
94+
# Special cases to invert previous ignore patterns
95+
# ------------------------------------------------------------------------------
96+
+!**/cmake/config.h.in
97+
+!**/cmake/modules/
98+
!/ext/bcmath/libbcmath/src/config.h
99+
!/ext/fileinfo/libmagic/config.h
100+
!/ext/fileinfo/libmagic.patch
101+
diff --git a/ext/ext_skel.php b/ext/ext_skel.php
102+
index ae7a3a987c..a9e0dd1b51 100755
103+
--- a/ext/ext_skel.php
104+
+++ b/ext/ext_skel.php
105+
@@ -302,6 +302,8 @@ function copy_config_scripts() {
106+
$files[] = 'config.w32';
107+
}
108+
109+
+ $files[] = 'CMakeLists.txt';
110+
+ $files[] = 'cmake/config.h.in';
111+
$files[] = '.gitignore';
112+
113+
foreach($files as $config_script) {
114+
diff --git a/ext/skeleton/.gitignore.in b/ext/skeleton/.gitignore.in
115+
index ae434fef97..87545d9162 100644
116+
--- a/ext/skeleton/.gitignore.in
117+
+++ b/ext/skeleton/.gitignore.in
118+
@@ -39,3 +39,26 @@ tests/**/*.sh
119+
tests/**/*.db
120+
tests/**/*.mem
121+
tmp-php.ini
122+
+
123+
+# ------------------------------------------------------------------------------
124+
+# CMake-based build system files
125+
+# ------------------------------------------------------------------------------
126+
+!**/cmake/config.h.in
127+
+!**/cmake/modules/
128+
+/_deps/
129+
+/.ninja*
130+
+/*.dependers
131+
+/*.dot
132+
+/build.ninja
133+
+/CMakeUserPresets.json
134+
+/compile-commands.json
135+
+/CTestTestfile.cmake
136+
+/install_manifest.txt
137+
+/profile.json
138+
+/Testing/
139+
+/TryRunResults.cmake
140+
+cmake_install.cmake
141+
+CMakeCache.txt
142+
+CMakeFiles/
143+
+CMakeLists.txt.user
144+
+CMakeScripts/
9145
diff --git a/run-tests.php b/run-tests.php
10146
index d51ab99a20..9211cbb3e2 100755
11147
--- a/run-tests.php

patches/8.3/php-config.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ index 61ee5c1675..1a8d67a783 100644
5959

6060
dnl
6161
diff --git a/configure.ac b/configure.ac
62-
index b6ec8b2be1..85849f73dc 100644
62+
index ee039a0bad..42fa6c9458 100644
6363
--- a/configure.ac
6464
+++ b/configure.ac
6565
@@ -1480,6 +1480,9 @@ exec_prefix=$old_exec_prefix

0 commit comments

Comments
 (0)