Skip to content

Commit b04ffad

Browse files
authored
Merge pull request #756 from crazywhalecc/feat/intl-win
Add intl support for windows
2 parents 5681722 + 3ac4a71 commit b04ffad

File tree

7 files changed

+68
-13
lines changed

7 files changed

+68
-13
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ jobs:
190190
echo "UPX_CMD=$(php src/globals/test-extensions.php upx)" >> $GITHUB_ENV
191191
192192
- name: "Run Build Tests (download)"
193-
run: GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} php src/globals/test-extensions.php download_cmd ${{ matrix.os }} ${{ matrix.php }}
193+
run: php src/globals/test-extensions.php download_cmd ${{ matrix.os }} ${{ matrix.php }}
194194

195195
- name: "Run Build Tests (build)"
196196
run: php src/globals/test-extensions.php build_cmd ${{ matrix.os }} ${{ matrix.php }}

config/ext.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,12 +304,14 @@
304304
},
305305
"intl": {
306306
"support": {
307-
"Windows": "no",
308307
"BSD": "wip"
309308
},
310309
"type": "builtin",
311-
"lib-depends": [
310+
"lib-depends-unix": [
312311
"icu"
312+
],
313+
"lib-depends-windows": [
314+
"icu-static-win"
313315
]
314316
},
315317
"ldap": {
@@ -336,6 +338,9 @@
336338
},
337339
"type": "builtin",
338340
"arg-type": "none",
341+
"ext-depends": [
342+
"xml"
343+
],
339344
"target": [
340345
"static"
341346
]

config/lib.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,18 @@
207207
"libicudata.a"
208208
]
209209
},
210+
"icu-static-win": {
211+
"source": "icu-static-win",
212+
"static-libs-windows": [
213+
"icudt.lib",
214+
"icuin.lib",
215+
"icuio.lib",
216+
"icuuc.lib"
217+
],
218+
"headers-windows": [
219+
"unicode"
220+
]
221+
},
210222
"imagemagick": {
211223
"source": "imagemagick",
212224
"static-libs-unix": [

config/source.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,14 @@
342342
"path": "LICENSE"
343343
}
344344
},
345+
"icu-static-win": {
346+
"type": "url",
347+
"url": "https://dl.static-php.dev/static-php-cli/deps/icu-static-windows-x64/icu-static-windows-x64.zip",
348+
"license": {
349+
"type": "text",
350+
"text": "none"
351+
}
352+
},
345353
"igbinary": {
346354
"type": "url",
347355
"url": "https://pecl.php.net/get/igbinary",

src/SPC/builder/extension/intl.php

Lines changed: 9 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,15 @@ 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+
);
23+
return true;
2124
}
22-
return true;
25+
return false;
2326
}
2427

2528
public function patchBeforeSharedPhpize(): bool
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+
}

src/globals/test-extensions.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
// 'ubuntu-latest',
2828
// 'ubuntu-22.04',
2929
// 'ubuntu-24.04',
30-
'ubuntu-22.04-arm',
30+
// 'ubuntu-22.04-arm',
3131
// 'ubuntu-24.04-arm',
32-
// 'windows-latest',
32+
'windows-latest',
3333
];
3434

3535
// whether enable thread safe
@@ -48,8 +48,8 @@
4848

4949
// If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`).
5050
$extensions = match (PHP_OS_FAMILY) {
51-
'Linux', 'Darwin' => 'apcu,ast,bcmath,calendar,ctype,curl,dba,dom,exif,fileinfo,filter,iconv,libxml,mbregex,mbstring,opcache,openssl,pcntl,phar,posix,readline,session,simplexml,sockets,sodium,tokenizer,xml,xmlreader,xmlwriter,zip,zlib',
52-
'Windows' => 'xlswriter,openssl',
51+
'Linux', 'Darwin' => 'curl',
52+
'Windows' => 'intl',
5353
};
5454

5555
// If you want to test shared extensions, add them below (comma separated, example `bcmath,openssl`).

0 commit comments

Comments
 (0)