Fix windows [2]

pull/41/head
韩天峰 4 weeks ago
parent 89e58350a8
commit efed2a7397
  1. 27
      phpunit/src/Platform/PlatformTest.php
  2. 13
      src/Build/SourcePipelineTrait.php
  3. 8
      src/Platform/Windows.php

@ -65,6 +65,33 @@ class PlatformTest extends TestCase
$this->assertStringContainsString('"php8ts.lib"', $flags); $this->assertStringContainsString('"php8ts.lib"', $flags);
} }
public function testWindowsMissingPhpxLibrariesAreFatalDiagnostics(): void
{
$root = sys_get_temp_dir() . '\\typephp-missing-phpx-' . bin2hex(random_bytes(6));
mkdir($root);
try {
$diagnostics = (new Windows())->getBuildLibraryWarnings($root, $root, 'bin');
$errors = array_column($diagnostics, 'error');
$this->assertContains(
'The PHPX import library was not found at: ' . $root . '\lib\phpx.lib',
$errors,
);
$this->assertContains(
'The PHPX runtime library `phpx.dll` was not found under: ' . $root,
$errors,
);
foreach ($diagnostics as $diagnostic) {
if (isset($diagnostic['error'])) {
$this->assertStringContainsString('Build PHPX first', $diagnostic['info']);
}
}
} finally {
rmdir($root);
}
}
/** /**
* 测试 Windows 路径规范化 * 测试 Windows 路径规范化
*/ */

@ -14,6 +14,7 @@ use TypePhp\Exception\Unsupported;
use TypePhp\Installer\LibPhpInstaller; use TypePhp\Installer\LibPhpInstaller;
use TypePhp\Installer\LibPhpxInstaller; use TypePhp\Installer\LibPhpxInstaller;
use TypePhp\Platform\Linux; use TypePhp\Platform\Linux;
use TypePhp\Platform\Windows;
trait SourcePipelineTrait trait SourcePipelineTrait
{ {
@ -98,9 +99,17 @@ trait SourcePipelineTrait
// shell_exec 和 define 已通过 php::fn:: 直接调用,无需动态符号表 // shell_exec 和 define 已通过 php::fn:: 直接调用,无需动态符号表
// 根据平台检查库文件(仅在构建二进制文件时需要) // Windows 的所有构建模式都依赖 PHPX 导入库和运行库。
if ($this->isBuildModeEmbed()) { // 其他平台仅在嵌入式构建模式下执行现有检查。
if ($this->isBuildModeEmbed() || $this->getPlatform() instanceof Windows) {
foreach ($this->getPlatform()->getBuildLibraryWarnings($this->getPhpDir(), $this->getPhpxDir(), $this->buildMode) as $message) { foreach ($this->getPlatform()->getBuildLibraryWarnings($this->getPhpDir(), $this->getPhpxDir(), $this->buildMode) as $message) {
if (!empty($message['error'])) {
$detail = $message['error'];
if (!empty($message['info'])) {
$detail .= "\n" . $message['info'];
}
$this->error($detail);
}
$this->climate->warning($message['warning']); $this->climate->warning($message['warning']);
if (!empty($message['info'])) { if (!empty($message['info'])) {
$this->climate->info($message['info']); $this->climate->info($message['info']);

@ -200,8 +200,8 @@ class Windows extends PlatformBase
$phpxLibPath = $phpxDir . '\lib\phpx.lib'; $phpxLibPath = $phpxDir . '\lib\phpx.lib';
if (!is_file($phpxLibPath)) { if (!is_file($phpxLibPath)) {
$warnings[] = [ $warnings[] = [
'warning' => 'The PHPX import library was not found at: ' . $phpxLibPath, 'error' => 'The PHPX import library was not found at: ' . $phpxLibPath,
'info' => 'Create the PHPX lib directory, reconfigure CMake if needed, then rebuild the phpx target', 'info' => 'Build PHPX first (for example, run `nmake phpx` in ' . $phpxDir . '\build)',
]; ];
} }
@ -219,8 +219,8 @@ class Windows extends PlatformBase
} }
if (!$hasPhpxDll) { if (!$hasPhpxDll) {
$warnings[] = [ $warnings[] = [
'warning' => 'The PHPX runtime library `phpx.dll` was not found under: ' . $phpxDir, 'error' => 'The PHPX runtime library `phpx.dll` was not found under: ' . $phpxDir,
'info' => 'Reconfigure CMake if needed, then rebuild the phpx target', 'info' => 'Build PHPX first (for example, run `nmake phpx` in ' . $phpxDir . '\build)',
]; ];
} }

Loading…
Cancel
Save