From 4537bfb247e48292d0ffe378ce39930e1f686f9c Mon Sep 17 00:00:00 2001 From: Marcel Pociot Date: Wed, 31 May 2023 10:03:40 +0200 Subject: [PATCH] Add support for libargon2 --- config/ext.json | 7 ++++++ config/lib.json | 6 +++++ config/source.json | 8 +++++++ src/SPC/builder/macos/library/libargon2.php | 12 ++++++++++ src/SPC/builder/unix/library/libargon2.php | 26 +++++++++++++++++++++ 5 files changed, 59 insertions(+) create mode 100644 src/SPC/builder/macos/library/libargon2.php create mode 100644 src/SPC/builder/unix/library/libargon2.php diff --git a/config/ext.json b/config/ext.json index 3c0b1960..f6d2d93c 100644 --- a/config/ext.json +++ b/config/ext.json @@ -295,6 +295,13 @@ "libsodium" ] }, + "password-argon2": { + "type": "builtin", + "arg-type": "with-prefix", + "lib-depends": [ + "libargon2" + ] + }, "sqlite3": { "type": "builtin", "arg-type": "with-prefix", diff --git a/config/lib.json b/config/lib.json index bfe6ec6c..4c2c0cae 100644 --- a/config/lib.json +++ b/config/lib.json @@ -460,5 +460,11 @@ "static-libs-unix": [ "libsodium.a" ] + }, + "libargon2": { + "source": "libargon2", + "static-libs-unix": [ + "libargon2.a" + ] } } \ No newline at end of file diff --git a/config/source.json b/config/source.json index d74fd496..d9784cba 100644 --- a/config/source.json +++ b/config/source.json @@ -419,5 +419,13 @@ "type": "file", "path": "LICENSE" } + }, + "libargon2": { + "type": "ghtar", + "repo": "P-H-C/phc-winner-argon2", + "license": { + "type": "file", + "path": "LICENSE" + } } } \ No newline at end of file diff --git a/src/SPC/builder/macos/library/libargon2.php b/src/SPC/builder/macos/library/libargon2.php new file mode 100644 index 00000000..f39afa4f --- /dev/null +++ b/src/SPC/builder/macos/library/libargon2.php @@ -0,0 +1,12 @@ +cd($this->source_dir) + ->exec("make {$this->builder->configure_env} 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); + } + } + } +}