diff --git a/config/pkg/ext/ext-spx.yml b/config/pkg/ext/ext-spx.yml new file mode 100644 index 00000000..a379cdd4 --- /dev/null +++ b/config/pkg/ext/ext-spx.yml @@ -0,0 +1,14 @@ +ext-spx: + type: php-extension + artifact: + source: + type: pie + repo: noisebynorthwest/php-spx + extract: php-src/ext/spx + metadata: + license-files: [LICENSE] + license: GPL-3.0-or-later + depends: + - ext-zlib + php-extension: + arg-type: '--enable-SPX@shared_suffix@' diff --git a/src/Package/Extension/spx.php b/src/Package/Extension/spx.php new file mode 100644 index 00000000..bb230ec9 --- /dev/null +++ b/src/Package/Extension/spx.php @@ -0,0 +1,52 @@ +getSourceDir()}/config.m4", + 'CFLAGS="$CFLAGS -Werror -Wall -O3 -pthread -std=gnu90"', + 'CFLAGS="$CFLAGS -pthread"' + ); + FileSystem::replaceFileStr( + "{$this->getSourceDir()}/src/php_spx.h", + "extern zend_module_entry spx_module_entry;\n", + "extern zend_module_entry spx_module_entry;;\n#define phpext_spx_ptr &spx_module_entry\n" + ); + FileSystem::copy("{$this->getSourceDir()}/src/php_spx.h", "{$this->getSourceDir()}/php_spx.h"); + return true; + } + + #[BeforeStage('php', [php::class, 'configureForUnix'], 'ext-spx')] + #[PatchDescription('Fix spx extension compile error when configuring')] + public function patchBeforeConfigure(): void + { + FileSystem::replaceFileStr( + "{$this->getSourceDir()}/Makefile.frag", + '@cp -r assets/web-ui/*', + "@cp -r {$this->getSourceDir()}/assets/web-ui/*", + ); + } + + public function getSharedExtensionEnv(): array + { + $env = parent::getSharedExtensionEnv(); + $env['SPX_SHARED_LIBADD'] = $env['LIBS']; + return $env; + } +}