Add nghttp2, nghttp3, ngtcp2

This commit is contained in:
crazywhalecc 2026-02-02 15:56:12 +08:00
parent 1586825b5b
commit 82ab14165e
No known key found for this signature in database
GPG Key ID: 1F4BDD59391F2680
6 changed files with 185 additions and 0 deletions

View 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

View 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
View 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

View 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);
}
}

View 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);
}
}

View 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");
}
}