From 954c0f399b9cc7aea959728448f3a6149da9311a Mon Sep 17 00:00:00 2001 From: rango Date: Sat, 9 May 2026 14:35:17 +0800 Subject: [PATCH] =?UTF-8?q?feat(build):=20=E6=9B=B4=E6=96=B0=20Windows=20?= =?UTF-8?q?=E6=89=93=E5=8C=85=E8=84=9A=E6=9C=AC=E4=BB=A5=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E6=96=B0=E7=A4=BA=E4=BE=8B=E5=92=8C=E9=85=8D=E7=BD=AE=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在打包列表中添加 composer.json 文件 - 增加对 tetris-win32 示例项目的复制支持 - 实现文件扩展名排除功能以过滤 .obj 目标文件 - 更新 copyDirectory 函数以支持扩展名过滤参数 - 修改打包清单显示以反映新增的配置文件和示例 - 将版本号从 1035 更新至 1049 --- package-on-windows.php | 32 ++++++++++++++++++++++++++++---- version.txt | 2 +- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/package-on-windows.php b/package-on-windows.php index 91926519..67fe151a 100644 --- a/package-on-windows.php +++ b/package-on-windows.php @@ -80,6 +80,7 @@ $requiredFiles = [ $compilerExe, 'README.md', 'LICENSE.md', + 'composer.json', 'examples/hello.php', ]; @@ -191,6 +192,7 @@ mkdir("{$topLevelDir}/examples", 0755, true); $projectFiles = [ 'README.md' => '.', 'LICENSE.md' => '.', + 'composer.json' => '.', 'examples/hello.php' => 'examples', ]; @@ -207,11 +209,22 @@ foreach ($projectFiles as $src => $destDir) { $win32HelloDir = 'examples/win32-hello'; if (is_dir($win32HelloDir)) { echo " 复制: {$win32HelloDir} -> examples/win32-hello/\n"; - copyDirectory($win32HelloDir, "{$topLevelDir}/examples/win32-hello"); + // 排除 .obj 文件(MSVC 目标文件) + copyDirectory($win32HelloDir, "{$topLevelDir}/examples/win32-hello", [], null, ['obj']); } else { echo " 警告: {$win32HelloDir} 目录不存在\n"; } +// 复制 tetris-win32 示例目录(俄罗斯方块游戏) +$tetrisWin32Dir = 'examples/tetris-win32'; +if (is_dir($tetrisWin32Dir)) { + echo " 复制: {$tetrisWin32Dir} -> examples/tetris-win32/\n"; + // 排除 .obj 文件(MSVC 目标文件) + copyDirectory($tetrisWin32Dir, "{$topLevelDir}/examples/tetris-win32", [], null, ['obj']); +} else { + echo " 警告: {$tetrisWin32Dir} 目录不存在\n"; +} + echo "项目文件复制完成\n\n"; // ==================== 6.3. 复制 vendor 目录 ==================== @@ -405,9 +418,11 @@ echo " - phpx/lib/ (PHPX 库文件)\n"; echo " - phpx/src/misc/ (PHPX 辅助工具和头文件)\n"; echo " - PHP 运行时环境 (完整目录结构)\n"; echo " - vendor/ (Composer 依赖包,无需再次安装)\n"; +echo " - composer.json (Composer 配置文件)\n"; echo " - README.md/LICENSE.md (文档)\n"; echo " - examples/hello.php (PHP 示例代码)\n"; -echo " - examples/win32-hello/ (Windows GUI 编程实例)\n\n"; +echo " - examples/win32-hello/ (Windows GUI 编程实例)\n"; +echo " - examples/tetris-win32/ (俄罗斯方块游戏实例)\n\n"; echo "使用说明:\n"; echo " 1. 解压到任意目录\n"; echo " 2. 确保 PHP 8.4+ 已安装并添加到 PATH\n"; @@ -419,8 +434,9 @@ echo " 3. 运行: php swoole_compiler.php \n\n"; * @param string $dest 目标目录 * @param array $excludeDirs 要排除的目录列表(相对于 src 的路径) * @param string $baseSrc 原始源目录(用于计算相对路径) + * @param array $excludeExtensions 要排除的文件扩展名列表(不含点) */ -function copyDirectory(string $src, string $dest, array $excludeDirs = [], ?string $baseSrc = null): void +function copyDirectory(string $src, string $dest, array $excludeDirs = [], ?string $baseSrc = null, array $excludeExtensions = []): void { if (!is_dir($src)) { return; @@ -439,6 +455,14 @@ function copyDirectory(string $src, string $dest, array $excludeDirs = [], ?stri $srcPath = "{$src}/{$file}"; $destPath = "{$dest}/{$file}"; + // 如果是文件,检查扩展名是否在排除列表中 + if (is_file($srcPath) && !empty($excludeExtensions)) { + $ext = strtolower(pathinfo($file, PATHINFO_EXTENSION)); + if (in_array($ext, $excludeExtensions)) { + continue; + } + } + // 计算相对于 baseSrc 的路径 $relativePath = str_replace('\\', '/', substr($srcPath, strlen($baseSrc) + 1)); @@ -456,7 +480,7 @@ function copyDirectory(string $src, string $dest, array $excludeDirs = [], ?stri } if (is_dir($srcPath)) { - copyDirectory($srcPath, $destPath, $excludeDirs, $baseSrc); + copyDirectory($srcPath, $destPath, $excludeDirs, $baseSrc, $excludeExtensions); } else { copy($srcPath, $destPath); } diff --git a/version.txt b/version.txt index ddd396ca..6409db25 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ - 1035 \ No newline at end of file +1049 \ No newline at end of file