mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-18 04:44:53 +08:00
Fix windows curl build (using cmake) (#600)
This commit is contained in:
parent
21de1a2291
commit
95d741496e
@ -34,7 +34,7 @@
|
||||
"libcurl.a"
|
||||
],
|
||||
"static-libs-windows": [
|
||||
"libcurl_a.lib"
|
||||
"libcurl.lib"
|
||||
],
|
||||
"headers": [
|
||||
"curl"
|
||||
|
||||
@ -31,7 +31,7 @@ use Symfony\Component\Console\Application;
|
||||
*/
|
||||
final class ConsoleApplication extends Application
|
||||
{
|
||||
public const VERSION = '2.4.4';
|
||||
public const VERSION = '2.4.5';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
@ -203,7 +203,7 @@ class Extension
|
||||
// Run compile check if build target is cli
|
||||
// If you need to run some check, overwrite this or add your assert in src/globals/ext-tests/{extension_name}.php
|
||||
// If check failed, throw RuntimeException
|
||||
[$ret] = cmd()->execWithResult(BUILD_ROOT_PATH . '/bin/php.exe --ri "' . $this->getDistName() . '"', false);
|
||||
[$ret] = cmd()->execWithResult(BUILD_ROOT_PATH . '/bin/php.exe -n --ri "' . $this->getDistName() . '"', false);
|
||||
if ($ret !== 0) {
|
||||
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: php-cli returned ' . $ret);
|
||||
}
|
||||
@ -216,7 +216,7 @@ class Extension
|
||||
file_get_contents(FileSystem::convertPath(ROOT_DIR . '/src/globals/ext-tests/' . $this->getName() . '.php'))
|
||||
);
|
||||
|
||||
[$ret] = cmd()->execWithResult(BUILD_ROOT_PATH . '/bin/php.exe -r "' . trim($test) . '"');
|
||||
[$ret] = cmd()->execWithResult(BUILD_ROOT_PATH . '/bin/php.exe -n -r "' . trim($test) . '"');
|
||||
if ($ret !== 0) {
|
||||
throw new RuntimeException('extension ' . $this->getName() . ' failed sanity check');
|
||||
}
|
||||
|
||||
@ -34,7 +34,7 @@ class mbregex extends Extension
|
||||
|
||||
public function runCliCheckWindows(): void
|
||||
{
|
||||
[$ret, $out] = cmd()->execWithResult(BUILD_ROOT_PATH . '/bin/php --ri "mbstring"', false);
|
||||
[$ret, $out] = cmd()->execWithResult(BUILD_ROOT_PATH . '/bin/php -n --ri "mbstring"', false);
|
||||
if ($ret !== 0) {
|
||||
throw new RuntimeException('extension ' . $this->getName() . ' failed compile check: compiled php-cli does not contain mbstring !');
|
||||
}
|
||||
|
||||
@ -277,7 +277,7 @@ class WindowsBuilder extends BuilderBase
|
||||
// sanity check for php-cli
|
||||
if (($build_target & BUILD_TARGET_CLI) === BUILD_TARGET_CLI) {
|
||||
logger()->info('running cli sanity check');
|
||||
[$ret, $output] = cmd()->execWithResult(BUILD_ROOT_PATH . '\bin\php.exe -r "echo \"hello\";"');
|
||||
[$ret, $output] = cmd()->execWithResult(BUILD_ROOT_PATH . '\bin\php.exe -n -r "echo \"hello\";"');
|
||||
if ($ret !== 0 || trim(implode('', $output)) !== 'hello') {
|
||||
throw new RuntimeException('cli failed sanity check');
|
||||
}
|
||||
|
||||
@ -12,14 +12,41 @@ class curl extends WindowsLibraryBase
|
||||
|
||||
protected function build(): void
|
||||
{
|
||||
FileSystem::createDir(BUILD_BIN_PATH);
|
||||
cmd()->cd($this->source_dir . '\winbuild')
|
||||
// reset cmake
|
||||
FileSystem::resetDir($this->source_dir . '\cmakebuild');
|
||||
|
||||
// lib:zstd
|
||||
$alt = $this->builder->getLib('zstd') ? '' : '-DCURL_ZSTD=OFF';
|
||||
// lib:brotli
|
||||
$alt .= $this->builder->getLib('brotli') ? '' : ' -DCURL_BROTLI=OFF';
|
||||
|
||||
// start build
|
||||
cmd()->cd($this->source_dir)
|
||||
->execWithWrapper(
|
||||
$this->builder->makeSimpleWrapper('nmake'),
|
||||
'/f Makefile.vc WITH_DEVEL=' . BUILD_ROOT_PATH . ' ' .
|
||||
'WITH_PREFIX=' . BUILD_ROOT_PATH . ' ' .
|
||||
'mode=static RTLIBCFG=static WITH_SSL=static WITH_NGHTTP2=static WITH_SSH2=static ENABLE_IPV6=yes WITH_ZLIB=static MACHINE=x64 DEBUG=no'
|
||||
$this->builder->makeSimpleWrapper('cmake'),
|
||||
'-B cmakebuild ' .
|
||||
'-A x64 ' .
|
||||
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
|
||||
'-DCMAKE_BUILD_TYPE=Release ' .
|
||||
'-DBUILD_SHARED_LIBS=OFF ' .
|
||||
'-DBUILD_STATIC_LIBS=ON ' .
|
||||
'-DCURL_STATICLIB=ON ' .
|
||||
'-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' ' .
|
||||
'-DBUILD_CURL_EXE=OFF ' . // disable curl.exe
|
||||
'-DBUILD_TESTING=OFF ' . // disable tests
|
||||
'-DBUILD_EXAMPLES=OFF ' . // disable examples
|
||||
'-DUSE_LIBIDN2=OFF ' . // disable libidn2
|
||||
'-DCURL_USE_LIBPSL=OFF ' . // disable libpsl
|
||||
'-DCURL_ENABLE_SSL=ON ' .
|
||||
'-DUSE_NGHTTP2=ON ' . // enable nghttp2
|
||||
'-DCURL_USE_LIBSSH2=ON ' . // enable libssh2
|
||||
'-DENABLE_IPV6=ON ' . // enable ipv6
|
||||
'-DNGHTTP2_CFLAGS="/DNGHTTP2_STATICLIB" ' .
|
||||
$alt
|
||||
)
|
||||
->execWithWrapper(
|
||||
$this->builder->makeSimpleWrapper('cmake'),
|
||||
"--build cmakebuild --config Release --target install -j{$this->builder->concurrency}"
|
||||
);
|
||||
FileSystem::copyDir($this->source_dir . '\include\curl', BUILD_INCLUDE_PATH . '\curl');
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,14 +21,14 @@ $test_php_version = [
|
||||
|
||||
// test os (macos-13, macos-14, ubuntu-latest, windows-latest are available)
|
||||
$test_os = [
|
||||
'macos-13',
|
||||
'macos-14',
|
||||
'ubuntu-latest',
|
||||
// 'macos-13',
|
||||
// 'macos-14',
|
||||
// 'ubuntu-latest',
|
||||
'windows-latest',
|
||||
];
|
||||
|
||||
// whether enable thread safe
|
||||
$zts = false;
|
||||
$zts = true;
|
||||
|
||||
$no_strip = false;
|
||||
|
||||
@ -36,12 +36,12 @@ $no_strip = false;
|
||||
$upx = false;
|
||||
|
||||
// prefer downloading pre-built packages to speed up the build process
|
||||
$prefer_pre_built = true;
|
||||
$prefer_pre_built = false;
|
||||
|
||||
// If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`).
|
||||
$extensions = match (PHP_OS_FAMILY) {
|
||||
'Linux', 'Darwin' => 'opentelemetry',
|
||||
'Windows' => 'opentelemetry',
|
||||
'Linux', 'Darwin' => 'curl',
|
||||
'Windows' => 'curl',
|
||||
};
|
||||
|
||||
// If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`).
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user