From ee8416c0c627a0836b50c1190c80b66408743bd4 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 12 Apr 2024 15:32:26 +0800 Subject: [PATCH] add windows support for dba-qdbm --- config/ext.json | 5 ++--- config/lib.json | 6 ++++++ config/source.json | 5 +++-- src/SPC/builder/extension/dba.php | 6 ++++++ src/SPC/builder/windows/WindowsBuilder.php | 3 +++ src/SPC/builder/windows/library/qdbm.php | 24 ++++++++++++++++++++++ src/globals/test-extensions.php | 4 ++-- 7 files changed, 46 insertions(+), 7 deletions(-) create mode 100644 src/SPC/builder/windows/library/qdbm.php diff --git a/config/ext.json b/config/ext.json index fa040056..f4c6ecbe 100644 --- a/config/ext.json +++ b/config/ext.json @@ -43,9 +43,8 @@ }, "dba": { "type": "builtin", - "arg-type-windows": "with", - "arg-type-unix": "custom", - "lib-suggests-unix": [ + "arg-type": "custom", + "lib-suggests": [ "qdbm" ] }, diff --git a/config/lib.json b/config/lib.json index d0c81c68..6dc2caac 100644 --- a/config/lib.json +++ b/config/lib.json @@ -529,6 +529,12 @@ "source": "qdbm", "static-libs-unix": [ "libqdbm.a" + ], + "static-libs-windows": [ + "qdbm_a.lib" + ], + "headers-windows": [ + "depot.h" ] }, "readline": { diff --git a/config/source.json b/config/source.json index 50c03735..0ecbb49d 100644 --- a/config/source.json +++ b/config/source.json @@ -552,8 +552,9 @@ } }, "qdbm": { - "type": "url", - "url": "https://master.dl.sourceforge.net/project/qdbm/qdbm/1.8.77/qdbm-1.8.77.tar.gz", + "type": "git", + "url": "https://github.com/static-php/qdbm.git", + "rev": "main", "license": { "type": "file", "path": "COPYING" diff --git a/src/SPC/builder/extension/dba.php b/src/SPC/builder/extension/dba.php index 34ac4ffe..011e4746 100644 --- a/src/SPC/builder/extension/dba.php +++ b/src/SPC/builder/extension/dba.php @@ -15,4 +15,10 @@ class dba extends Extension $qdbm = $this->builder->getLib('qdbm') ? (' --with-qdbm=' . BUILD_ROOT_PATH) : ''; return '--enable-dba' . $qdbm; } + + public function getWindowsConfigureArg(): string + { + $qdbm = $this->builder->getLib('qdbm') ? ' --with-qdbm' : ''; + return '--with-dba' . $qdbm; + } } diff --git a/src/SPC/builder/windows/WindowsBuilder.php b/src/SPC/builder/windows/WindowsBuilder.php index 256b392b..2e5a2d0d 100644 --- a/src/SPC/builder/windows/WindowsBuilder.php +++ b/src/SPC/builder/windows/WindowsBuilder.php @@ -46,6 +46,9 @@ class WindowsBuilder extends BuilderBase // make cmake toolchain $this->cmake_toolchain_file = SystemUtil::makeCmakeToolchainFile(); + + f_mkdir(BUILD_INCLUDE_PATH, recursive: true); + f_mkdir(BUILD_LIB_PATH, recursive: true); } /** diff --git a/src/SPC/builder/windows/library/qdbm.php b/src/SPC/builder/windows/library/qdbm.php new file mode 100644 index 00000000..67617b34 --- /dev/null +++ b/src/SPC/builder/windows/library/qdbm.php @@ -0,0 +1,24 @@ +cd($this->source_dir) + ->execWithWrapper( + $this->builder->makeSimpleWrapper('nmake'), + '/f VCMakefile' + ); + copy($this->source_dir . '\qdbm_a.lib', BUILD_LIB_PATH . '\qdbm_a.lib'); + copy($this->source_dir . '\depot.h', BUILD_INCLUDE_PATH . '\depot.h'); + // FileSystem::copyDir($this->source_dir . '\include\curl', BUILD_INCLUDE_PATH . '\curl'); + } +} diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index dcbd337e..45d03b42 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -14,13 +14,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' => 'dba', - 'Windows' => 'mbstring,pdo_sqlite,mbregex', + 'Windows' => 'mbstring,pdo_sqlite,mbregex,dba', }; // 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' => 'qdbm', - 'Windows' => '', + 'Windows' => 'qdbm', }; // Please change your test base combination. We recommend testing with `common`.