diff --git a/config/ext.json b/config/ext.json index 63e511e4..dcb2ba3f 100644 --- a/config/ext.json +++ b/config/ext.json @@ -297,12 +297,14 @@ }, "intl": { "support": { - "Windows": "no", "BSD": "wip" }, "type": "builtin", - "lib-depends": [ + "lib-depends-unix": [ "icu" + ], + "lib-depends-windows": [ + "icu-static-win" ] }, "ldap": { diff --git a/config/lib.json b/config/lib.json index 0d4941f0..3048610a 100644 --- a/config/lib.json +++ b/config/lib.json @@ -198,6 +198,18 @@ "libicudata.a" ] }, + "icu-static-win": { + "source": "icu-static-win", + "static-libs-windows": [ + "icudt.lib", + "icuin.lib", + "icuio.lib", + "icuuc.lib" + ], + "headers-windows": [ + "unicode" + ] + }, "imagemagick": { "source": "imagemagick", "static-libs-unix": [ diff --git a/config/source.json b/config/source.json index 81c21cfd..bc245fae 100644 --- a/config/source.json +++ b/config/source.json @@ -312,6 +312,14 @@ "path": "LICENSE" } }, + "icu-static-win": { + "type": "url", + "url": "https://dl.static-php.dev/static-php-cli/deps/icu-static-windows-x64/icu-static-windows-x64.zip", + "license": { + "type": "text", + "text": "none" + } + }, "igbinary": { "type": "url", "url": "https://pecl.php.net/get/igbinary", diff --git a/src/SPC/builder/extension/intl.php b/src/SPC/builder/extension/intl.php index 8130b5d3..d52a15b0 100644 --- a/src/SPC/builder/extension/intl.php +++ b/src/SPC/builder/extension/intl.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace SPC\builder\extension; use SPC\builder\Extension; +use SPC\builder\windows\WindowsBuilder; use SPC\store\FileSystem; use SPC\util\CustomExt; @@ -13,13 +14,21 @@ class intl extends Extension { public function patchBeforeBuildconf(): bool { - // TODO: remove the following line when https://github.com/php/php-src/pull/14002 will be released - FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/intl/config.m4', 'PHP_CXX_COMPILE_STDCXX(11', 'PHP_CXX_COMPILE_STDCXX(17'); - // Also need to use clang++ -std=c++17 to force override the default C++ standard - if (is_string($env = getenv('CXX')) && !str_contains($env, 'std=c++17')) { - f_putenv('CXX=' . $env . ' -std=c++17'); + if ($this->builder instanceof WindowsBuilder) { + FileSystem::replaceFileStr( + SOURCE_PATH . '/php-src/ext/intl/config.w32', + 'EXTENSION("intl", "php_intl.c intl_convert.c intl_convertcpp.cpp intl_error.c ", true,', + 'EXTENSION("intl", "php_intl.c intl_convert.c intl_convertcpp.cpp intl_error.c ", PHP_INTL_SHARED,' + ); } else { - f_putenv('CXX=clang++ -std=c++17'); + // TODO: remove the following line when https://github.com/php/php-src/pull/14002 will be released + FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/intl/config.m4', 'PHP_CXX_COMPILE_STDCXX(11', 'PHP_CXX_COMPILE_STDCXX(17'); + // Also need to use clang++ -std=c++17 to force override the default C++ standard + if (is_string($env = getenv('CXX')) && !str_contains($env, 'std=c++17')) { + f_putenv('CXX=' . $env . ' -std=c++17'); + } else { + f_putenv('CXX=clang++ -std=c++17'); + } } return true; } diff --git a/src/SPC/builder/windows/library/icu_static_win.php b/src/SPC/builder/windows/library/icu_static_win.php new file mode 100644 index 00000000..04c8e589 --- /dev/null +++ b/src/SPC/builder/windows/library/icu_static_win.php @@ -0,0 +1,27 @@ +source_dir}\\x64-windows-static\lib\icudt.lib", "{$this->getLibDir()}\icudt.lib"); + copy("{$this->source_dir}\\x64-windows-static\lib\icuin.lib", "{$this->getLibDir()}\icuin.lib"); + copy("{$this->source_dir}\\x64-windows-static\lib\icuio.lib", "{$this->getLibDir()}\icuio.lib"); + copy("{$this->source_dir}\\x64-windows-static\lib\icuuc.lib", "{$this->getLibDir()}\icuuc.lib"); + + // create libpq folder in buildroot/includes/libpq + if (!file_exists("{$this->getIncludeDir()}\unicode")) { + mkdir("{$this->getIncludeDir()}\unicode"); + } + + FileSystem::copyDir("{$this->source_dir}\\x64-windows-static\include\unicode", "{$this->getIncludeDir()}\unicode"); + } +}