Adjust extension definition after review

This commit is contained in:
Joseph Bielawski 2023-09-03 18:59:00 +02:00 committed by Jerry Ma
parent fdc3a7a04b
commit 0381a1c412
4 changed files with 24 additions and 2 deletions

View File

@ -328,6 +328,7 @@
"snappy": {
"type": "external",
"source": "ext-snappy",
"cpp-extension": true,
"arg-type": "custom",
"lib-depends": [
"snappy"

View File

@ -522,6 +522,9 @@
"snappy.h",
"snappy-stubs-internal.h",
"snappy-stubs-public.h"
],
"lib-depends": [
"zlib"
]
}
}

View File

@ -5,11 +5,27 @@ 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

@ -21,12 +21,14 @@ trait snappy
shell()->cd($this->source_dir . '/cmake/build')
->exec(
"{$this->builder->configure_env} cmake " .
"{$this->builder->makeCmakeArgs()} " .
"-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 DESTDIR=' . BUILD_ROOT_PATH);
->exec('make install');
}
}