Skip to content

Commit 5d10433

Browse files
authored
Add extension maxminddb support for macOS and Linux (#975)
1 parent f24cbcf commit 5d10433

File tree

9 files changed

+120
-9
lines changed

9 files changed

+120
-9
lines changed

config/ext.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,18 @@
358358
"liblz4"
359359
]
360360
},
361+
"maxminddb": {
362+
"support": {
363+
"BSD": "wip",
364+
"Windows": "wip"
365+
},
366+
"type": "external",
367+
"source": "ext-maxminddb",
368+
"arg-type": "with",
369+
"lib-depends": [
370+
"libmaxminddb"
371+
]
372+
},
361373
"mbregex": {
362374
"type": "builtin",
363375
"arg-type": "custom",

config/lib.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,16 @@
506506
"liblz4.a"
507507
]
508508
},
509+
"libmaxminddb": {
510+
"source": "libmaxminddb",
511+
"static-libs-unix": [
512+
"libmaxminddb.a"
513+
],
514+
"headers": [
515+
"maxminddb.h",
516+
"maxminddb_config.h"
517+
]
518+
},
509519
"libmemcached": {
510520
"source": "libmemcached",
511521
"cpp-library": true,

config/source.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,15 @@
184184
]
185185
}
186186
},
187+
"ext-maxminddb": {
188+
"type": "url",
189+
"url": "https://pecl.php.net/get/maxminddb",
190+
"filename": "ext-maxminddb.tgz",
191+
"license": {
192+
"type": "file",
193+
"path": "LICENSE"
194+
}
195+
},
187196
"ext-memcache": {
188197
"type": "url",
189198
"url": "https://pecl.php.net/get/memcache",
@@ -641,6 +650,16 @@
641650
"path": "LICENSE"
642651
}
643652
},
653+
"libmaxminddb": {
654+
"type": "ghrel",
655+
"repo": "maxmind/libmaxminddb",
656+
"match": "libmaxminddb-.+\\.tar\\.gz",
657+
"prefer-stable": true,
658+
"license": {
659+
"type": "file",
660+
"path": "LICENSE"
661+
}
662+
},
644663
"libmemcached": {
645664
"type": "ghtagtar",
646665
"repo": "awesomized/libmemcached",

src/SPC/ConsoleApplication.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
*/
3535
final class ConsoleApplication extends Application
3636
{
37-
public const string VERSION = '2.7.7';
37+
public const string VERSION = '2.7.8';
3838

3939
public function __construct()
4040
{
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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('maxminddb')]
11+
class maxminddb extends Extension
12+
{
13+
public function patchBeforeBuildconf(): bool
14+
{
15+
if (!is_link(SOURCE_PATH . '/php-src/ext/maxminddb')) {
16+
$original = $this->source_dir;
17+
if (PHP_OS_FAMILY === 'Windows') {
18+
f_passthru('cd ' . SOURCE_PATH . '/php-src/ext && mklink /D maxminddb ' . $original . '\ext');
19+
} else {
20+
f_passthru('cd ' . SOURCE_PATH . '/php-src/ext && ln -s ' . $original . '/ext maxminddb');
21+
}
22+
return true;
23+
}
24+
return false;
25+
}
26+
}
Lines changed: 12 additions & 0 deletions
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 libmaxminddb extends LinuxLibraryBase
8+
{
9+
use \SPC\builder\unix\library\libmaxminddb;
10+
11+
public const NAME = 'libmaxminddb';
12+
}
Lines changed: 12 additions & 0 deletions
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 libmaxminddb extends MacOSLibraryBase
8+
{
9+
use \SPC\builder\unix\library\libmaxminddb;
10+
11+
public const NAME = 'libmaxminddb';
12+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SPC\builder\unix\library;
6+
7+
use SPC\util\executor\UnixCMakeExecutor;
8+
9+
trait libmaxminddb
10+
{
11+
protected function build(): void
12+
{
13+
UnixCMakeExecutor::create($this)
14+
->addConfigureArgs(
15+
'-DBUILD_TESTING=OFF',
16+
'-DMAXMINDDB_BUILD_BINARIES=OFF',
17+
)
18+
->build();
19+
}
20+
}

src/globals/test-extensions.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313

1414
// test php version (8.1 ~ 8.4 available, multiple for matrix)
1515
$test_php_version = [
16-
// '8.1',
17-
// '8.2',
18-
// '8.3',
16+
'8.1',
17+
'8.2',
18+
'8.3',
1919
'8.4',
20-
// '8.5',
20+
'8.5',
2121
// 'git',
2222
];
2323

@@ -35,7 +35,7 @@
3535
];
3636

3737
// whether enable thread safe
38-
$zts = true;
38+
$zts = false;
3939

4040
$no_strip = false;
4141

@@ -50,7 +50,7 @@
5050

5151
// If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`).
5252
$extensions = match (PHP_OS_FAMILY) {
53-
'Linux', 'Darwin' => 'curl',
53+
'Linux', 'Darwin' => 'maxminddb',
5454
'Windows' => 'bcmath',
5555
};
5656

@@ -62,7 +62,7 @@
6262
};
6363

6464
// If you want to test lib-suggests for all extensions and libraries, set it to true.
65-
$with_suggested_libs = true;
65+
$with_suggested_libs = false;
6666

6767
// If you want to test extra libs for extensions, add them below (comma separated, example `libwebp,libavif`). Unnecessary, when $with_suggested_libs is true.
6868
$with_libs = match (PHP_OS_FAMILY) {
@@ -74,7 +74,7 @@
7474
// You can use `common`, `bulk`, `minimal` or `none`.
7575
// note: combination is only available for *nix platform. Windows must use `none` combination
7676
$base_combination = match (PHP_OS_FAMILY) {
77-
'Linux', 'Darwin' => 'none',
77+
'Linux', 'Darwin' => 'minimal',
7878
'Windows' => 'none',
7979
};
8080

0 commit comments

Comments
 (0)