Add ext-password-argon2

This commit is contained in:
crazywhalecc 2026-03-12 21:56:28 +08:00
parent e523fff0ab
commit 9d65c491e7
No known key found for this signature in database
GPG Key ID: 1F4BDD59391F2680
2 changed files with 45 additions and 0 deletions

View File

@ -144,6 +144,14 @@ ext-openssl:
arg-type: custom
arg-type@windows: with
build-with-php: true
ext-password-argon2:
type: php-extension
depends:
- libargon2
- ext-openssl
php-extension:
arg-type: custom
display-name: ''
ext-phar:
type: php-extension
depends:

View File

@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
namespace Package\Extension;
use Package\Target\php;
use StaticPHP\Attribute\Package\CustomPhpConfigureArg;
use StaticPHP\Attribute\Package\Extension;
use StaticPHP\Exception\ValidationException;
use StaticPHP\Package\PackageBuilder;
use StaticPHP\Package\PackageInstaller;
use StaticPHP\Package\PhpExtensionPackage;
#[Extension('password-argon2')]
class password_argon2 extends PhpExtensionPackage
{
public function runSmokeTestCliUnix(): void
{
[$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -n -r "assert(defined(\'PASSWORD_ARGON2I\'));"');
if ($ret !== 0) {
throw new ValidationException('extension ' . $this->getName() . ' failed sanity check', validation_module: 'password_argon2 function check');
}
}
#[CustomPhpConfigureArg('Linux')]
#[CustomPhpConfigureArg('Darwin')]
public function getConfigureArg(PackageInstaller $installer, PackageBuilder $builder): string
{
if ($installer->getLibraryPackage('openssl') !== null) {
if (php::getPHPVersionID() >= 80500 || (php::getPHPVersionID() >= 80400 && !$builder->getOption('enable-zts'))) {
return '--without-password-argon2'; // use --with-openssl-argon2 in openssl extension instead
}
}
return '--with-password-argon2';
}
}