Browse Source

fix linux build (dont know why linux failed)

crazywhalecc 1 year ago
parent
commit
339c03adb2
2 changed files with 18 additions and 1 deletions
  1. 13 0
      src/SPC/builder/linux/library/libargon2.php
  2. 5 1
      src/globals/test-extensions.php

+ 13 - 0
src/SPC/builder/linux/library/libargon2.php

@@ -4,9 +4,22 @@ 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;
+    }
 }

+ 5 - 1
src/globals/test-extensions.php

@@ -3,6 +3,10 @@
 declare(strict_types=1);
 
 # If you want to test new extensions here, just modify it.
-$extensions = 'password-argon2,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,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,sqlite3,swoole,sysvmsg,sysvsem,sysvshm,tokenizer,xml,xmlreader,xmlwriter,xsl,zip,zlib';
+
+if (PHP_OS_FAMILY === 'Darwin') {
+    $extensions .= ',sodium';
+}
 
 echo $extensions;