2023-06-02 21:40:17 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace SPC\builder\extension;
|
|
|
|
|
|
|
|
|
|
use SPC\builder\Extension;
|
2025-04-28 14:35:08 +08:00
|
|
|
use SPC\store\SourcePatcher;
|
2023-06-02 21:40:17 +08:00
|
|
|
use SPC\util\CustomExt;
|
|
|
|
|
|
|
|
|
|
#[CustomExt('xlswriter')]
|
|
|
|
|
class xlswriter extends Extension
|
|
|
|
|
{
|
2025-03-27 11:12:19 +07:00
|
|
|
public function getUnixConfigureArg(bool $shared = false): string
|
2023-06-02 21:40:17 +08:00
|
|
|
{
|
2024-06-04 19:31:13 +08:00
|
|
|
$arg = '--with-xlswriter --enable-reader';
|
|
|
|
|
if ($this->builder->getLib('openssl')) {
|
|
|
|
|
$arg .= ' --with-openssl=' . BUILD_ROOT_PATH;
|
|
|
|
|
}
|
|
|
|
|
return $arg;
|
2023-06-02 21:40:17 +08:00
|
|
|
}
|
2025-04-24 14:21:37 +08:00
|
|
|
|
2025-05-21 12:01:00 +07:00
|
|
|
public function getWindowsConfigureArg(bool $shared = false): string
|
2025-04-24 14:21:37 +08:00
|
|
|
{
|
|
|
|
|
return '--with-xlswriter';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function patchBeforeMake(): bool
|
|
|
|
|
{
|
2025-07-19 15:10:42 +07:00
|
|
|
$patched = parent::patchBeforeMake();
|
2025-04-24 14:21:37 +08:00
|
|
|
if (PHP_OS_FAMILY === 'Windows') {
|
2025-04-28 14:35:08 +08:00
|
|
|
// fix windows build with openssl extension duplicate symbol bug
|
|
|
|
|
SourcePatcher::patchFile('spc_fix_xlswriter_win32.patch', $this->source_dir);
|
2025-04-24 14:21:37 +08:00
|
|
|
$content = file_get_contents($this->source_dir . '/library/libxlsxwriter/src/theme.c');
|
|
|
|
|
$bom = pack('CCC', 0xEF, 0xBB, 0xBF);
|
2025-07-19 15:11:22 +07:00
|
|
|
if (!str_starts_with($content, $bom)) {
|
2025-04-28 14:35:08 +08:00
|
|
|
file_put_contents($this->source_dir . '/library/libxlsxwriter/src/theme.c', $bom . $content);
|
2025-04-24 14:21:37 +08:00
|
|
|
}
|
2025-04-28 14:35:08 +08:00
|
|
|
return true;
|
2025-04-24 14:21:37 +08:00
|
|
|
}
|
2025-07-19 15:10:42 +07:00
|
|
|
return $patched;
|
2025-04-24 14:21:37 +08:00
|
|
|
}
|
2023-06-02 21:40:17 +08:00
|
|
|
}
|