Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion config/ext.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -490,4 +502,4 @@
"zstd"
]
}
}
}
18 changes: 17 additions & 1 deletion config/lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down Expand Up @@ -511,4 +527,4 @@
"zstd_errors.h"
]
}
}
}
22 changes: 21 additions & 1 deletion config/source.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -476,4 +496,4 @@
"path": "LICENSE"
}
}
}
}
33 changes: 33 additions & 0 deletions src/SPC/builder/extension/snappy.php
Original file line number Diff line number Diff line change
@@ -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 . '"';
}
}
12 changes: 12 additions & 0 deletions src/SPC/builder/linux/library/snappy.php
Original file line number Diff line number Diff line change
@@ -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';
}
12 changes: 12 additions & 0 deletions src/SPC/builder/macos/library/snappy.php
Original file line number Diff line number Diff line change
@@ -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';
}
34 changes: 34 additions & 0 deletions src/SPC/builder/unix/library/snappy.php
Original file line number Diff line number Diff line change
@@ -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');
}
}