mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-19 13:24:51 +08:00
Add curl
This commit is contained in:
parent
103b5b3585
commit
7041e060f2
33
config/pkg/lib/curl.yml
Normal file
33
config/pkg/lib/curl.yml
Normal file
@ -0,0 +1,33 @@
|
||||
curl:
|
||||
type: library
|
||||
artifact:
|
||||
source:
|
||||
type: ghrel
|
||||
repo: curl/curl
|
||||
match: 'curl.+\.tar\.xz'
|
||||
prefer-stable: true
|
||||
metadata:
|
||||
license-files: [COPYING]
|
||||
license: curl
|
||||
static-libs@unix:
|
||||
- libcurl.a
|
||||
headers:
|
||||
- curl
|
||||
depends@unix:
|
||||
- openssl
|
||||
- zlib
|
||||
suggests@unix:
|
||||
- libssh2
|
||||
- brotli
|
||||
- nghttp2
|
||||
- nghttp3
|
||||
- ngtcp2
|
||||
- zstd
|
||||
- libcares
|
||||
- ldap
|
||||
- idn2
|
||||
- krb5
|
||||
frameworks:
|
||||
- CoreFoundation
|
||||
- CoreServices
|
||||
- SystemConfiguration
|
||||
61
src/Package/Library/curl.php
Normal file
61
src/Package/Library/curl.php
Normal file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Package\Library;
|
||||
|
||||
use StaticPHP\Attribute\Package\BuildFor;
|
||||
use StaticPHP\Attribute\Package\Library;
|
||||
use StaticPHP\Attribute\Package\PatchBeforeBuild;
|
||||
use StaticPHP\Attribute\PatchDescription;
|
||||
use StaticPHP\Package\LibraryPackage;
|
||||
use StaticPHP\Runtime\Executor\UnixCMakeExecutor;
|
||||
use StaticPHP\Runtime\SystemTarget;
|
||||
use StaticPHP\Util\FileSystem;
|
||||
|
||||
#[Library('curl')]
|
||||
class curl
|
||||
{
|
||||
#[PatchBeforeBuild]
|
||||
#[PatchDescription('Remove CMAKE_C_IMPLICIT_LINK_LIBRARIES and fix macOS framework detection')]
|
||||
public function patchBeforeBuild(LibraryPackage $lib): bool
|
||||
{
|
||||
shell()->cd($lib->getSourceDir())->exec('sed -i.save s@\${CMAKE_C_IMPLICIT_LINK_LIBRARIES}@@ ./CMakeLists.txt');
|
||||
if (SystemTarget::getTargetOS() === 'Darwin') {
|
||||
FileSystem::replaceFileRegex("{$lib->getSourceDir()}/curl/CMakeLists.txt", '/NOT COREFOUNDATION_FRAMEWORK/m', 'FALSE');
|
||||
FileSystem::replaceFileRegex("{$lib->getSourceDir()}/curl/CMakeLists.txt", '/NOT SYSTEMCONFIGURATION_FRAMEWORK/m', 'FALSE');
|
||||
FileSystem::replaceFileRegex("{$lib->getSourceDir()}/curl/CMakeLists.txt", '/NOT CORESERVICES_FRAMEWORK/m', 'FALSE');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#[BuildFor('Linux')]
|
||||
#[BuildFor('Darwin')]
|
||||
public function build(LibraryPackage $lib): void
|
||||
{
|
||||
UnixCMakeExecutor::create($lib)
|
||||
->optionalPackage('openssl', '-DCURL_USE_OPENSSL=ON -DCURL_CA_BUNDLE=OFF -DCURL_CA_PATH=OFF -DCURL_CA_FALLBACK=ON', '-DCURL_USE_OPENSSL=OFF -DCURL_ENABLE_SSL=OFF')
|
||||
->optionalPackage('brotli', ...cmake_boolean_args('CURL_BROTLI'))
|
||||
->optionalPackage('libssh2', ...cmake_boolean_args('CURL_USE_LIBSSH2'))
|
||||
->optionalPackage('nghttp2', ...cmake_boolean_args('USE_NGHTTP2'))
|
||||
->optionalPackage('nghttp3', ...cmake_boolean_args('USE_NGHTTP3'))
|
||||
->optionalPackage('ngtcp2', ...cmake_boolean_args('USE_NGTCP2'))
|
||||
->optionalPackage('ldap', ...cmake_boolean_args('CURL_DISABLE_LDAP', true))
|
||||
->optionalPackage('zstd', ...cmake_boolean_args('CURL_ZSTD'))
|
||||
->optionalPackage('idn2', ...cmake_boolean_args('USE_LIBIDN2'))
|
||||
->optionalPackage('psl', ...cmake_boolean_args('CURL_USE_LIBPSL'))
|
||||
->optionalPackage('krb5', ...cmake_boolean_args('CURL_USE_GSSAPI'))
|
||||
->optionalPackage('idn2', ...cmake_boolean_args('CURL_USE_IDN2'))
|
||||
->optionalPackage('libcares', '-DENABLE_ARES=ON')
|
||||
->addConfigureArgs(
|
||||
'-DBUILD_CURL_EXE=OFF',
|
||||
'-DBUILD_LIBCURL_DOCS=OFF',
|
||||
)
|
||||
->build();
|
||||
|
||||
// patch pkgconf
|
||||
$lib->patchPkgconfPrefix(['libcurl.pc']);
|
||||
shell()->cd("{$lib->getLibDir()}/cmake/CURL/")
|
||||
->exec("sed -ie 's|\"/lib/libcurl.a\"|\"{$lib->getLibDir()}/libcurl.a\"|g' CURLTargets-release.cmake");
|
||||
}
|
||||
}
|
||||
@ -146,7 +146,8 @@ readonly class Doctor
|
||||
foreach (DoctorLoader::getDoctorItems() as [$item, $optional]) {
|
||||
/* @var CheckItem $item */
|
||||
// optional check
|
||||
if ($optional !== null && !call_user_func($optional)) {
|
||||
/* @phpstan-ignore-next-line */
|
||||
if (is_callable($optional) && !call_user_func($optional)) {
|
||||
continue; // skip this when the optional check is false
|
||||
}
|
||||
// limit_os check
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user