-
-
Notifications
You must be signed in to change notification settings - Fork 245
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add amqp/librabbitmq support for linux, macos, windows (#366)
* add amqp/librabbitmq support for linux, macos, windows * add test for amqp
- Loading branch information
1 parent
d4c0290
commit 96dd5ba
Showing
9 changed files
with
175 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SPC\builder\extension; | ||
|
||
use SPC\builder\Extension; | ||
use SPC\store\FileSystem; | ||
use SPC\util\CustomExt; | ||
|
||
#[CustomExt('amqp')] | ||
class amqp extends Extension | ||
{ | ||
public function patchBeforeMake(): bool | ||
{ | ||
if (PHP_OS_FAMILY === 'Windows') { | ||
FileSystem::replaceFileRegex(BUILD_INCLUDE_PATH . '\amqp.h', '/^#warning.*/m', ''); | ||
FileSystem::replaceFileRegex(BUILD_INCLUDE_PATH . '\amqp_framing.h', '/^#warning.*/m', ''); | ||
FileSystem::replaceFileRegex(BUILD_INCLUDE_PATH . '\amqp_ssl_socket.h', '/^#warning.*/m', ''); | ||
FileSystem::replaceFileRegex(BUILD_INCLUDE_PATH . '\amqp_tcp_socket.h', '/^#warning.*/m', ''); | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
public function getUnixConfigureArg(): string | ||
{ | ||
return '--with-amqp --with-librabbitmq-dir=' . BUILD_ROOT_PATH; | ||
} | ||
|
||
public function getWindowsConfigureArg(): string | ||
{ | ||
return '--with-amqp'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 librabbitmq extends LinuxLibraryBase | ||
{ | ||
use \SPC\builder\unix\library\librabbitmq; | ||
|
||
public const NAME = 'librabbitmq'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 librabbitmq extends MacOSLibraryBase | ||
{ | ||
use \SPC\builder\unix\library\librabbitmq; | ||
|
||
public const NAME = 'librabbitmq'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SPC\builder\unix\library; | ||
|
||
use SPC\exception\FileSystemException; | ||
use SPC\exception\RuntimeException; | ||
use SPC\store\FileSystem; | ||
|
||
trait librabbitmq | ||
{ | ||
/** | ||
* @throws RuntimeException | ||
* @throws FileSystemException | ||
*/ | ||
protected function build(): void | ||
{ | ||
// CMake needs a clean build directory | ||
FileSystem::resetDir($this->source_dir . '/build'); | ||
// Start build | ||
shell()->cd($this->source_dir . '/build') | ||
->exec( | ||
'cmake ' . | ||
'-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' . | ||
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . | ||
'-DCMAKE_BUILD_TYPE=Release ' . | ||
'-DBUILD_SHARED_LIBS=OFF ' . | ||
'-DBUILD_STATIC_LIBS=ON ' . | ||
'..' | ||
) | ||
->exec("cmake --build . -j {$this->builder->concurrency}") | ||
->exec('make install'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SPC\builder\windows\library; | ||
|
||
use SPC\store\FileSystem; | ||
|
||
class librabbitmq extends WindowsLibraryBase | ||
{ | ||
public const NAME = 'librabbitmq'; | ||
|
||
protected function build(): void | ||
{ | ||
// reset cmake | ||
FileSystem::resetDir($this->source_dir . '\build'); | ||
|
||
// start build | ||
cmd()->cd($this->source_dir) | ||
->execWithWrapper( | ||
$this->builder->makeSimpleWrapper('cmake'), | ||
'-B build ' . | ||
'-A x64 ' . | ||
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " . | ||
'-DCMAKE_BUILD_TYPE=Release ' . | ||
'-DBUILD_SHARED_LIBS=OFF ' . | ||
'-DBUILD_STATIC_LIBS=ON ' . | ||
'-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' | ||
) | ||
->execWithWrapper( | ||
$this->builder->makeSimpleWrapper('cmake'), | ||
"--build build --config Release --target install -j{$this->builder->concurrency}" | ||
); | ||
rename(BUILD_LIB_PATH . '\librabbitmq.4.lib', BUILD_LIB_PATH . '\rabbitmq.4.lib'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters