Skip to content

Commit a1251a7

Browse files
committed
Add snappy extension
1 parent 6de5c1d commit a1251a7

File tree

7 files changed

+120
-3
lines changed

7 files changed

+120
-3
lines changed

config/ext.json

+12-1
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,17 @@
325325
"libxml2"
326326
]
327327
},
328+
"snappy": {
329+
"type": "external",
330+
"source": "ext-snappy",
331+
"arg-type": "custom",
332+
"lib-depends": [
333+
"snappy"
334+
],
335+
"ext-suggest": [
336+
"apcu"
337+
]
338+
},
328339
"snmp": {
329340
"type": "builtin",
330341
"arg-type": "with",
@@ -490,4 +501,4 @@
490501
"zstd"
491502
]
492503
}
493-
}
504+
}

config/lib.json

+14-1
Original file line numberDiff line numberDiff line change
@@ -510,5 +510,18 @@
510510
"zstd.h",
511511
"zstd_errors.h"
512512
]
513+
},
514+
"snappy": {
515+
"source": "snappy",
516+
"static-libs-unix": [
517+
"libsnappy.a"
518+
],
519+
"headers-unix": [
520+
"snappy-c.h",
521+
"snappy-sinksource.h",
522+
"snappy.h",
523+
"snappy-stubs-internal.h",
524+
"snappy-stubs-public.h"
525+
]
513526
}
514-
}
527+
}

config/source.json

+21-1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,16 @@
8080
"path": "LICENSE"
8181
}
8282
},
83+
"ext-snappy": {
84+
"type": "git",
85+
"path": "php-src/ext/snappy",
86+
"rev": "master",
87+
"url": "https://github.com/kjdev/php-ext-snappy",
88+
"license": {
89+
"type": "file",
90+
"path": "LICENSE"
91+
}
92+
},
8393
"ext-ssh2": {
8494
"type": "url",
8595
"url": "https://pecl.php.net/get/ssh2",
@@ -401,6 +411,16 @@
401411
"path": "COPYING"
402412
}
403413
},
414+
"snappy": {
415+
"type": "git",
416+
"repo": "google/snappy",
417+
"rev": "main",
418+
"url": "https://github.com/google/snappy",
419+
"license": {
420+
"type": "file",
421+
"path": "COPYING"
422+
}
423+
},
404424
"sqlite": {
405425
"type": "url",
406426
"url": "https://www.sqlite.org/2023/sqlite-autoconf-3410100.tar.gz",
@@ -476,4 +496,4 @@
476496
"path": "LICENSE"
477497
}
478498
}
479-
}
499+
}

src/SPC/builder/extension/snappy.php

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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('snappy')]
11+
class snappy extends Extension
12+
{
13+
public function getUnixConfigureArg(): string
14+
{
15+
return '--enable-snappy --with-snappy-includedir="' . BUILD_ROOT_PATH . '"';
16+
}
17+
}
+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 snappy extends LinuxLibraryBase
8+
{
9+
use \SPC\builder\unix\library\snappy;
10+
11+
public const NAME = 'snappy';
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 snappy extends MacOSLibraryBase
8+
{
9+
use \SPC\builder\unix\library\snappy;
10+
11+
public const NAME = 'snappy';
12+
}
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SPC\builder\unix\library;
6+
7+
use SPC\exception\FileSystemException;
8+
use SPC\exception\RuntimeException;
9+
use SPC\store\FileSystem;
10+
11+
trait snappy
12+
{
13+
/**
14+
* @throws RuntimeException
15+
* @throws FileSystemException
16+
*/
17+
protected function build(): void
18+
{
19+
FileSystem::resetDir($this->source_dir . '/cmake/build');
20+
21+
shell()->cd($this->source_dir . '/cmake/build')
22+
->exec(
23+
"{$this->builder->configure_env} cmake " .
24+
"{$this->builder->makeCmakeArgs()} " .
25+
'-DSNAPPY_BUILD_TESTS=OFF ' .
26+
'-DSNAPPY_BUILD_BENCHMARKS=OFF ' .
27+
'../..'
28+
)
29+
->exec("cmake --build . -j {$this->builder->concurrency}")
30+
->exec('make install DESTDIR=' . BUILD_ROOT_PATH);
31+
}
32+
}

0 commit comments

Comments
 (0)