mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-18 04:44:53 +08:00
Merge pull request #64 from mpociot/libargon2-support
Add support for libargon2
This commit is contained in:
commit
cf198e0f0a
@ -242,6 +242,13 @@
|
|||||||
"zlib"
|
"zlib"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"password-argon2": {
|
||||||
|
"type": "builtin",
|
||||||
|
"arg-type": "with-prefix",
|
||||||
|
"lib-depends": [
|
||||||
|
"libargon2"
|
||||||
|
]
|
||||||
|
},
|
||||||
"pcntl": {
|
"pcntl": {
|
||||||
"type": "builtin",
|
"type": "builtin",
|
||||||
"unix-only": true
|
"unix-only": true
|
||||||
|
|||||||
@ -163,6 +163,12 @@
|
|||||||
"libsodium"
|
"libsodium"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"libargon2": {
|
||||||
|
"source": "libargon2",
|
||||||
|
"static-libs-unix": [
|
||||||
|
"libargon2.a"
|
||||||
|
]
|
||||||
|
},
|
||||||
"libavif": {
|
"libavif": {
|
||||||
"source": "libavif",
|
"source": "libavif",
|
||||||
"static-libs-unix": [
|
"static-libs-unix": [
|
||||||
|
|||||||
@ -172,6 +172,15 @@
|
|||||||
"path": "LICENSE"
|
"path": "LICENSE"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"libargon2": {
|
||||||
|
"type": "git",
|
||||||
|
"rev": "master",
|
||||||
|
"url": "https://github.com/mpociot/phc-winner-argon2",
|
||||||
|
"license": {
|
||||||
|
"type": "file",
|
||||||
|
"path": "LICENSE"
|
||||||
|
}
|
||||||
|
},
|
||||||
"libavif": {
|
"libavif": {
|
||||||
"type": "ghtar",
|
"type": "ghtar",
|
||||||
"repo": "AOMediaCodec/libavif",
|
"repo": "AOMediaCodec/libavif",
|
||||||
@ -376,9 +385,8 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"pkg-config": {
|
"pkg-config": {
|
||||||
"type": "filelist",
|
"type": "url",
|
||||||
"url": "https://pkgconfig.freedesktop.org/releases/",
|
"url": "https://dl.static-php.dev/static-php-cli/deps/pkg-config/pkg-config-0.29.2.tar.gz",
|
||||||
"regex": "/href=\"(?<file>pkg-config-(?<version>[^\"]+)\\.tar\\.gz)\"/",
|
|
||||||
"license": {
|
"license": {
|
||||||
"type": "file",
|
"type": "file",
|
||||||
"path": "COPYING"
|
"path": "COPYING"
|
||||||
|
|||||||
21
src/SPC/builder/extension/password_argon2.php
Normal file
21
src/SPC/builder/extension/password_argon2.php
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\extension;
|
||||||
|
|
||||||
|
use SPC\builder\Extension;
|
||||||
|
use SPC\exception\RuntimeException;
|
||||||
|
use SPC\util\CustomExt;
|
||||||
|
|
||||||
|
#[CustomExt('password-argon2')]
|
||||||
|
class password_argon2 extends Extension
|
||||||
|
{
|
||||||
|
public function runCliCheck(): void
|
||||||
|
{
|
||||||
|
[$ret] = shell()->execWithResult(BUILD_ROOT_PATH . '/bin/php -r "assert(defined(\'PASSWORD_ARGON2I\'));"');
|
||||||
|
if ($ret !== 0) {
|
||||||
|
throw new RuntimeException('extension ' . $this->getName() . ' failed sanity check');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
25
src/SPC/builder/linux/library/libargon2.php
Normal file
25
src/SPC/builder/linux/library/libargon2.php
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\linux\library;
|
||||||
|
|
||||||
|
use SPC\exception\WrongUsageException;
|
||||||
|
use SPC\store\FileSystem;
|
||||||
|
|
||||||
|
class libargon2 extends LinuxLibraryBase
|
||||||
|
{
|
||||||
|
use \SPC\builder\unix\library\libargon2;
|
||||||
|
|
||||||
|
public const NAME = 'libargon2';
|
||||||
|
|
||||||
|
public function patchBeforeBuild(): bool
|
||||||
|
{
|
||||||
|
// detect libsodium (The libargon2 conflicts with the libsodium library.)
|
||||||
|
if ($this->builder->getLib('libsodium') !== null) {
|
||||||
|
throw new WrongUsageException('libargon2 (required by password-argon2) conflicts with the libsodium library !');
|
||||||
|
}
|
||||||
|
FileSystem::replaceFileStr($this->source_dir . '/Makefile', 'LIBRARY_REL ?= lib/x86_64-linux-gnu', 'LIBRARY_REL ?= lib');
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
12
src/SPC/builder/macos/library/libargon2.php
Normal file
12
src/SPC/builder/macos/library/libargon2.php
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\macos\library;
|
||||||
|
|
||||||
|
class libargon2 extends MacOSLibraryBase
|
||||||
|
{
|
||||||
|
use \SPC\builder\unix\library\libargon2;
|
||||||
|
|
||||||
|
public const NAME = 'libargon2';
|
||||||
|
}
|
||||||
26
src/SPC/builder/unix/library/libargon2.php
Normal file
26
src/SPC/builder/unix/library/libargon2.php
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\unix\library;
|
||||||
|
|
||||||
|
use SPC\store\FileSystem;
|
||||||
|
|
||||||
|
trait libargon2
|
||||||
|
{
|
||||||
|
protected function build()
|
||||||
|
{
|
||||||
|
shell()->cd($this->source_dir)
|
||||||
|
->exec("make PREFIX='' clean")
|
||||||
|
->exec("make -j{$this->builder->concurrency} PREFIX=''")
|
||||||
|
->exec("make install PREFIX='' DESTDIR=" . BUILD_ROOT_PATH);
|
||||||
|
|
||||||
|
$this->patchPkgconfPrefix(['libargon2.pc']);
|
||||||
|
|
||||||
|
foreach (FileSystem::scanDirFiles(BUILD_ROOT_PATH . '/lib/', false, true) as $filename) {
|
||||||
|
if (str_starts_with($filename, 'libargon2') && (str_contains($filename, '.so') || str_ends_with($filename, '.dylib'))) {
|
||||||
|
unlink(BUILD_ROOT_PATH . '/lib/' . $filename);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -3,6 +3,10 @@
|
|||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
# If you want to test new extensions here, just modify it.
|
# If you want to test new extensions here, just modify it.
|
||||||
$extensions = 'apcu,bcmath,bz2,calendar,ctype,curl,dba,dom,event,exif,fileinfo,filter,ftp,gd,gmp,iconv,imagick,imap,intl,ldap,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pdo_pgsql,pdo_sqlite,pgsql,phar,posix,protobuf,readline,redis,session,shmop,simplexml,soap,sockets,sodium,sqlite3,swoole,sysvmsg,sysvsem,sysvshm,tokenizer,xml,xmlreader,xmlwriter,xsl,zip,zlib';
|
$extensions = 'password-argon2,apcu,bcmath,bz2,calendar,ctype,curl,dba,dom,event,exif,fileinfo,filter,ftp,gd,gmp,iconv,imagick,imap,intl,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pdo_pgsql,pdo_sqlite,pgsql,phar,posix,protobuf,readline,redis,session,shmop,simplexml,soap,sockets,sqlite3,swoole,sysvmsg,sysvsem,sysvshm,tokenizer,xml,xmlreader,xmlwriter,xsl,zip,zlib';
|
||||||
|
|
||||||
|
if (PHP_OS_FAMILY === 'Darwin') {
|
||||||
|
$extensions .= ',sodium';
|
||||||
|
}
|
||||||
|
|
||||||
echo $extensions;
|
echo $extensions;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user