diff --git a/config/ext.json b/config/ext.json index 32c6ea346..b8fccc63c 100644 --- a/config/ext.json +++ b/config/ext.json @@ -1,4 +1,15 @@ { + "amqp": { + "type": "external", + "arg-type": "custom", + "source": "amqp", + "lib-depends": [ + "librabbitmq" + ], + "ext-depends-windows": [ + "openssl" + ] + }, "apcu": { "type": "external", "source": "apcu" diff --git a/config/lib.json b/config/lib.json index 586e3f960..5b47bc91d 100644 --- a/config/lib.json +++ b/config/lib.json @@ -305,6 +305,18 @@ "zlib" ] }, + "librabbitmq": { + "source": "librabbitmq", + "static-libs-unix": [ + "librabbitmq.a" + ], + "static-libs-windows": [ + "rabbitmq.4.lib" + ], + "lib-depends": [ + "openssl" + ] + }, "libsodium": { "source": "libsodium", "static-libs-unix": [ diff --git a/config/source.json b/config/source.json index c9d8c687d..e9f9dc8a7 100644 --- a/config/source.json +++ b/config/source.json @@ -6,6 +6,16 @@ "path": "LICENSE" } }, + "amqp": { + "type": "url", + "url": "https://pecl.php.net/get/amqp", + "path": "php-src/ext/amqp", + "filename": "amqp.tgz", + "license": { + "type": "file", + "path": "LICENSE" + } + }, "apcu": { "type": "url", "url": "https://pecl.php.net/get/APCu", @@ -317,6 +327,15 @@ "path": "LICENSE" } }, + "librabbitmq": { + "type": "git", + "url": "https://github.com/alanxz/rabbitmq-c.git", + "rev": "master", + "license": { + "type": "file", + "path": "LICENSE" + } + }, "libsodium": { "type": "ghrel", "repo": "jedisct1/libsodium", diff --git a/src/SPC/builder/extension/amqp.php b/src/SPC/builder/extension/amqp.php new file mode 100644 index 000000000..d795f47d9 --- /dev/null +++ b/src/SPC/builder/extension/amqp.php @@ -0,0 +1,35 @@ +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'); + } +} diff --git a/src/SPC/builder/windows/library/librabbitmq.php b/src/SPC/builder/windows/library/librabbitmq.php new file mode 100644 index 000000000..19c33a31e --- /dev/null +++ b/src/SPC/builder/windows/library/librabbitmq.php @@ -0,0 +1,36 @@ +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'); + } +} diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index c01071be5..c82820212 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -13,8 +13,8 @@ // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'uuid', - 'Windows' => 'mbstring,pdo_sqlite,mbregex,ffi', + 'Linux', 'Darwin' => 'amqp', + 'Windows' => 'mbstring,pdo_sqlite,mbregex,ffi,amqp', }; // If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`). @@ -27,7 +27,7 @@ // You can use `common`, `bulk`, `minimal` or `none`. // note: combination is only available for *nix platform. Windows must use `none` combination $base_combination = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'minimal', + 'Linux', 'Darwin' => 'common', 'Windows' => 'none', };