rc文件生成

speed_build
yangweijie 3 weeks ago
parent 473bd284ab
commit 7fa91622e2
  1. 5
      src/Build/ResourceCompilationTrait.php
  2. 10
      src/Generator/ResourceFileGenerator.php

@ -54,7 +54,10 @@ trait ResourceCompilationTrait
$rcFile = $this->getResourceRcFile();
$rcContent = $generator->generate();
$this->writeFile($rcFile, "\xEF\xBB\xBF" . $rcContent);
// 不写 UTF-8 BOM:rc.exe 在文件头遇到 BOM 字节会导致无法识别首行 `//` 注释,
// 进而把注释文本当成语句解析(RC2135 "file not found")。
// 文件内的中文由 `#pragma code_page(65001)` 正确处理,无需 BOM。
$this->writeFile($rcFile, $rcContent);
$this->climate->info('Generated resource file: ' . $rcFile);
$backend = $this->getCompilerBackend();

@ -105,8 +105,8 @@ class ResourceFileGenerator
public function generate(): string
{
$content = '';
$content .= '// Generated by TypePHP - Windows Resource File' . PHP_EOL;
$content .= '// DO NOT EDIT - This file is auto-generated' . PHP_EOL;
$content .= '; Generated by TypePHP - Windows Resource File' . PHP_EOL;
$content .= '; DO NOT EDIT - This file is auto-generated' . PHP_EOL;
$content .= PHP_EOL;
// 告诉 rc.exe 此文件使用 UTF-8 编码,避免中文乱码
@ -121,7 +121,7 @@ class ResourceFileGenerator
$manifestPath = $this->getManifestPath();
if ($manifestPath) {
$manifestPathRc = str_replace('\\', '/', $manifestPath);
$content .= '// Manifest Resource' . PHP_EOL;
$content .= '; Manifest Resource' . PHP_EOL;
$content .= 'CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "' . addslashes($manifestPathRc) . '"' . PHP_EOL;
$content .= PHP_EOL;
}
@ -131,7 +131,7 @@ class ResourceFileGenerator
if ($iconPath) {
// 使用正斜杠,Windows RC 编译器更兼容
$iconPathRc = str_replace('\\', '/', $iconPath);
$content .= '// Icon Resource' . PHP_EOL;
$content .= '; Icon Resource' . PHP_EOL;
$content .= 'MAINICON ICON "' . addslashes($iconPathRc) . '"' . PHP_EOL;
$content .= PHP_EOL;
}
@ -154,7 +154,7 @@ class ResourceFileGenerator
$productVersion = $info['product-version'] ?? $fileVersion;
$content = '';
$content .= '// Version Information' . PHP_EOL;
$content .= '; Version Information' . PHP_EOL;
$content .= '1 VERSIONINFO' . PHP_EOL;
$content .= 'FILEVERSION ' . $this->formatVersionDots($fileVersion) . PHP_EOL;
$content .= 'PRODUCTVERSION ' . $this->formatVersionDots($productVersion) . PHP_EOL;

Loading…
Cancel
Save