Skip to content

Commit e3c542d

Browse files
authored
add qdbm for dba (#409)
* add qdbm for dba * add windows support for dba-qdbm * fix test scripts * fix test scripts
1 parent b4ed4ea commit e3c542d

File tree

11 files changed

+138
-7
lines changed

11 files changed

+138
-7
lines changed

.github/workflows/tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,4 +168,4 @@ jobs:
168168
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
169169
170170
- name: "Run Build Tests (build)"
171-
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
171+
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

config/ext.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@
4343
},
4444
"dba": {
4545
"type": "builtin",
46-
"arg-type-windows": "with"
46+
"arg-type": "custom",
47+
"lib-suggests": [
48+
"qdbm"
49+
]
4750
},
4851
"dom": {
4952
"type": "builtin",

config/lib.json

+12
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,18 @@
525525
"zstd"
526526
]
527527
},
528+
"qdbm": {
529+
"source": "qdbm",
530+
"static-libs-unix": [
531+
"libqdbm.a"
532+
],
533+
"static-libs-windows": [
534+
"qdbm_a.lib"
535+
],
536+
"headers-windows": [
537+
"depot.h"
538+
]
539+
},
528540
"readline": {
529541
"source": "readline",
530542
"static-libs-unix": [

config/source.json

+9
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,15 @@
551551
"path": "LICENSE"
552552
}
553553
},
554+
"qdbm": {
555+
"type": "git",
556+
"url": "https://github.com/static-php/qdbm.git",
557+
"rev": "main",
558+
"license": {
559+
"type": "file",
560+
"path": "COPYING"
561+
}
562+
},
554563
"rar": {
555564
"type": "git",
556565
"url": "https://github.com/static-php/php-rar.git",

src/SPC/builder/extension/dba.php

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SPC\builder\extension;
6+
7+
use SPC\builder\Extension;
8+
use SPC\util\CustomExt;
9+
10+
#[CustomExt('dba')]
11+
class dba extends Extension
12+
{
13+
public function getUnixConfigureArg(): string
14+
{
15+
$qdbm = $this->builder->getLib('qdbm') ? (' --with-qdbm=' . BUILD_ROOT_PATH) : '';
16+
return '--enable-dba' . $qdbm;
17+
}
18+
19+
public function getWindowsConfigureArg(): string
20+
{
21+
$qdbm = $this->builder->getLib('qdbm') ? ' --with-qdbm' : '';
22+
return '--with-dba' . $qdbm;
23+
}
24+
}
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SPC\builder\linux\library;
6+
7+
class qdbm extends LinuxLibraryBase
8+
{
9+
use \SPC\builder\unix\library\qdbm;
10+
11+
public const NAME = 'qdbm';
12+
}
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SPC\builder\macos\library;
6+
7+
class qdbm extends MacOSLibraryBase
8+
{
9+
use \SPC\builder\unix\library\qdbm;
10+
11+
public const NAME = 'qdbm';
12+
}

src/SPC/builder/unix/library/qdbm.php

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SPC\builder\unix\library;
6+
7+
use SPC\builder\macos\library\MacOSLibraryBase;
8+
use SPC\exception\FileSystemException;
9+
use SPC\exception\RuntimeException;
10+
use SPC\store\FileSystem;
11+
12+
trait qdbm
13+
{
14+
/**
15+
* @throws FileSystemException
16+
* @throws RuntimeException
17+
*/
18+
protected function build(): void
19+
{
20+
shell()->cd($this->source_dir)
21+
->exec(
22+
'./configure ' .
23+
'--enable-static --disable-shared ' .
24+
'--prefix='
25+
)
26+
->exec('make clean');
27+
FileSystem::replaceFileRegex($this->source_dir . '/Makefile', '/MYLIBS = libqdbm.a.*/m', 'MYLIBS = libqdbm.a');
28+
shell()->cd($this->source_dir)
29+
->exec("make -j{$this->builder->concurrency}" . ($this instanceof MacOSLibraryBase ? ' mac' : ''))
30+
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
31+
$this->patchPkgconfPrefix(['qdbm.pc']);
32+
}
33+
}

src/SPC/builder/windows/WindowsBuilder.php

+3
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ public function __construct(array $options = [])
4646

4747
// make cmake toolchain
4848
$this->cmake_toolchain_file = SystemUtil::makeCmakeToolchainFile();
49+
50+
f_mkdir(BUILD_INCLUDE_PATH, recursive: true);
51+
f_mkdir(BUILD_LIB_PATH, recursive: true);
4952
}
5053

5154
/**
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SPC\builder\windows\library;
6+
7+
use SPC\store\FileSystem;
8+
9+
class qdbm extends WindowsLibraryBase
10+
{
11+
public const NAME = 'qdbm';
12+
13+
protected function build(): void
14+
{
15+
cmd()->cd($this->source_dir)
16+
->execWithWrapper(
17+
$this->builder->makeSimpleWrapper('nmake'),
18+
'/f VCMakefile'
19+
);
20+
copy($this->source_dir . '\qdbm_a.lib', BUILD_LIB_PATH . '\qdbm_a.lib');
21+
copy($this->source_dir . '\depot.h', BUILD_INCLUDE_PATH . '\depot.h');
22+
// FileSystem::copyDir($this->source_dir . '\include\curl', BUILD_INCLUDE_PATH . '\curl');
23+
}
24+
}

src/globals/test-extensions.php

+4-5
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313

1414
// If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`).
1515
$extensions = match (PHP_OS_FAMILY) {
16-
'Linux', 'Darwin' => 'yac',
17-
'Windows' => 'mbstring,pdo_sqlite,mbregex,yac',
16+
'Linux', 'Darwin' => 'dba',
17+
'Windows' => 'mbstring,pdo_sqlite,mbregex,dba',
1818
};
1919

2020
// If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`).
2121
$with_libs = match (PHP_OS_FAMILY) {
22-
'Linux', 'Darwin' => '',
23-
'Windows' => '',
22+
'Linux', 'Darwin' => 'qdbm',
23+
'Windows' => 'qdbm',
2424
};
2525

2626
// Please change your test base combination. We recommend testing with `common`.
@@ -62,7 +62,6 @@ function _getCombination(string $type = 'common'): string
6262

6363
if (PHP_OS_FAMILY === 'Windows') {
6464
$final_extensions_cmd = '"' . $final_extensions . '"';
65-
$final_libs = $final_libs === '' ? '' : ('"' . $final_libs . '"');
6665
} else {
6766
$final_extensions_cmd = $final_extensions;
6867
}

0 commit comments

Comments
 (0)