Compare commits

...

4 Commits

Author SHA1 Message Date
Joseph Bielawski
3d2f6e4c3a Sort lib definition 2023-09-04 23:12:13 +08:00
Joseph Bielawski
88e9639482 Fix operator precedence 2023-09-04 23:12:13 +08:00
Joseph Bielawski
0381a1c412 Adjust extension definition after review 2023-09-04 23:12:13 +08:00
Joseph Bielawski
fdc3a7a04b Add snappy extension 2023-09-04 23:12:13 +08:00
7 changed files with 142 additions and 3 deletions

View File

@ -325,6 +325,18 @@
"libxml2"
]
},
"snappy": {
"type": "external",
"source": "ext-snappy",
"cpp-extension": true,
"arg-type": "custom",
"lib-depends": [
"snappy"
],
"ext-suggest": [
"apcu"
]
},
"snmp": {
"type": "builtin",
"arg-type": "with",
@ -490,4 +502,4 @@
"zstd"
]
}
}
}

View File

@ -445,6 +445,22 @@
"ncurses"
]
},
"snappy": {
"source": "snappy",
"static-libs-unix": [
"libsnappy.a"
],
"headers-unix": [
"snappy-c.h",
"snappy-sinksource.h",
"snappy.h",
"snappy-stubs-internal.h",
"snappy-stubs-public.h"
],
"lib-depends": [
"zlib"
]
},
"sqlite": {
"source": "sqlite",
"static-libs-unix": [
@ -511,4 +527,4 @@
"zstd_errors.h"
]
}
}
}

View File

@ -80,6 +80,16 @@
"path": "LICENSE"
}
},
"ext-snappy": {
"type": "git",
"path": "php-src/ext/snappy",
"rev": "master",
"url": "https://github.com/kjdev/php-ext-snappy",
"license": {
"type": "file",
"path": "LICENSE"
}
},
"ext-ssh2": {
"type": "url",
"url": "https://pecl.php.net/get/ssh2",
@ -401,6 +411,16 @@
"path": "COPYING"
}
},
"snappy": {
"type": "git",
"repo": "google/snappy",
"rev": "main",
"url": "https://github.com/google/snappy",
"license": {
"type": "file",
"path": "COPYING"
}
},
"sqlite": {
"type": "url",
"url": "https://www.sqlite.org/2023/sqlite-autoconf-3410100.tar.gz",
@ -476,4 +496,4 @@
"path": "LICENSE"
}
}
}
}

View File

@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
namespace SPC\builder\extension;
use SPC\builder\Extension;
use SPC\builder\macos\MacOSBuilder;
use SPC\exception\FileSystemException;
use SPC\store\FileSystem;
use SPC\util\CustomExt;
#[CustomExt('snappy')]
class snappy extends Extension
{
/**
* @throws FileSystemException
*/
public function patchBeforeConfigure(): bool
{
FileSystem::replaceFileRegex(
SOURCE_PATH . '/php-src/configure',
'/-lsnappy/',
$this->getLibFilesString() . ($this->builder instanceof MacOSBuilder ? ' -lc++' : ' -lstdc++')
);
return true;
}
public function getUnixConfigureArg(): string
{
return '--enable-snappy --with-snappy-includedir="' . BUILD_ROOT_PATH . '"';
}
}

View File

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

View File

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

View File

@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
namespace SPC\builder\unix\library;
use SPC\exception\FileSystemException;
use SPC\exception\RuntimeException;
use SPC\store\FileSystem;
trait snappy
{
/**
* @throws RuntimeException
* @throws FileSystemException
*/
protected function build(): void
{
FileSystem::resetDir($this->source_dir . '/cmake/build');
shell()->cd($this->source_dir . '/cmake/build')
->exec(
"{$this->builder->configure_env} cmake " .
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
'-DCMAKE_BUILD_TYPE=Release ' .
'-DCMAKE_INSTALL_PREFIX=' . escapeshellarg(BUILD_ROOT_PATH) . ' ' .
'-DSNAPPY_BUILD_TESTS=OFF ' .
'-DSNAPPY_BUILD_BENCHMARKS=OFF ' .
'../..'
)
->exec("cmake --build . -j {$this->builder->concurrency}")
->exec('make install');
}
}