parent
063476360b
commit
87c328b3db
6 changed files with 298 additions and 71 deletions
@ -1,36 +0,0 @@ |
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index 897706d..b4d85ec 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -355,14 +355,6 @@ if (IS_WINDOWS)
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${PHP_SDK_DIR}/include;${MPDECIMAL_DIR}/libmpdec++"
|
||||
)
|
||||
|
||||
- # 复制 DLL 到输出目录
|
||||
- file(GLOB MPDEC_DLLS "${PHP_LIBRARY_DIR}/libmpdec-4.0.1.dll" "${PHP_LIBRARY_DIR}/libmpdec++-4.0.1.dll")
|
||||
- foreach(_dll ${MPDEC_DLLS})
|
||||
- add_custom_command(TARGET phpx POST_BUILD
|
||||
- COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_dll}" $<TARGET_FILE_DIR:phpx>
|
||||
- COMMENT "Copying ${_dll} to output"
|
||||
- )
|
||||
- endforeach()
|
||||
else()
|
||||
# Linux/macOS: 内置编译 mpdecimal + libmpdec++
|
||||
message(STATUS "Using bundled mpdecimal with uint128")
|
||||
@@ -419,6 +411,16 @@ set_target_properties(phpx PROPERTIES
|
||||
CLEAN_DIRECT_OUTPUT 1
|
||||
)
|
||||
|
||||
+if (IS_WINDOWS)
|
||||
+ # Register post-build commands only after the phpx target exists.
|
||||
+ file(GLOB MPDEC_DLLS "${PHP_LIBRARY_DIR}/libmpdec-4.0.1.dll" "${PHP_LIBRARY_DIR}/libmpdec++-4.0.1.dll")
|
||||
+ foreach(_dll ${MPDEC_DLLS})
|
||||
+ add_custom_command(TARGET phpx POST_BUILD
|
||||
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_dll}" $<TARGET_FILE_DIR:phpx>
|
||||
+ COMMENT "Copying ${_dll} to output")
|
||||
+ endforeach()
|
||||
+endif()
|
||||
+
|
||||
if (IS_WINDOWS)
|
||||
target_link_libraries(phpx PRIVATE
|
||||
${PHP_LIBRARY}
|
||||
@ -0,0 +1,30 @@ |
||||
#include <phpx.h> |
||||
#include <windows.h> |
||||
|
||||
using namespace php; |
||||
|
||||
Int php_windows_current_process_id() |
||||
{ |
||||
return static_cast<Int>(GetCurrentProcessId()); |
||||
} |
||||
|
||||
Bool php_windows_has_module_handle() |
||||
{ |
||||
return GetModuleHandleW(nullptr) != nullptr; |
||||
} |
||||
|
||||
Int php_windows_logical_processor_count() |
||||
{ |
||||
SYSTEM_INFO info{}; |
||||
GetNativeSystemInfo(&info); |
||||
return static_cast<Int>(info.dwNumberOfProcessors); |
||||
} |
||||
|
||||
Bool php_windows_php_is_zts() |
||||
{ |
||||
#ifdef ZTS |
||||
return true; |
||||
#else |
||||
return false; |
||||
#endif |
||||
} |
||||
@ -0,0 +1,10 @@ |
||||
<?php |
||||
|
||||
/** Windows API smoke-test declarations implemented by winapi.cc. */ |
||||
function windows_current_process_id(): int {} |
||||
|
||||
function windows_has_module_handle(): bool {} |
||||
|
||||
function windows_logical_processor_count(): int {} |
||||
|
||||
function windows_php_is_zts(): bool {} |
||||
@ -0,0 +1,34 @@ |
||||
<?php |
||||
|
||||
function requireWindowsCondition(bool $condition, string $message): void |
||||
{ |
||||
if (!$condition) { |
||||
throw new RuntimeException($message); |
||||
} |
||||
} |
||||
|
||||
function main(int $argc, array $argv): void |
||||
{ |
||||
requireWindowsCondition($argc === 2, 'Expected the thread-safety mode argument'); |
||||
|
||||
$expectedZts = $argv[1] === 'zts'; |
||||
requireWindowsCondition(PHP_OS_FAMILY === 'Windows', 'Expected PHP_OS_FAMILY=Windows'); |
||||
requireWindowsCondition(DIRECTORY_SEPARATOR === '\\', 'Expected the Windows directory separator'); |
||||
// PHP exposes PHP_ZTS as either an integer-like or boolean-like constant, |
||||
// depending on how the runtime constants were imported. Test its meaning, |
||||
// rather than its representation. |
||||
$runtimeZts = PHP_ZTS !== 0 && PHP_ZTS !== false; |
||||
requireWindowsCondition($runtimeZts === $expectedZts, 'PHP_ZTS does not match the CI matrix'); |
||||
requireWindowsCondition(windows_php_is_zts() === $expectedZts, 'The native ZTS macro does not match PHP_ZTS'); |
||||
requireWindowsCondition(windows_current_process_id() > 0, 'GetCurrentProcessId() failed'); |
||||
requireWindowsCondition(windows_has_module_handle(), 'GetModuleHandleW() failed'); |
||||
requireWindowsCondition(windows_logical_processor_count() > 0, 'GetNativeSystemInfo() returned no processors'); |
||||
|
||||
$path = sys_get_temp_dir() . DIRECTORY_SEPARATOR |
||||
. 'typephp-windows-smoke-' . windows_current_process_id() . '.txt'; |
||||
requireWindowsCondition(file_put_contents($path, 'windows-file-api') === 16, 'Windows file write failed'); |
||||
requireWindowsCondition(file_get_contents($path) === 'windows-file-api', 'Windows file read failed'); |
||||
requireWindowsCondition(unlink($path), 'Windows file cleanup failed'); |
||||
|
||||
echo 'windows-smoke-ok:', $expectedZts ? 'zts' : 'nts'; |
||||
} |
||||
@ -0,0 +1,9 @@ |
||||
name: windows-smoke |
||||
mode: bin |
||||
build-dir: build |
||||
output: windows_smoke |
||||
cxx-std: c++17 |
||||
|
||||
sources: |
||||
- main.php |
||||
- cpp-src |
||||
Loading…
Reference in new issue