From db2d9a909fab4a988b164d34f9bf626640bfefd3 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Mon, 22 Jun 2026 16:44:44 +0800 Subject: [PATCH] feat(gmssl): add patch for pbkdf2_hmac_sm3_genkey rename and update build process --- src/Package/Extension/gmssl.php | 12 ++++++++++++ src/Package/Library/gmssl.php | 14 +++++++------- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/Package/Extension/gmssl.php b/src/Package/Extension/gmssl.php index 372e7d7c..a230f407 100644 --- a/src/Package/Extension/gmssl.php +++ b/src/Package/Extension/gmssl.php @@ -27,6 +27,18 @@ 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: pbkdf2_hmac_sm3_genkey was renamed to sm3_pbkdf2 in GmSSL >= 3.2.0')] + public function patchPbkdf2Rename(): void + { + FileSystem::replaceFileStr( + "{$this->getSourceDir()}/gmssl.c", + 'pbkdf2_hmac_sm3_genkey', + 'sm3_pbkdf2' + ); + } + #[BeforeStage('php', [php::class, 'buildconfForWindows'], 'ext-gmssl')] #[PatchDescription('Add CHECK_LIB to config.w32 for static Windows builds')] public function patchBeforeBuildconfWin(): bool diff --git a/src/Package/Library/gmssl.php b/src/Package/Library/gmssl.php index 8887b64f..eff598a3 100644 --- a/src/Package/Library/gmssl.php +++ b/src/Package/Library/gmssl.php @@ -45,13 +45,13 @@ class gmssl ->toStep(1) ->build(); - // fix cmake_install.cmake install prefix (GmSSL overrides it internally) - $installCmake = "{$buildDir}\\cmake_install.cmake"; - FileSystem::writeFile( - $installCmake, - 'set(CMAKE_INSTALL_PREFIX "' . str_replace('\\', '/', $lib->getBuildRootPath()) . '")' . PHP_EOL . FileSystem::readFile($installCmake) - ); + cmd()->cd($buildDir)->exec('nmake gmssl XCFLAGS=/MT'); - cmd()->cd($buildDir)->exec('nmake install XCFLAGS=/MT'); + $libPath = "{$lib->getBuildRootPath()}/lib"; + $incPath = "{$lib->getBuildRootPath()}/include/gmssl"; + FileSystem::createDir($libPath); + FileSystem::createDir($incPath); + FileSystem::copy("{$buildDir}\\bin\\gmssl.lib", "{$libPath}/gmssl.lib"); + FileSystem::copyDir("{$lib->getSourceDir()}\\include\\gmssl", $incPath); } }