mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-17 20:34:51 +08:00
Fix windows curl build (#368)
* fix curl on windows build needs nghttp2.dll bug * add curl on windows tests * cs fix * fix curl headers * exit powershell properly * reproduce zend_mm_heap corrupted * reproduce zend_mm_heap corrupted * reproduce zend_mm_heap corrupted * add for-libs option for download * add for-libs option for download * add for-libs option for download
This commit is contained in:
parent
8e58592a6e
commit
03510073c6
3
.github/workflows/tests.yml
vendored
3
.github/workflows/tests.yml
vendored
@ -164,7 +164,8 @@ jobs:
|
||||
timeout_minutes: 10
|
||||
max_attempts: 3
|
||||
retry_on: error
|
||||
command: bin/spc download --for-extensions="$(php src/globals/test-extensions.php extensions)" --with-php=${{ matrix.php }} --debug
|
||||
command: |
|
||||
bin/spc download --for-extensions="$(php src/globals/test-extensions.php extensions)" --with-php=${{ matrix.php }} --debug
|
||||
|
||||
- name: "Run Build Tests (build)"
|
||||
run: bin/spc build "$(php src/globals/test-extensions.php extensions)" $(php src/globals/test-extensions.php libs_cmd) --build-cli --build-micro --build-fpm --debug
|
||||
|
||||
@ -9,3 +9,4 @@ if (-not(Test-Path $PHP_Exec)) {
|
||||
}
|
||||
|
||||
& "$PHP_Exec" ("bin/spc") @args
|
||||
exit $LASTEXITCODE
|
||||
|
||||
@ -52,6 +52,9 @@
|
||||
"lib-depends": [
|
||||
"libxml2",
|
||||
"zlib"
|
||||
],
|
||||
"ext-depends-windows": [
|
||||
"xml"
|
||||
]
|
||||
},
|
||||
"event": {
|
||||
|
||||
@ -36,7 +36,7 @@
|
||||
"libcurl.a"
|
||||
],
|
||||
"static-libs-windows": [
|
||||
"libcurl.lib"
|
||||
"libcurl_a.lib"
|
||||
],
|
||||
"headers": [
|
||||
"curl"
|
||||
|
||||
@ -88,7 +88,7 @@ class WindowsBuilder extends BuilderBase
|
||||
if (($logo = $this->getOption('with-micro-logo')) !== null) {
|
||||
// realpath
|
||||
$logo = realpath($logo);
|
||||
$micro_logo = '--enable-micro-logo=' . escapeshellarg($logo) . ' ';
|
||||
$micro_logo = '--enable-micro-logo=' . $logo . ' ';
|
||||
} else {
|
||||
$micro_logo = '';
|
||||
}
|
||||
@ -187,11 +187,13 @@ class WindowsBuilder extends BuilderBase
|
||||
SourcePatcher::patchMicro(['phar']);
|
||||
}
|
||||
|
||||
try {
|
||||
cmd()->cd(SOURCE_PATH . '\php-src')->exec("{$this->sdk_prefix} nmake_micro_wrapper.bat --task-args micro");
|
||||
|
||||
} finally {
|
||||
if ($this->phar_patched) {
|
||||
SourcePatcher::patchMicro(['phar'], true);
|
||||
}
|
||||
}
|
||||
|
||||
$this->deployBinary(BUILD_TARGET_MICRO);
|
||||
}
|
||||
|
||||
@ -12,29 +12,13 @@ class curl extends WindowsLibraryBase
|
||||
|
||||
protected function build(): void
|
||||
{
|
||||
// reset cmake
|
||||
FileSystem::resetDir($this->source_dir . '\build');
|
||||
|
||||
// start build
|
||||
cmd()->cd($this->source_dir)
|
||||
cmd()->cd($this->source_dir . '\winbuild')
|
||||
->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 ' .
|
||||
'-DBUILD_CURL_EXE=OFF ' .
|
||||
'-DUSE_ZLIB=ON ' .
|
||||
'-DCURL_USE_OPENSSL=ON ' .
|
||||
'-DCURL_USE_LIBLSSH2=ON ' .
|
||||
'-DUSE_NGHTTP2=ON ' . // php-src with curl needs nghttp2
|
||||
'-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' '
|
||||
)
|
||||
->execWithWrapper(
|
||||
$this->builder->makeSimpleWrapper('cmake'),
|
||||
"--build build --config Release --target install -j{$this->builder->concurrency}"
|
||||
$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'
|
||||
);
|
||||
FileSystem::copyDir($this->source_dir . '\include\curl', BUILD_INCLUDE_PATH . '\curl');
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,8 +23,8 @@ class nghttp2 extends WindowsLibraryBase
|
||||
'-A x64 ' .
|
||||
"-DCMAKE_TOOLCHAIN_FILE={$this->builder->cmake_toolchain_file} " .
|
||||
'-DCMAKE_BUILD_TYPE=Release ' .
|
||||
'-DBUILD_SHARED_LIBS=OFF ' .
|
||||
'-DBUILD_STATIC_LIBS=ON ' .
|
||||
'-DENABLE_SHARED_LIB=OFF ' .
|
||||
'-DENABLE_STATIC_LIB=ON ' .
|
||||
'-DENABLE_STATIC_CRT=ON ' .
|
||||
'-DENABLE_LIB_ONLY=ON ' .
|
||||
'-DCMAKE_INSTALL_PREFIX=' . BUILD_ROOT_PATH . ' '
|
||||
|
||||
@ -36,6 +36,7 @@ class DownloadCommand extends BaseCommand
|
||||
$this->addOption('custom-url', 'U', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Specify custom source download url, e.g "php-src:https://downloads.php.net/~eric/php-8.3.0beta1.tar.gz"');
|
||||
$this->addOption('from-zip', 'Z', InputOption::VALUE_REQUIRED, 'Fetch from zip archive');
|
||||
$this->addOption('for-extensions', 'e', InputOption::VALUE_REQUIRED, 'Fetch by extensions, e.g "openssl,mbstring"');
|
||||
$this->addOption('for-libs', 'l', InputOption::VALUE_REQUIRED, 'Fetch by libraries, e.g "libcares,openssl,onig"');
|
||||
$this->addOption('without-suggestions', null, null, 'Do not fetch suggested sources when using --for-extensions');
|
||||
}
|
||||
|
||||
@ -46,6 +47,7 @@ class DownloadCommand extends BaseCommand
|
||||
|| $input->getOption('clean')
|
||||
|| $input->getOption('from-zip')
|
||||
|| $input->getOption('for-extensions')
|
||||
|| $input->getOption('for-libs')
|
||||
) {
|
||||
$input->setArgument('sources', '');
|
||||
}
|
||||
@ -112,6 +114,9 @@ class DownloadCommand extends BaseCommand
|
||||
$ext = array_map('trim', array_filter(explode(',', $for_ext)));
|
||||
$sources = $this->calculateSourcesByExt($ext, !$this->getOption('without-suggestions'));
|
||||
array_unshift($sources, 'php-src', 'micro', 'pkg-config');
|
||||
} elseif ($for_lib = $this->getOption('for-libs')) {
|
||||
$lib = array_map('trim', array_filter(explode(',', $for_lib)));
|
||||
$sources = $this->calculateSourcesByLib($lib, !$this->getOption('without-suggestions'));
|
||||
} else {
|
||||
// get source list that will be downloaded
|
||||
$sources = array_map('trim', array_filter(explode(',', $this->getArgument('sources'))));
|
||||
@ -209,6 +214,7 @@ class DownloadCommand extends BaseCommand
|
||||
* Calculate the sources by extensions
|
||||
*
|
||||
* @param array $extensions extension list
|
||||
* @param bool $include_suggests include suggested libs and extensions (default: true)
|
||||
* @throws FileSystemException
|
||||
* @throws WrongUsageException
|
||||
*/
|
||||
@ -226,4 +232,22 @@ class DownloadCommand extends BaseCommand
|
||||
}
|
||||
return array_values(array_unique($sources));
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the sources by libraries
|
||||
*
|
||||
* @param array $libs library list
|
||||
* @param bool $include_suggests include suggested libs (default: true)
|
||||
* @throws FileSystemException
|
||||
* @throws WrongUsageException
|
||||
*/
|
||||
private function calculateSourcesByLib(array $libs, bool $include_suggests = true): array
|
||||
{
|
||||
$libs = DependencyUtil::getLibs($libs, $include_suggests);
|
||||
$sources = [];
|
||||
foreach ($libs as $library) {
|
||||
$sources[] = Config::getLib($library, 'source');
|
||||
}
|
||||
return array_values(array_unique($sources));
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,8 +13,8 @@ declare(strict_types=1);
|
||||
|
||||
// If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`).
|
||||
$extensions = match (PHP_OS_FAMILY) {
|
||||
'Linux', 'Darwin' => 'swoole,swoole-hook-mysql,swoole-hook-pgsql,swoole-hook-sqlite,openssl,curl,pdo_mysql',
|
||||
'Windows' => 'mbstring,pdo_sqlite,mbregex,ffi',
|
||||
'Linux', 'Darwin' => 'zlib,openssl,curl,pcntl,posix,mbstring,tokenizer,phar',
|
||||
'Windows' => 'mbstring,pdo_sqlite,mbregex,ffi,curl',
|
||||
};
|
||||
|
||||
// If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`).
|
||||
@ -27,7 +27,7 @@ $with_libs = match (PHP_OS_FAMILY) {
|
||||
// You can use `common`, `bulk`, `minimal` or `none`.
|
||||
// note: combination is only available for *nix platform. Windows must use `none` combination
|
||||
$base_combination = match (PHP_OS_FAMILY) {
|
||||
'Linux', 'Darwin' => 'minimal',
|
||||
'Linux', 'Darwin' => 'none',
|
||||
'Windows' => 'none',
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user