mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-09 01:45:36 +08:00
Add nghttp2, nghttp3, ngtcp2
This commit is contained in:
24
config/pkg/lib/nghttp2.yml
Normal file
24
config/pkg/lib/nghttp2.yml
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
nghttp2:
|
||||||
|
type: library
|
||||||
|
artifact:
|
||||||
|
source:
|
||||||
|
type: ghrel
|
||||||
|
repo: nghttp2/nghttp2
|
||||||
|
match: nghttp2.+\.tar\.xz
|
||||||
|
prefer-stable: true
|
||||||
|
metadata:
|
||||||
|
license-files: [COPYING]
|
||||||
|
depends:
|
||||||
|
- zlib
|
||||||
|
- openssl
|
||||||
|
suggests:
|
||||||
|
- libxml2
|
||||||
|
- nghttp3
|
||||||
|
- ngtcp2
|
||||||
|
- brotli
|
||||||
|
headers:
|
||||||
|
- nghttp2
|
||||||
|
static-libs@unix:
|
||||||
|
- libnghttp2.a
|
||||||
|
pkg-configs:
|
||||||
|
- libnghttp2
|
||||||
19
config/pkg/lib/nghttp3.yml
Normal file
19
config/pkg/lib/nghttp3.yml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
nghttp3:
|
||||||
|
type: library
|
||||||
|
artifact:
|
||||||
|
source:
|
||||||
|
type: ghrel
|
||||||
|
repo: ngtcp2/nghttp3
|
||||||
|
match: nghttp3.+\.tar\.xz
|
||||||
|
prefer-stable: true
|
||||||
|
metadata:
|
||||||
|
license-files: [COPYING]
|
||||||
|
license: MIT
|
||||||
|
depends:
|
||||||
|
- openssl
|
||||||
|
headers:
|
||||||
|
- nghttp3
|
||||||
|
static-libs@unix:
|
||||||
|
- libnghttp3.a
|
||||||
|
pkg-configs:
|
||||||
|
- libnghttp3
|
||||||
24
config/pkg/lib/ngtcp2.yml
Normal file
24
config/pkg/lib/ngtcp2.yml
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
ngtcp2:
|
||||||
|
type: library
|
||||||
|
artifact:
|
||||||
|
source:
|
||||||
|
type: ghrel
|
||||||
|
repo: ngtcp2/ngtcp2
|
||||||
|
match: ngtcp2.+\.tar\.xz
|
||||||
|
prefer-stable: true
|
||||||
|
metadata:
|
||||||
|
license-files: [COPYING]
|
||||||
|
license: MIT
|
||||||
|
depends:
|
||||||
|
- openssl
|
||||||
|
suggests:
|
||||||
|
- nghttp3
|
||||||
|
- brotli
|
||||||
|
headers:
|
||||||
|
- ngtcp2
|
||||||
|
static-libs@unix:
|
||||||
|
- libngtcp2.a
|
||||||
|
- libngtcp2_crypto_ossl.a
|
||||||
|
pkg-configs:
|
||||||
|
- libngtcp2
|
||||||
|
- libngtcp2_crypto_ossl
|
||||||
41
src/Package/Library/nghttp2.php
Normal file
41
src/Package/Library/nghttp2.php
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Package\Library;
|
||||||
|
|
||||||
|
use StaticPHP\Attribute\Package\BuildFor;
|
||||||
|
use StaticPHP\Attribute\Package\Library;
|
||||||
|
use StaticPHP\Package\LibraryPackage;
|
||||||
|
use StaticPHP\Runtime\Executor\UnixAutoconfExecutor;
|
||||||
|
|
||||||
|
#[Library('nghttp2')]
|
||||||
|
class nghttp2
|
||||||
|
{
|
||||||
|
#[BuildFor('Linux')]
|
||||||
|
#[BuildFor('Darwin')]
|
||||||
|
public function build(LibraryPackage $lib): void
|
||||||
|
{
|
||||||
|
UnixAutoconfExecutor::create($lib)
|
||||||
|
->optionalPackage('zlib', ...ac_with_args('zlib', true))
|
||||||
|
->optionalPackage('openssl', ...ac_with_args('openssl', true))
|
||||||
|
->optionalPackage('libxml2', ...ac_with_args('libxml2', true))
|
||||||
|
->optionalPackage('ngtcp2', ...ac_with_args('libngtcp2', true))
|
||||||
|
->optionalPackage('nghttp3', ...ac_with_args('libnghttp3', true))
|
||||||
|
->optionalPackage(
|
||||||
|
'brotli',
|
||||||
|
fn (LibraryPackage $brotli) => implode(' ', [
|
||||||
|
'--with-brotlidec=yes',
|
||||||
|
"LIBBROTLIDEC_CFLAGS=\"-I{$brotli->getIncludeDir()}\"",
|
||||||
|
"LIBBROTLIDEC_LIBS=\"{$brotli->getStaticLibFiles()}\"",
|
||||||
|
'--with-libbrotlienc=yes',
|
||||||
|
"LIBBROTLIENC_CFLAGS=\"-I{$brotli->getIncludeDir()}\"",
|
||||||
|
"LIBBROTLIENC_LIBS=\"{$brotli->getStaticLibFiles()}\"",
|
||||||
|
])
|
||||||
|
)
|
||||||
|
->configure('--enable-lib-only')
|
||||||
|
->make();
|
||||||
|
|
||||||
|
$lib->patchPkgconfPrefix(['libnghttp2.pc'], PKGCONF_PATCH_PREFIX);
|
||||||
|
}
|
||||||
|
}
|
||||||
25
src/Package/Library/nghttp3.php
Normal file
25
src/Package/Library/nghttp3.php
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Package\Library;
|
||||||
|
|
||||||
|
use StaticPHP\Attribute\Package\BuildFor;
|
||||||
|
use StaticPHP\Attribute\Package\Library;
|
||||||
|
use StaticPHP\Package\LibraryPackage;
|
||||||
|
use StaticPHP\Runtime\Executor\UnixAutoconfExecutor;
|
||||||
|
|
||||||
|
#[Library('nghttp3')]
|
||||||
|
class nghttp3
|
||||||
|
{
|
||||||
|
#[BuildFor('Linux')]
|
||||||
|
#[BuildFor('Darwin')]
|
||||||
|
public function build(LibraryPackage $lib): void
|
||||||
|
{
|
||||||
|
UnixAutoconfExecutor::create($lib)
|
||||||
|
->configure('--enable-lib-only')
|
||||||
|
->make();
|
||||||
|
|
||||||
|
$lib->patchPkgconfPrefix(['libnghttp3.pc'], PKGCONF_PATCH_PREFIX);
|
||||||
|
}
|
||||||
|
}
|
||||||
52
src/Package/Library/ngtcp2.php
Normal file
52
src/Package/Library/ngtcp2.php
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Package\Library;
|
||||||
|
|
||||||
|
use StaticPHP\Attribute\Package\BuildFor;
|
||||||
|
use StaticPHP\Attribute\Package\Library;
|
||||||
|
use StaticPHP\Package\LibraryPackage;
|
||||||
|
use StaticPHP\Runtime\Executor\UnixAutoconfExecutor;
|
||||||
|
|
||||||
|
#[Library('ngtcp2')]
|
||||||
|
class ngtcp2
|
||||||
|
{
|
||||||
|
#[BuildFor('Linux')]
|
||||||
|
#[BuildFor('Darwin')]
|
||||||
|
public function build(LibraryPackage $lib): void
|
||||||
|
{
|
||||||
|
UnixAutoconfExecutor::create($lib)
|
||||||
|
->optionalPackage(
|
||||||
|
'openssl',
|
||||||
|
fn (LibraryPackage $openssl) => implode(' ', [
|
||||||
|
'--with-openssl=yes',
|
||||||
|
"OPENSSL_LIBS=\"{$openssl->getStaticLibFiles()}\"",
|
||||||
|
"OPENSSL_CFLAGS=\"-I{$openssl->getIncludeDir()}\"",
|
||||||
|
]),
|
||||||
|
'--with-openssl=no'
|
||||||
|
)
|
||||||
|
->optionalPackage('nghttp3', ...ac_with_args('libnghttp3', true))
|
||||||
|
->optionalPackage(
|
||||||
|
'brotli',
|
||||||
|
fn (LibraryPackage $brotli) => implode(' ', [
|
||||||
|
'--with-brotlidec=yes',
|
||||||
|
"LIBBROTLIDEC_CFLAGS=\"-I{$brotli->getIncludeDir()}\"",
|
||||||
|
"LIBBROTLIDEC_LIBS=\"{$brotli->getStaticLibFiles()}\"",
|
||||||
|
'--with-libbrotlienc=yes',
|
||||||
|
"LIBBROTLIENC_CFLAGS=\"-I{$brotli->getIncludeDir()}\"",
|
||||||
|
"LIBBROTLIENC_LIBS=\"{$brotli->getStaticLibFiles()}\"",
|
||||||
|
])
|
||||||
|
)
|
||||||
|
->appendEnv(['PKG_CONFIG' => '$PKG_CONFIG --static'])
|
||||||
|
->configure('--enable-lib-only')
|
||||||
|
->make();
|
||||||
|
|
||||||
|
$lib->patchPkgconfPrefix(['libngtcp2.pc', 'libngtcp2_crypto_ossl.pc'], PKGCONF_PATCH_PREFIX);
|
||||||
|
|
||||||
|
// On macOS, the static library may contain other static libraries
|
||||||
|
// ld: archive member 'libssl.a' not a mach-o file in libngtcp2_crypto_ossl.a
|
||||||
|
$AR = getenv('AR') ?: 'ar';
|
||||||
|
shell()->cd($lib->getLibDir())->exec("{$AR} -t libngtcp2_crypto_ossl.a | grep '\\.a\$' | xargs -n1 {$AR} d libngtcp2_crypto_ossl.a");
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user