Skip to content

Commit 48cb87a

Browse files
committed
Add intl support for windows
1 parent a48680c commit 48cb87a

File tree

5 files changed

+66
-8
lines changed

5 files changed

+66
-8
lines changed

config/ext.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,12 +297,14 @@
297297
},
298298
"intl": {
299299
"support": {
300-
"Windows": "no",
301300
"BSD": "wip"
302301
},
303302
"type": "builtin",
304-
"lib-depends": [
303+
"lib-depends-unix": [
305304
"icu"
305+
],
306+
"lib-depends-windows": [
307+
"icu-static-win"
306308
]
307309
},
308310
"ldap": {

config/lib.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,18 @@
198198
"libicudata.a"
199199
]
200200
},
201+
"icu-static-win": {
202+
"source": "icu-static-win",
203+
"static-libs-windows": [
204+
"icudt.lib",
205+
"icuin.lib",
206+
"icuio.lib",
207+
"icuuc.lib"
208+
],
209+
"headers-windows": [
210+
"unicode"
211+
]
212+
},
201213
"imagemagick": {
202214
"source": "imagemagick",
203215
"static-libs-unix": [

config/source.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,14 @@
312312
"path": "LICENSE"
313313
}
314314
},
315+
"icu-static-win": {
316+
"type": "url",
317+
"url": "https://dl.static-php.dev/static-php-cli/deps/icu-static-windows-x64/icu-static-windows-x64.zip",
318+
"license": {
319+
"type": "text",
320+
"text": "none"
321+
}
322+
},
315323
"igbinary": {
316324
"type": "url",
317325
"url": "https://pecl.php.net/get/igbinary",

src/SPC/builder/extension/intl.php

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace SPC\builder\extension;
66

77
use SPC\builder\Extension;
8+
use SPC\builder\windows\WindowsBuilder;
89
use SPC\store\FileSystem;
910
use SPC\util\CustomExt;
1011

@@ -13,13 +14,21 @@ class intl extends Extension
1314
{
1415
public function patchBeforeBuildconf(): bool
1516
{
16-
// TODO: remove the following line when https://github.com/php/php-src/pull/14002 will be released
17-
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/intl/config.m4', 'PHP_CXX_COMPILE_STDCXX(11', 'PHP_CXX_COMPILE_STDCXX(17');
18-
// Also need to use clang++ -std=c++17 to force override the default C++ standard
19-
if (is_string($env = getenv('CXX')) && !str_contains($env, 'std=c++17')) {
20-
f_putenv('CXX=' . $env . ' -std=c++17');
17+
if ($this->builder instanceof WindowsBuilder) {
18+
FileSystem::replaceFileStr(
19+
SOURCE_PATH . '/php-src/ext/intl/config.w32',
20+
'EXTENSION("intl", "php_intl.c intl_convert.c intl_convertcpp.cpp intl_error.c ", true,',
21+
'EXTENSION("intl", "php_intl.c intl_convert.c intl_convertcpp.cpp intl_error.c ", PHP_INTL_SHARED,'
22+
);
2123
} else {
22-
f_putenv('CXX=clang++ -std=c++17');
24+
// TODO: remove the following line when https://github.com/php/php-src/pull/14002 will be released
25+
FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/ext/intl/config.m4', 'PHP_CXX_COMPILE_STDCXX(11', 'PHP_CXX_COMPILE_STDCXX(17');
26+
// Also need to use clang++ -std=c++17 to force override the default C++ standard
27+
if (is_string($env = getenv('CXX')) && !str_contains($env, 'std=c++17')) {
28+
f_putenv('CXX=' . $env . ' -std=c++17');
29+
} else {
30+
f_putenv('CXX=clang++ -std=c++17');
31+
}
2332
}
2433
return true;
2534
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SPC\builder\windows\library;
6+
7+
use SPC\store\FileSystem;
8+
9+
class icu_static_win extends WindowsLibraryBase
10+
{
11+
public const NAME = 'icu-static-win';
12+
13+
protected function build(): void
14+
{
15+
copy("{$this->source_dir}\\x64-windows-static\lib\icudt.lib", "{$this->getLibDir()}\icudt.lib");
16+
copy("{$this->source_dir}\\x64-windows-static\lib\icuin.lib", "{$this->getLibDir()}\icuin.lib");
17+
copy("{$this->source_dir}\\x64-windows-static\lib\icuio.lib", "{$this->getLibDir()}\icuio.lib");
18+
copy("{$this->source_dir}\\x64-windows-static\lib\icuuc.lib", "{$this->getLibDir()}\icuuc.lib");
19+
20+
// create libpq folder in buildroot/includes/libpq
21+
if (!file_exists("{$this->getIncludeDir()}\unicode")) {
22+
mkdir("{$this->getIncludeDir()}\unicode");
23+
}
24+
25+
FileSystem::copyDir("{$this->source_dir}\\x64-windows-static\include\unicode", "{$this->getIncludeDir()}\unicode");
26+
}
27+
}

0 commit comments

Comments
 (0)