Skip to content

Commit bb7e0f6

Browse files
committed
add nghttp3 and ngtcp2
1 parent 8919a2f commit bb7e0f6

File tree

11 files changed

+172
-16
lines changed

11 files changed

+172
-16
lines changed

config/lib.json

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@
8686
"libssh2",
8787
"brotli",
8888
"nghttp2",
89+
"nghttp3",
90+
"ngtcp2",
8991
"zstd",
9092
"libcares"
9193
],
@@ -615,7 +617,9 @@
615617
"openssl"
616618
],
617619
"lib-suggests": [
618-
"libxml2"
620+
"libxml2",
621+
"nghttp3",
622+
"ngtcp2"
619623
]
620624
},
621625
"nghttp3": {
@@ -630,11 +634,27 @@
630634
"nghttp3"
631635
],
632636
"lib-depends": [
633-
"zlib",
634637
"openssl"
635638
],
636639
"lib-suggests": [
637-
"libxml2"
640+
"ngtcp2"
641+
]
642+
},
643+
"ngtcp2": {
644+
"source": "ngtcp2",
645+
"static-libs-unix": [
646+
"libngtcp2.a",
647+
"libngtcp2_crypto_ossl.a"
648+
],
649+
"static-libs-windows": [
650+
"ngtcp2.lib",
651+
"ngtcp2_crypto_ossl.lib"
652+
],
653+
"headers": [
654+
"ngtcp2"
655+
],
656+
"lib-depends": [
657+
"openssl"
638658
]
639659
},
640660
"onig": {

config/source.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,16 @@
713713
"path": "COPYING"
714714
}
715715
},
716+
"ngtcp2": {
717+
"type": "ghrel",
718+
"repo": "ngtcp2/ngtcp2",
719+
"match": "ngtcp2.+\\.tar\\.xz",
720+
"prefer-stable": true,
721+
"license": {
722+
"type": "file",
723+
"path": "COPYING"
724+
}
725+
},
716726
"onig": {
717727
"type": "ghrel",
718728
"repo": "kkos/oniguruma",

src/SPC/builder/linux/LinuxBuilder.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ public function makeAutoconfArgs(string $name, array $libSpecs): string
8080
$ret = '';
8181
foreach ($libSpecs as $libName => $arr) {
8282
$lib = $this->getLib($libName);
83+
if ($lib === null && str_starts_with($libName, 'lib')) {
84+
$lib = $this->getExt(substr($libName, 3));
85+
}
8386

8487
$arr = $arr ?? [];
8588

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SPC\builder\linux\library;
6+
7+
class ngtcp2 extends LinuxLibraryBase
8+
{
9+
use \SPC\builder\unix\library\ngtcp2;
10+
11+
public const NAME = 'ngtcp2';
12+
}

src/SPC/builder/macos/MacOSBuilder.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ public function makeAutoconfArgs(string $name, array $lib_specs): string
5555
$ret = '';
5656
foreach ($lib_specs as $libName => $arr) {
5757
$lib = $this->getLib($libName);
58+
if ($lib === null && str_starts_with($libName, 'lib')) {
59+
$lib = $this->getExt(substr($libName, 3));
60+
}
5861

5962
$arr = $arr ?? [];
6063

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SPC\builder\macos\library;
6+
7+
class ngtcp2 extends MacOSLibraryBase
8+
{
9+
use \SPC\builder\unix\library\ngtcp2;
10+
11+
public const NAME = 'ngtcp2';
12+
}

src/SPC/builder/unix/library/curl.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,24 @@ protected function build(): void
4747
} else {
4848
$extra .= '-DUSE_NGHTTP2=OFF ';
4949
}
50+
// lib:nghttp3
51+
if ($nghttp3 = $this->builder->getLib('nghttp3')) {
52+
$extra .= '-DUSE_NGHTTP3=ON ' .
53+
/* @phpstan-ignore-next-line */
54+
'-DNGHTTP3_LIBRARY="' . $nghttp3->getStaticLibFiles(style: 'cmake') . '" ' .
55+
'-DNGHTTP3_INCLUDE_DIR="' . BUILD_INCLUDE_PATH . '" ';
56+
} else {
57+
$extra .= '-DUSE_NGHTTP3=OFF ';
58+
}
59+
// lib:ngtcp2
60+
if ($ngtcp2 = $this->builder->getLib('ngtcp2')) {
61+
$extra .= '-DUSE_NGTCP2=ON '
62+
/* @phpstan-ignore-next-line */.
63+
'-DNGTCP2_LIBRARY="' . $ngtcp2->getStaticLibFiles(style: 'cmake') . '" ' .
64+
'-DNGTCP2_INCLUDE_DIR="' . BUILD_INCLUDE_PATH . '" ';
65+
} else {
66+
$extra .= '-DUSE_NGTCP2=OFF ';
67+
}
5068
// lib:ldap
5169
$extra .= $this->builder->getLib('ldap') ? '-DCURL_DISABLE_LDAP=OFF ' : '-DCURL_DISABLE_LDAP=ON ';
5270
// lib:zstd

src/SPC/builder/unix/library/nghttp2.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ protected function build(): void
3030
'jansson' => null,
3131
'jemalloc' => null,
3232
'systemd' => null,
33-
'cunit' => null,
3433
]);
3534

3635
[,,$destdir] = SEPARATED_PATH;
@@ -41,8 +40,8 @@ protected function build(): void
4140
'./configure ' .
4241
'--enable-static ' .
4342
'--disable-shared ' .
43+
'--with-pic ' .
4444
'--enable-lib-only ' .
45-
'--with-boost=no ' .
4645
$args . ' ' .
4746
'--prefix='
4847
)

src/SPC/builder/unix/library/nghttp3.php

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,6 @@ protected function build(): void
2020
$args = $this->builder->makeAutoconfArgs(static::NAME, [
2121
'zlib' => null,
2222
'openssl' => null,
23-
'libxml2' => null,
24-
'libev' => null,
25-
'libcares' => null,
26-
'libngtcp2' => null,
27-
'libbpf' => null,
28-
'libevent-openssl' => null,
29-
'jansson' => null,
30-
'jemalloc' => null,
31-
'systemd' => null,
32-
'cunit' => null,
3323
]);
3424

3525
shell()->cd($this->source_dir)
@@ -42,8 +32,8 @@ protected function build(): void
4232
'./configure ' .
4333
'--enable-static ' .
4434
'--disable-shared ' .
35+
'--with-pic ' .
4536
'--enable-lib-only ' .
46-
'--with-boost=no ' .
4737
$args . ' ' .
4838
'--prefix='
4939
)
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SPC\builder\unix\library;
6+
7+
use SPC\builder\LibraryBase;
8+
use SPC\exception\FileSystemException;
9+
use SPC\exception\RuntimeException;
10+
use SPC\exception\WrongUsageException;
11+
use SPC\store\FileSystem;
12+
13+
trait ngtcp2
14+
{
15+
/**
16+
* @throws FileSystemException
17+
* @throws RuntimeException
18+
* @throws WrongUsageException
19+
*/
20+
protected function build(): void
21+
{
22+
$args = $this->builder->makeAutoconfArgs(static::NAME, [
23+
'zlib' => null,
24+
'openssl' => null,
25+
'libxml2' => null,
26+
'libev' => null,
27+
'jemalloc' => null,
28+
]);
29+
30+
shell()->cd($this->source_dir)
31+
->setEnv([
32+
'CFLAGS' => $this->getLibExtraCFlags(),
33+
'LDFLAGS' => $this->getLibExtraLdFlags(),
34+
'LIBS' => $this->getLibExtraLibs()
35+
])
36+
->execWithEnv(
37+
'./configure ' .
38+
'--enable-static ' .
39+
'--disable-shared ' .
40+
'--with-pic ' .
41+
'--enable-lib-only ' .
42+
$args . ' ' .
43+
'--prefix='
44+
)
45+
->execWithEnv('make clean')
46+
->execWithEnv("make -j{$this->builder->concurrency}")
47+
->execWithEnv('make install DESTDIR=' . BUILD_ROOT_PATH);
48+
$this->patchPkgconfPrefix(['libngtcp2.pc']);
49+
}
50+
}

0 commit comments

Comments
 (0)