add qdbm for dba (#409)

* add qdbm for dba

* add windows support for dba-qdbm

* fix test scripts

* fix test scripts
This commit is contained in:
Jerry Ma 2024-04-12 15:53:38 +08:00 committed by GitHub
parent b4ed4ea956
commit e3c542d9df
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 138 additions and 7 deletions

View File

@ -168,4 +168,4 @@ jobs:
bin/spc download --for-extensions="$(php src/globals/test-extensions.php extensions)" --for-libs="$(php src/globals/test-extensions.php libs)" --with-php=${{ matrix.php }} --ignore-cache-sources=php-src --debug bin/spc download --for-extensions="$(php src/globals/test-extensions.php extensions)" --for-libs="$(php src/globals/test-extensions.php libs)" --with-php=${{ matrix.php }} --ignore-cache-sources=php-src --debug
- name: "Run Build Tests (build)" - name: "Run Build Tests (build)"
run: bin/spc build "$(php src/globals/test-extensions.php extensions)" $(php src/globals/test-extensions.php libs_cmd) --build-cli --build-micro --build-fpm --debug run: bin/spc build "$(php src/globals/test-extensions.php extensions)" --with-libs="$(php src/globals/test-extensions.php libs)" --build-cli --build-micro --build-fpm --debug

View File

@ -43,7 +43,10 @@
}, },
"dba": { "dba": {
"type": "builtin", "type": "builtin",
"arg-type-windows": "with" "arg-type": "custom",
"lib-suggests": [
"qdbm"
]
}, },
"dom": { "dom": {
"type": "builtin", "type": "builtin",

View File

@ -525,6 +525,18 @@
"zstd" "zstd"
] ]
}, },
"qdbm": {
"source": "qdbm",
"static-libs-unix": [
"libqdbm.a"
],
"static-libs-windows": [
"qdbm_a.lib"
],
"headers-windows": [
"depot.h"
]
},
"readline": { "readline": {
"source": "readline", "source": "readline",
"static-libs-unix": [ "static-libs-unix": [

View File

@ -551,6 +551,15 @@
"path": "LICENSE" "path": "LICENSE"
} }
}, },
"qdbm": {
"type": "git",
"url": "https://github.com/static-php/qdbm.git",
"rev": "main",
"license": {
"type": "file",
"path": "COPYING"
}
},
"rar": { "rar": {
"type": "git", "type": "git",
"url": "https://github.com/static-php/php-rar.git", "url": "https://github.com/static-php/php-rar.git",

View File

@ -0,0 +1,24 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\util\CustomExt;
#[CustomExt('dba')]
class dba extends Extension
{
public function getUnixConfigureArg(): string
{
$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;
}
}

View File

@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
namespace SPC\builder\linux\library;
class qdbm extends LinuxLibraryBase
{
use \SPC\builder\unix\library\qdbm;
public const NAME = 'qdbm';
}

View File

@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
namespace SPC\builder\macos\library;
class qdbm extends MacOSLibraryBase
{
use \SPC\builder\unix\library\qdbm;
public const NAME = 'qdbm';
}

View File

@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
namespace SPC\builder\unix\library;
use SPC\builder\macos\library\MacOSLibraryBase;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\store\FileSystem;
trait qdbm
{
/**
* @throws FileSystemException
* @throws RuntimeException
*/
protected function build(): void
{
shell()->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']);
}
}

View File

@ -46,6 +46,9 @@ class WindowsBuilder extends BuilderBase
// make cmake toolchain // make cmake toolchain
$this->cmake_toolchain_file = SystemUtil::makeCmakeToolchainFile(); $this->cmake_toolchain_file = SystemUtil::makeCmakeToolchainFile();
f_mkdir(BUILD_INCLUDE_PATH, recursive: true);
f_mkdir(BUILD_LIB_PATH, recursive: true);
} }
/** /**

View File

@ -0,0 +1,24 @@
<?php
declare(strict_types=1);
namespace SPC\builder\windows\library;
use SPC\store\FileSystem;
class qdbm extends WindowsLibraryBase
{
public const NAME = 'qdbm';
protected function build(): void
{
cmd()->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');
}
}

View File

@ -13,14 +13,14 @@ declare(strict_types=1);
// If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`).
$extensions = match (PHP_OS_FAMILY) { $extensions = match (PHP_OS_FAMILY) {
'Linux', 'Darwin' => 'yac', 'Linux', 'Darwin' => 'dba',
'Windows' => 'mbstring,pdo_sqlite,mbregex,yac', 'Windows' => 'mbstring,pdo_sqlite,mbregex,dba',
}; };
// If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`). // If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`).
$with_libs = match (PHP_OS_FAMILY) { $with_libs = match (PHP_OS_FAMILY) {
'Linux', 'Darwin' => '', 'Linux', 'Darwin' => 'qdbm',
'Windows' => '', 'Windows' => 'qdbm',
}; };
// Please change your test base combination. We recommend testing with `common`. // Please change your test base combination. We recommend testing with `common`.
@ -62,7 +62,6 @@ $final_libs = trim($with_libs, $trim_value);
if (PHP_OS_FAMILY === 'Windows') { if (PHP_OS_FAMILY === 'Windows') {
$final_extensions_cmd = '"' . $final_extensions . '"'; $final_extensions_cmd = '"' . $final_extensions . '"';
$final_libs = $final_libs === '' ? '' : ('"' . $final_libs . '"');
} else { } else {
$final_extensions_cmd = $final_extensions; $final_extensions_cmd = $final_extensions;
} }