Skip to content

Add intl support for windows #756

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ jobs:
echo "UPX_CMD=$(php src/globals/test-extensions.php upx)" >> $GITHUB_ENV

- name: "Run Build Tests (download)"
run: GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} php src/globals/test-extensions.php download_cmd ${{ matrix.os }} ${{ matrix.php }}
run: php src/globals/test-extensions.php download_cmd ${{ matrix.os }} ${{ matrix.php }}

- name: "Run Build Tests (build)"
run: php src/globals/test-extensions.php build_cmd ${{ matrix.os }} ${{ matrix.php }}
Expand Down
26 changes: 14 additions & 12 deletions config/ext.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -323,6 +325,16 @@
"openssl"
]
},
"libxml": {
"support": {
"BSD": "wip"
},
"type": "builtin",
"arg-type": "none",
"ext-depends": [
"xml"
]
},
"lz4": {
"support": {
"Windows": "wip",
Expand All @@ -335,16 +347,6 @@
"liblz4"
]
},
"libxml": {
"support": {
"BSD": "wip"
},
"type": "builtin",
"arg-type": "none",
"ext-depends": [
"xml"
]
},
"mbregex": {
"type": "builtin",
"arg-type": "custom",
Expand Down
12 changes: 12 additions & 0 deletions config/lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
8 changes: 8 additions & 0 deletions config/source.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
21 changes: 15 additions & 6 deletions src/SPC/builder/extension/intl.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace SPC\builder\extension;

use SPC\builder\Extension;
use SPC\builder\windows\WindowsBuilder;
use SPC\store\FileSystem;
use SPC\util\CustomExt;

Expand All @@ -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;
}
Expand Down
27 changes: 27 additions & 0 deletions src/SPC/builder/windows/library/icu_static_win.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

namespace SPC\builder\windows\library;

use SPC\store\FileSystem;

class icu_static_win extends WindowsLibraryBase
{
public const NAME = 'icu-static-win';

protected function build(): void
{
copy("{$this->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");
}
}
16 changes: 8 additions & 8 deletions src/globals/test-extensions.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@

// test os (macos-13, macos-14, macos-15, ubuntu-latest, windows-latest are available)
$test_os = [
'macos-13',
// 'macos-13',
// 'macos-14',
'macos-15',
'ubuntu-latest',
'ubuntu-22.04',
// 'macos-15',
// 'ubuntu-latest',
// 'ubuntu-22.04',
// 'ubuntu-24.04',
'ubuntu-22.04-arm',
// 'ubuntu-22.04-arm',
// 'ubuntu-24.04-arm',
// 'windows-latest',
'windows-latest',
];

// whether enable thread safe
Expand All @@ -46,7 +46,7 @@
// If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`).
$extensions = match (PHP_OS_FAMILY) {
'Linux', 'Darwin' => 'curl',
'Windows' => 'xlswriter,openssl',
'Windows' => 'intl',
};

// If you want to test shared extensions, add them below (comma separated, example `bcmath,openssl`).
Expand All @@ -57,7 +57,7 @@

// If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`).
$with_libs = match (PHP_OS_FAMILY) {
'Linux', 'Darwin' => 'brotli,curl,freetype,gmssl,libaom,libavif,libde265,libevent,libheif,libjpeg,librabbitmq,libssh2,libuuid,libuv,libwebp,libxml2,libyaml,libzip,mimalloc,snappy,tidy,zstd',
'Linux', 'Darwin' => '',
'Windows' => '',
};

Expand Down