mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-02 14:25:41 +08:00
v3: Fix gmssl build (#1188)
This commit is contained in:
@@ -10,3 +10,5 @@ ext-gmssl:
|
||||
license: PHP-3.01
|
||||
depends:
|
||||
- gmssl
|
||||
php-extension:
|
||||
arg-type: with-path
|
||||
|
||||
45
src/Package/Extension/gmssl.php
Normal file
45
src/Package/Extension/gmssl.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?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\PhpExtensionPackage;
|
||||
use StaticPHP\Util\FileSystem;
|
||||
|
||||
#[Extension('gmssl')]
|
||||
class gmssl extends PhpExtensionPackage
|
||||
{
|
||||
#[BeforeStage('php', [php::class, 'buildconfForUnix'], 'ext-gmssl')]
|
||||
#[BeforeStage('php', [php::class, 'buildconfForWindows'], 'ext-gmssl')]
|
||||
#[PatchDescription('Fix ext-gmssl v1.1.1 compatibility with GmSSL >= 3.1.0 where SM2_VERIFY_CTX was removed (unified into SM2_SIGN_CTX)')]
|
||||
public function patchSm2VerifyCtx(): void
|
||||
{
|
||||
// See: https://github.com/crazywhalecc/static-php-cli/issues/1182
|
||||
FileSystem::replaceFileStr(
|
||||
"{$this->getSourceDir()}/gmssl.c",
|
||||
'SM2_VERIFY_CTX',
|
||||
'SM2_SIGN_CTX'
|
||||
);
|
||||
}
|
||||
|
||||
#[BeforeStage('php', [php::class, 'buildconfForWindows'], 'ext-gmssl')]
|
||||
#[PatchDescription('Add CHECK_LIB to config.w32 for static Windows builds')]
|
||||
public function patchBeforeBuildconfWin(): bool
|
||||
{
|
||||
$configW32 = "{$this->getSourceDir()}/config.w32";
|
||||
if (str_contains(FileSystem::readFile($configW32), 'CHECK_LIB(')) {
|
||||
return false;
|
||||
}
|
||||
FileSystem::replaceFileStr(
|
||||
$configW32,
|
||||
'AC_DEFINE(',
|
||||
'CHECK_LIB("gmssl.lib", "gmssl", PHP_GMSSL);' . PHP_EOL . 'AC_DEFINE('
|
||||
);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,9 @@ class gmssl
|
||||
#[BuildFor('Darwin')]
|
||||
public function build(LibraryPackage $lib): void
|
||||
{
|
||||
UnixCMakeExecutor::create($lib)->build();
|
||||
UnixCMakeExecutor::create($lib)
|
||||
->addConfigureArgs('-DENABLE_SM2_PRIVATE_KEY_EXPORT=ON')
|
||||
->build();
|
||||
}
|
||||
|
||||
#[BuildFor('Windows')]
|
||||
@@ -33,6 +35,7 @@ class gmssl
|
||||
'-G "NMake Makefiles"',
|
||||
'-DWIN32=ON',
|
||||
'-DBUILD_SHARED_LIBS=OFF',
|
||||
'-DENABLE_SM2_PRIVATE_KEY_EXPORT=ON',
|
||||
'-DCMAKE_BUILD_TYPE=Release',
|
||||
'-DCMAKE_C_FLAGS_RELEASE="/MT /O2 /Ob2 /DNDEBUG"',
|
||||
'-DCMAKE_CXX_FLAGS_RELEASE="/MT /O2 /Ob2 /DNDEBUG"',
|
||||
|
||||
@@ -45,7 +45,11 @@ class FileList implements DownloadTypeInterface, CheckUpdateInterface
|
||||
throw new DownloaderException("Failed to get {$name} file list from {$config['url']}");
|
||||
}
|
||||
$versions = [];
|
||||
logger()->debug('Matched ' . count($matches['version']) . " versions for {$name}");
|
||||
$cnt = count($matches['version']);
|
||||
if ($cnt === 0) {
|
||||
throw new DownloaderException("Failed to get {$name} file list from {$config['url']}: no version parsed");
|
||||
}
|
||||
logger()->debug("Matched {$cnt} versions for {$name}");
|
||||
foreach ($matches['version'] as $i => $version) {
|
||||
$lower = strtolower($version);
|
||||
foreach (['alpha', 'beta', 'rc', 'pre', 'nightly', 'snapshot', 'dev'] as $beta) {
|
||||
|
||||
Reference in New Issue
Block a user