mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-02 14:25:41 +08:00
Apply v2 patch for xlswriter
This commit is contained in:
@@ -16,3 +16,4 @@ ext-xlswriter:
|
||||
support:
|
||||
BSD: wip
|
||||
arg-type: custom
|
||||
arg-type@windows: '--with-xlswriter'
|
||||
|
||||
@@ -4,10 +4,14 @@ declare(strict_types=1);
|
||||
|
||||
namespace Package\Extension;
|
||||
|
||||
use Package\Target\php;
|
||||
use StaticPHP\Attribute\Package\BeforeStage;
|
||||
use StaticPHP\Attribute\Package\CustomPhpConfigureArg;
|
||||
use StaticPHP\Attribute\Package\Extension;
|
||||
use StaticPHP\Attribute\PatchDescription;
|
||||
use StaticPHP\Package\PackageInstaller;
|
||||
use StaticPHP\Package\PhpExtensionPackage;
|
||||
use StaticPHP\Util\SourcePatcher;
|
||||
|
||||
#[Extension('xlswriter')]
|
||||
class xlswriter extends PhpExtensionPackage
|
||||
@@ -22,4 +26,17 @@ class xlswriter extends PhpExtensionPackage
|
||||
}
|
||||
return $arg;
|
||||
}
|
||||
|
||||
#[BeforeStage('php', [php::class, 'makeForWindows'], 'ext-xlswriter')]
|
||||
#[PatchDescription('Fix Windows build: apply win32 patch and add UTF-8 BOM to theme.c')]
|
||||
public function patchBeforeMakeForWindows(): void
|
||||
{
|
||||
// fix windows build with openssl extension duplicate symbol bug
|
||||
SourcePatcher::patchFile('spc_fix_xlswriter_win32.patch', $this->getSourceDir());
|
||||
$content = file_get_contents($this->getSourceDir() . '/library/libxlsxwriter/src/theme.c');
|
||||
$bom = pack('CCC', 0xEF, 0xBB, 0xBF);
|
||||
if (!str_starts_with($content, $bom)) {
|
||||
file_put_contents($this->getSourceDir() . '/library/libxlsxwriter/src/theme.c', $bom . $content);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user