From e67e13e81facf45cbcc536dd738f9ee0e065bef5 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sun, 28 Jul 2024 14:02:17 +0800 Subject: [PATCH] Fix imap and rar build on macOS bug --- src/SPC/builder/extension/imap.php | 12 +++++++++++ src/SPC/builder/extension/rar.php | 28 ++++++++++++++++++++++++++ src/SPC/builder/macos/library/imap.php | 3 ++- src/SPC/store/SourcePatcher.php | 3 +++ src/globals/test-extensions.php | 2 +- 5 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 src/SPC/builder/extension/rar.php diff --git a/src/SPC/builder/extension/imap.php b/src/SPC/builder/extension/imap.php index bdb1cd8c..3aa2c284 100644 --- a/src/SPC/builder/extension/imap.php +++ b/src/SPC/builder/extension/imap.php @@ -6,11 +6,23 @@ namespace SPC\builder\extension; use SPC\builder\Extension; use SPC\exception\WrongUsageException; +use SPC\store\FileSystem; use SPC\util\CustomExt; #[CustomExt('imap')] class imap extends Extension { + public function patchBeforeBuildconf(): bool + { + if ($this->builder->getLib('openssl')) { + // sometimes imap with openssl does not contain zlib (required by openssl) + // we need to add it manually + FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/imap/config.m4', 'TST_LIBS="$DLIBS $IMAP_SHARED_LIBADD"', 'TST_LIBS="$DLIBS $IMAP_SHARED_LIBADD -lz"'); + return true; + } + return false; + } + /** * @throws WrongUsageException */ diff --git a/src/SPC/builder/extension/rar.php b/src/SPC/builder/extension/rar.php new file mode 100644 index 00000000..5f3aaa01 --- /dev/null +++ b/src/SPC/builder/extension/rar.php @@ -0,0 +1,28 @@ += 15.0) + if ($this->builder instanceof MacOSBuilder) { + FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/rar/config.m4', '-Wall -fvisibility=hidden', '-Wall -Wno-incompatible-function-pointer-types -fvisibility=hidden'); + return true; + } + return false; + } +} diff --git a/src/SPC/builder/macos/library/imap.php b/src/SPC/builder/macos/library/imap.php index 2deb17ab..843e0c34 100644 --- a/src/SPC/builder/macos/library/imap.php +++ b/src/SPC/builder/macos/library/imap.php @@ -47,6 +47,7 @@ class imap extends MacOSLibraryBase } else { $ssl_options = 'SSLTYPE=none'; } + $out = shell()->execWithResult('echo "-include $(xcrun --show-sdk-path)/usr/include/poll.h -include $(xcrun --show-sdk-path)/usr/include/time.h -include $(xcrun --show-sdk-path)/usr/include/utime.h"')[1][0]; shell()->cd($this->source_dir) ->exec('make clean') ->exec('touch ip6') @@ -55,7 +56,7 @@ class imap extends MacOSLibraryBase ->exec('chmod +x src/osdep/unix/drivers') ->exec('chmod +x src/osdep/unix/mkauths') ->exec( - "yes | EXTRACFLAGS='-Wimplicit-function-declaration -include $(xcrun --show-sdk-path)/usr/include/poll.h -include $(xcrun --show-sdk-path)/usr/include/time.h -include $(xcrun --show-sdk-path)/usr/include/utime.h' make osx {$ssl_options}" + "yes | make osx {$ssl_options} EXTRACFLAGS='-Wimplicit-function-declaration -Wno-incompatible-function-pointer-types {$out}'" ); try { shell() diff --git a/src/SPC/store/SourcePatcher.php b/src/SPC/store/SourcePatcher.php index 0ba1c0a5..47b8c05f 100644 --- a/src/SPC/store/SourcePatcher.php +++ b/src/SPC/store/SourcePatcher.php @@ -57,6 +57,9 @@ class SourcePatcher ); } + // patch php-src/build/php.m4 PKG_CHECK_MODULES -> PKG_CHECK_MODULES_STATIC + FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/build/php.m4', 'PKG_CHECK_MODULES(', 'PKG_CHECK_MODULES_STATIC('); + if ($builder->getOption('enable-micro-win32')) { SourcePatcher::patchMicroWin32(); } else { diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 95f43889..8a803a5b 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -19,7 +19,7 @@ $upx = true; // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'intl', + 'Linux', 'Darwin' => 'imap,swoole,openssl,rar', 'Windows' => 'amqp,apcu', };