diff --git a/config/ext.json b/config/ext.json index 00f60518..d5234e4e 100644 --- a/config/ext.json +++ b/config/ext.json @@ -328,6 +328,7 @@ "snappy": { "type": "external", "source": "ext-snappy", + "cpp-extension": true, "arg-type": "custom", "lib-depends": [ "snappy" diff --git a/config/lib.json b/config/lib.json index ebcbe668..f4558f83 100644 --- a/config/lib.json +++ b/config/lib.json @@ -522,6 +522,9 @@ "snappy.h", "snappy-stubs-internal.h", "snappy-stubs-public.h" + ], + "lib-depends": [ + "zlib" ] } } diff --git a/src/SPC/builder/extension/snappy.php b/src/SPC/builder/extension/snappy.php index 065b33a7..ad80518f 100644 --- a/src/SPC/builder/extension/snappy.php +++ b/src/SPC/builder/extension/snappy.php @@ -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 . '"'; diff --git a/src/SPC/builder/unix/library/snappy.php b/src/SPC/builder/unix/library/snappy.php index b7924de2..112cf5ed 100644 --- a/src/SPC/builder/unix/library/snappy.php +++ b/src/SPC/builder/unix/library/snappy.php @@ -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'); } }