From f6c42e0fbf21b49a11cbf82539b83e7de51e2444 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 12 Apr 2024 12:44:26 +0800 Subject: [PATCH] add qdbm for dba --- config/ext.json | 6 ++++- config/lib.json | 6 +++++ config/source.json | 8 +++++++ src/SPC/builder/extension/dba.php | 18 ++++++++++++++ src/SPC/builder/linux/library/qdbm.php | 12 ++++++++++ src/SPC/builder/macos/library/qdbm.php | 12 ++++++++++ src/SPC/builder/unix/library/qdbm.php | 33 ++++++++++++++++++++++++++ src/globals/test-extensions.php | 6 ++--- 8 files changed, 97 insertions(+), 4 deletions(-) create mode 100644 src/SPC/builder/extension/dba.php create mode 100644 src/SPC/builder/linux/library/qdbm.php create mode 100644 src/SPC/builder/macos/library/qdbm.php create mode 100644 src/SPC/builder/unix/library/qdbm.php diff --git a/config/ext.json b/config/ext.json index 6d5765e5..fa040056 100644 --- a/config/ext.json +++ b/config/ext.json @@ -43,7 +43,11 @@ }, "dba": { "type": "builtin", - "arg-type-windows": "with" + "arg-type-windows": "with", + "arg-type-unix": "custom", + "lib-suggests-unix": [ + "qdbm" + ] }, "dom": { "type": "builtin", diff --git a/config/lib.json b/config/lib.json index 746f508e..d0c81c68 100644 --- a/config/lib.json +++ b/config/lib.json @@ -525,6 +525,12 @@ "zstd" ] }, + "qdbm": { + "source": "qdbm", + "static-libs-unix": [ + "libqdbm.a" + ] + }, "readline": { "source": "readline", "static-libs-unix": [ diff --git a/config/source.json b/config/source.json index 87099347..50c03735 100644 --- a/config/source.json +++ b/config/source.json @@ -551,6 +551,14 @@ "path": "LICENSE" } }, + "qdbm": { + "type": "url", + "url": "https://master.dl.sourceforge.net/project/qdbm/qdbm/1.8.77/qdbm-1.8.77.tar.gz", + "license": { + "type": "file", + "path": "COPYING" + } + }, "rar": { "type": "git", "url": "https://github.com/static-php/php-rar.git", diff --git a/src/SPC/builder/extension/dba.php b/src/SPC/builder/extension/dba.php new file mode 100644 index 00000000..34ac4ffe --- /dev/null +++ b/src/SPC/builder/extension/dba.php @@ -0,0 +1,18 @@ +builder->getLib('qdbm') ? (' --with-qdbm=' . BUILD_ROOT_PATH) : ''; + return '--enable-dba' . $qdbm; + } +} diff --git a/src/SPC/builder/linux/library/qdbm.php b/src/SPC/builder/linux/library/qdbm.php new file mode 100644 index 00000000..b0bc8960 --- /dev/null +++ b/src/SPC/builder/linux/library/qdbm.php @@ -0,0 +1,12 @@ +cd($this->source_dir) + ->exec( + './configure ' . + '--enable-static --disable-shared ' . + '--prefix=' + ) + ->exec('make clean'); + FileSystem::replaceFileRegex($this->source_dir . '/Makefile', '/MYLIBS = libqdbm.a.*/m', 'MYLIBS = libqdbm.a'); + shell()->cd($this->source_dir) + ->exec("make -j{$this->builder->concurrency}" . ($this instanceof MacOSLibraryBase ? ' mac' : '')) + ->exec('make install DESTDIR=' . BUILD_ROOT_PATH); + $this->patchPkgconfPrefix(['qdbm.pc']); + } +} diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 07497e67..dcbd337e 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -13,13 +13,13 @@ declare(strict_types=1); // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'yac', - 'Windows' => 'mbstring,pdo_sqlite,mbregex,yac', + 'Linux', 'Darwin' => 'dba', + 'Windows' => 'mbstring,pdo_sqlite,mbregex', }; // If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`). $with_libs = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => '', + 'Linux', 'Darwin' => 'qdbm', 'Windows' => '', };