Add mbregex support for windows (#351)

* add mbregex support for windows

* cs fix

* fix curl http2 support
This commit is contained in:
Jerry Ma 2024-02-23 11:41:35 +08:00 committed by GitHub
parent 4ab7b6bfdc
commit df0e37cd0f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 56 additions and 5 deletions

View File

@ -440,10 +440,8 @@
"libonig.a" "libonig.a"
], ],
"static-libs-windows": [ "static-libs-windows": [
[
"onig.lib", "onig.lib",
"onig_a.lib" "onig_a.lib"
]
], ],
"headers": [ "headers": [
"oniggnu.h", "oniggnu.h",

View File

@ -31,4 +31,16 @@ class mbregex extends Extension
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: compiled php-cli mbstring extension does not contain regex !'); throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: compiled php-cli mbstring extension does not contain regex !');
} }
} }
public function runCliCheckWindows(): void
{
[$ret, $out] = cmd()->execWithResult(BUILD_ROOT_PATH . '/bin/php --ri "mbstring"', false);
if ($ret !== 0) {
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: compiled php-cli does not contain mbstring !');
}
$out = implode("\n", $out);
if (!str_contains($out, 'regex')) {
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: compiled php-cli mbstring extension does not contain regex !');
}
}
} }

View File

@ -15,6 +15,8 @@ class mbstring extends Extension
$arg = '--enable-mbstring'; $arg = '--enable-mbstring';
if ($this->builder->getExt('mbregex') === null) { if ($this->builder->getExt('mbregex') === null) {
$arg .= ' --disable-mbregex'; $arg .= ' --disable-mbregex';
} else {
$arg .= ' --enable-mbregex';
} }
return $arg; return $arg;
} }

View File

@ -29,6 +29,7 @@ class curl extends WindowsLibraryBase
'-DUSE_ZLIB=ON ' . '-DUSE_ZLIB=ON ' .
'-DCURL_USE_OPENSSL=ON ' . '-DCURL_USE_OPENSSL=ON ' .
'-DCURL_USE_LIBLSSH2=ON ' . '-DCURL_USE_LIBLSSH2=ON ' .
'-DUSE_NGHTTP2=ON ' . // php-src with curl needs nghttp2
'-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' '-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' '
) )
->execWithWrapper( ->execWithWrapper(

View File

@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
namespace SPC\builder\windows\library;
use SPC\store\FileSystem;
class onig extends WindowsLibraryBase
{
public const NAME = 'onig';
protected function build(): void
{
// reset cmake
FileSystem::resetDir($this->source_dir . '\build');
// start build
cmd()->cd($this->source_dir)
->execWithWrapper(
$this->builder->makeSimpleWrapper('cmake'),
'-B build ' .
'-A x64 ' .
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
'-DCMAKE_BUILD_TYPE=Release ' .
'-DBUILD_SHARED_LIBS=OFF ' .
'-DBUILD_STATIC_LIBS=ON ' .
'-DMSVC_STATIC_RUNTIME=ON ' .
'-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' '
)
->execWithWrapper(
$this->builder->makeSimpleWrapper('cmake'),
"--build build --config Release --target install -j{$this->builder->concurrency}"
);
copy(BUILD_LIB_PATH . '/onig.lib', BUILD_LIB_PATH . '/onig_a.lib');
}
}

View File

@ -14,7 +14,8 @@ declare(strict_types=1);
// If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`).
$extensions = match (PHP_OS_FAMILY) { $extensions = match (PHP_OS_FAMILY) {
'Linux', 'Darwin' => 'event,gettext', 'Linux', 'Darwin' => 'event,gettext',
'Windows' => 'mbstring,pdo_sqlite', 'Linux', 'Darwin' => 'event,gettext',
'Windows' => 'mbstring,pdo_sqlite,mbregex',
}; };
// If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`). // If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`).