mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-04 23:35:40 +08:00
Refactor extension configuration and improve Windows build support
This commit is contained in:
@@ -45,7 +45,13 @@ class php_src
|
||||
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/gd/libgd/gdft.c', '#ifndef MSWIN32', '#ifndef _WIN32');
|
||||
}
|
||||
// custom config.w32, because official config.w32 is hard-coded many things
|
||||
$origin = $ver_id >= 80100 ? file_get_contents(ROOT_DIR . '/src/globals/extra/gd_config_81.w32') : file_get_contents(ROOT_DIR . '/src/globals/extra/gd_config_80.w32');
|
||||
if ($ver_id >= 80500) {
|
||||
$origin = file_get_contents(ROOT_DIR . '/src/globals/extra/gd_config_85.w32');
|
||||
} elseif ($ver_id >= 80100) {
|
||||
$origin = file_get_contents(ROOT_DIR . '/src/globals/extra/gd_config_81.w32');
|
||||
} else {
|
||||
$origin = file_get_contents(ROOT_DIR . '/src/globals/extra/gd_config_80.w32');
|
||||
}
|
||||
file_put_contents(SOURCE_PATH . '/php-src/ext/gd/config.w32.bak', file_get_contents(SOURCE_PATH . '/php-src/ext/gd/config.w32'));
|
||||
file_put_contents(SOURCE_PATH . '/php-src/ext/gd/config.w32', $origin);
|
||||
}
|
||||
|
||||
30
src/Package/Extension/ev.php
Normal file
30
src/Package/Extension/ev.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Package\Extension;
|
||||
|
||||
use Package\Target\php;
|
||||
use StaticPHP\Attribute\Package\BeforeStage;
|
||||
use StaticPHP\Attribute\Package\Extension;
|
||||
use StaticPHP\Package\PhpExtensionPackage;
|
||||
use StaticPHP\Util\FileSystem;
|
||||
|
||||
#[Extension('ev')]
|
||||
class ev extends PhpExtensionPackage
|
||||
{
|
||||
#[BeforeStage('php', [php::class, 'buildconfForWindows'], 'ext-ev')]
|
||||
public function patchBeforeBuildconf(): bool
|
||||
{
|
||||
/*
|
||||
* replace EXTENSION('ev', php_ev_sources, true, ' /DZEND_ENABLE_STATIC_TSRMLS_CACHE=1');
|
||||
* to EXTENSION('ev', php_ev_sources, PHP_EV_SHARED, ' /DZEND_ENABLE_STATIC_TSRMLS_CACHE=1');
|
||||
*/
|
||||
FileSystem::replaceFileLineContainsString(
|
||||
"{$this->getSourceDir()}\\config.w32",
|
||||
'EXTENSION(\'ev\'',
|
||||
" EXTENSION('ev', php_ev_sources, PHP_EV_SHARED, ' /DZEND_ENABLE_STATIC_TSRMLS_CACHE=1');"
|
||||
);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
29
src/Package/Extension/intl.php
Normal file
29
src/Package/Extension/intl.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Package\Extension;
|
||||
|
||||
use Package\Target\php;
|
||||
use StaticPHP\Attribute\Package\BeforeStage;
|
||||
use StaticPHP\Attribute\Package\Extension;
|
||||
use StaticPHP\Attribute\PatchDescription;
|
||||
use StaticPHP\Package\PackageInstaller;
|
||||
use StaticPHP\Package\PhpExtensionPackage;
|
||||
use StaticPHP\Util\FileSystem;
|
||||
|
||||
#[Extension('intl')]
|
||||
class intl extends PhpExtensionPackage
|
||||
{
|
||||
#[BeforeStage('php', [php::class, 'buildconfForWindows'], 'ext-intl')]
|
||||
#[PatchDescription('Fix intl config.w32: replace hardcoded true with PHP_INTL_SHARED for static build support')]
|
||||
public function patchBeforeBuildconfForWindows(PackageInstaller $installer): void
|
||||
{
|
||||
$php_src = $installer->getTargetPackage('php')->getSourceDir();
|
||||
FileSystem::replaceFileStr(
|
||||
"{$php_src}/ext/intl/config.w32",
|
||||
'EXTENSION("intl", "php_intl.c intl_convert.c intl_convertcpp.cpp intl_error.c ", true,',
|
||||
'EXTENSION("intl", "php_intl.c intl_convert.c intl_convertcpp.cpp intl_error.c ", PHP_INTL_SHARED,'
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ class mbregex
|
||||
{
|
||||
#[CustomPhpConfigureArg('Linux')]
|
||||
#[CustomPhpConfigureArg('Darwin')]
|
||||
#[CustomPhpConfigureArg('Windows')]
|
||||
public function getUnixConfigureArg(): string
|
||||
{
|
||||
return '';
|
||||
|
||||
@@ -19,4 +19,10 @@ class mbstring
|
||||
$arg .= $installer->isPackageResolved('ext-mbregex') === false ? ' --disable-mbregex' : ' --enable-mbregex';
|
||||
return $arg;
|
||||
}
|
||||
|
||||
#[CustomPhpConfigureArg('Windows')]
|
||||
public function getWinConfigureArg(PackageInstaller $installer): string
|
||||
{
|
||||
return '--enable-mbstring ' . ($installer->isPackageResolved('ext-mbregex') ? '--enable-mbregex' : ' --disable-mbregex');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ class libjpeg
|
||||
'-DENABLE_STATIC=ON',
|
||||
'-DBUILD_TESTING=OFF',
|
||||
'-DWITH_JAVA=OFF',
|
||||
'-DWITH_SIMD=OFF',
|
||||
'-DWITH_CRT_DLL=OFF',
|
||||
)
|
||||
->optionalPackage('zlib', '-DENABLE_ZLIB_COMPRESSION=ON', '-DENABLE_ZLIB_COMPRESSION=OFF')
|
||||
|
||||
Reference in New Issue
Block a user