-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcmake.patch
213 lines (199 loc) · 7.11 KB
/
cmake.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
From: Peter Kokot <peterkokot@gmail.com>
Subject: Add CMake changes for PHP-8.5 branch
- EditorConfig adjustments for code style support in editors and IDEs
- CMake build system files added to .gitignore
- CMake added to run-tests.php for info about failing tests and checks
- CMake-related modifications added to ext/skeleton template directory
and ext/ext_skel.php script
---
.editorconfig | 2 +-
.gitignore | 50 ++++++++++++++++++++++++++++++++++++++
ext/ext_skel.php | 7 ++++++
ext/skeleton/.gitignore.in | 23 ++++++++++++++++++
run-tests.php | 24 +++++++++++++-----
5 files changed, 99 insertions(+), 7 deletions(-)
diff --git a/.editorconfig b/.editorconfig
index 19be96087d9..58a83dfb688 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -17,7 +17,7 @@ indent_style = tab
indent_size = 4
indent_style = space
-[*.{ac,m4,sh,yml}]
+[{CMakeLists.{txt,txt.in},*.{ac,cmake,cmake.in,json,m4,sh,yml}}]
indent_size = 2
indent_style = space
diff --git a/.gitignore b/.gitignore
index 91120a5fa6b..1af59c1eaac 100644
--- a/.gitignore
+++ b/.gitignore
@@ -155,6 +155,7 @@ php
# ------------------------------------------------------------------------------
/ext/json/json_parser.tab.h
/ext/json/json_parser.tab.c
+/ext/json/json_parser.output
/sapi/phpdbg/phpdbg_parser.c
/sapi/phpdbg/phpdbg_parser.h
/sapi/phpdbg/phpdbg_parser.output
@@ -298,9 +299,58 @@ tmp-php.ini
# ------------------------------------------------------------------------------
/ext/standard/tests/helpers/bad_cmd.exe
+# ------------------------------------------------------------------------------
+# CMake-based build system files
+# ------------------------------------------------------------------------------
+cmake_install.cmake
+CMakeCache.txt
+CMakeFiles/
+
+# Generated by FetchContent
+/_deps/
+
+# Graphviz generated files
+/*.dependers
+/*.dot
+
+# Generated by the Ninja build system
+/.ninja*
+/build.ninja
+
+# Local user presets
+/CMakeUserPresets.json
+
+# Generated when CMAKE_EXPORT_COMPILE_COMMANDS is enabled
+/compile-commands.json
+
+# Generated by ctest
+/CTestTestfile.cmake
+/Testing/
+
+# CMake script profiling data output (--profiling-output <path>)
+/profile.json
+
+# Generated by QT Creator
+CMakeLists.txt.user
+
+# Generated by XCode
+CMakeScripts/
+
+# Generated by cmake --install
+/install_manifest.txt
+
+# Generated by cmake when cross-compiling if missing cache variables are found
+/TryRunResults.cmake
+
+# pkg-config .pc files
+/sapi/embed/php-embed.pc
+/scripts/php.pc
+
# ------------------------------------------------------------------------------
# Special cases to invert previous ignore patterns
# ------------------------------------------------------------------------------
+!**/cmake/config.h.in
+!**/cmake/modules/
!/ext/bcmath/libbcmath/src/config.h
!/ext/fileinfo/libmagic/config.h
!/ext/fileinfo/libmagic.patch
diff --git a/ext/ext_skel.php b/ext/ext_skel.php
index cd82abb3469..19f55f46734 100755
--- a/ext/ext_skel.php
+++ b/ext/ext_skel.php
@@ -289,11 +289,18 @@ function copy_config_scripts() {
$files[] = 'config.w32';
}
+ $files[] = 'CMakeLists.txt';
+ $files[] = 'cmake/config.h.in';
$files[] = '.gitignore';
foreach($files as $config_script) {
$new_config_script = $options['dir'] . $options['ext'] . DIRECTORY_SEPARATOR . $config_script;
+ $directory = dirname($new_config_script);
+ if (!is_dir($directory) && !mkdir($directory, 0777, true)) {
+ error('Unable to create ' . $directory . ' directory in the output directory');
+ }
+
if (!copy($options['skel'] . $config_script . '.in', $new_config_script)) {
error('Unable to copy config script: ' . $config_script);
}
diff --git a/ext/skeleton/.gitignore.in b/ext/skeleton/.gitignore.in
index e691bd3964b..191fcd70eb5 100644
--- a/ext/skeleton/.gitignore.in
+++ b/ext/skeleton/.gitignore.in
@@ -45,3 +45,26 @@ tests/**/*.db
tests/**/*.mem
tmp-php.ini
*~
+
+# ------------------------------------------------------------------------------
+# CMake-based build system files
+# ------------------------------------------------------------------------------
+!**/cmake/config.h.in
+!**/cmake/modules/
+/_deps/
+/.ninja*
+/*.dependers
+/*.dot
+/build.ninja
+/CMakeUserPresets.json
+/compile-commands.json
+/CTestTestfile.cmake
+/install_manifest.txt
+/profile.json
+/Testing/
+/TryRunResults.cmake
+cmake_install.cmake
+CMakeCache.txt
+CMakeFiles/
+CMakeLists.txt.user
+CMakeScripts/
diff --git a/run-tests.php b/run-tests.php
index 0db6937c7a8..47118f6a3ff 100755
--- a/run-tests.php
+++ b/run-tests.php
@@ -848,10 +848,12 @@ function write_information(array $user_tests, $phpdbg): void
<?php
$exts = get_loaded_extensions();
$ext_dir = ini_get('extension_dir');
- foreach (scandir($ext_dir) as $file) {
- if (preg_match('/^(?:php_)?([_a-zA-Z0-9]+)\.(?:so|dll)$/', $file, $matches)) {
- if (!extension_loaded($matches[1])) {
- $exts[] = $matches[1];
+ if (is_dir($ext_dir)) {
+ foreach (scandir($ext_dir) as $file) {
+ if (preg_match('/^(?:php_)?([_a-zA-Z0-9]+)\.(?:so|dll)$/', $file, $matches)) {
+ if (!extension_loaded($matches[1])) {
+ $exts[] = $matches[1];
+ }
}
}
}
@@ -940,7 +942,7 @@ function save_results(string $output_file, bool $prompt_to_save_results): void
$failed_tests_data .= "\n" . $sep . 'BUILD ENVIRONMENT' . $sep;
$failed_tests_data .= "OS:\n" . PHP_OS . " - " . php_uname() . "\n\n";
- $ldd = $autoconf = $sys_libtool = $libtool = $compiler = 'N/A';
+ $ldd = $autoconf = $sys_libtool = $libtool = $compiler = $cmake = 'N/A';
if (!IS_WINDOWS) {
/* If PHP_AUTOCONF is set, use it; otherwise, use 'autoconf'. */
@@ -951,7 +953,9 @@ function save_results(string $output_file, bool $prompt_to_save_results): void
}
/* Always use the generated libtool - Mac OSX uses 'glibtool' */
- $libtool = shell_exec(INIT_DIR . '/libtool --version');
+ if (file_exists(INIT_DIR . '/libtool')) {
+ $libtool = shell_exec(INIT_DIR . '/libtool --version');
+ }
/* Use shtool to find out if there is glibtool present (MacOSX) */
$sys_libtool_path = shell_exec(__DIR__ . '/build/shtool path glibtool libtool');
@@ -973,9 +977,17 @@ function save_results(string $output_file, bool $prompt_to_save_results): void
}
$ldd = shell_exec("ldd $php 2>/dev/null");
+
+ /** If PHP_CMAKE is set, use it; otherwise, use 'cmake'. */
+ if (getenv('PHP_CMAKE')) {
+ $cmake = shell_exec(getenv('PHP_CMAKE') . ' --version');
+ } else {
+ $cmake = shell_exec('cmake --version');
+ }
}
$failed_tests_data .= "Autoconf:\n$autoconf\n";
+ $failed_tests_data .= "CMake:\n$cmake\n";
$failed_tests_data .= "Bundled Libtool:\n$libtool\n";
$failed_tests_data .= "System Libtool:\n$sys_libtool\n";
$failed_tests_data .= "Compiler:\n$compiler\n";