Skip to content

Commit 4bbbe75

Browse files
mcollinaaduh95
authored andcommitted
quic: move quic behind compile time flag
Move node:quic behind a compile-time flag, disabled by default. Use --experimental-quic at configure time to enable. - Add --experimental-quic flag to configure.py - Add node_use_quic variable and HAVE_QUIC define - Make QUIC sources conditional in node.gyp - Move ngtcp2/nghttp3 deps under QUIC condition in node.gypi - Update C++ guards to check HAVE_QUIC - Update process.features.quic to check node_use_quic PR-URL: #61444 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Aviv Keller <me@aviv.sh> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent 7c2242b commit 4bbbe75

24 files changed

+103
-61
lines changed

configure.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -948,6 +948,12 @@
948948
default=None,
949949
help='build without SQLite (disables SQLite and Web Storage API)')
950950

951+
parser.add_argument('--experimental-quic',
952+
action='store_true',
953+
dest='experimental_quic',
954+
default=None,
955+
help='build with experimental QUIC support')
956+
951957
parser.add_argument('--ninja',
952958
action='store_true',
953959
dest='use_ninja',
@@ -2007,6 +2013,10 @@ def without_sqlite_error(option):
20072013

20082014
configure_library('sqlite', o, pkgname='sqlite3')
20092015

2016+
def configure_quic(o):
2017+
o['variables']['node_use_quic'] = b(options.experimental_quic and
2018+
not options.without_ssl)
2019+
20102020
def configure_static(o):
20112021
if options.fully_static or options.partly_static:
20122022
if flavor == 'mac':
@@ -2458,6 +2468,7 @@ def make_bin_override():
24582468
configure_library('zstd', output, pkgname='libzstd')
24592469
configure_v8(output, configurations)
24602470
configure_openssl(output)
2471+
configure_quic(output)
24612472
configure_intl(output)
24622473
configure_static(output)
24632474
configure_inspector(output)

lib/internal/bootstrap/node.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,8 @@ const features = {
288288
get quic() {
289289
// TODO(@jasnell): When the implementation is updated to support Boring,
290290
// then this should be refactored to depend not only on the OpenSSL version.
291-
return !openSSLIsBoringSSL &&
291+
return process.config.variables.node_use_quic &&
292+
!openSSLIsBoringSSL &&
292293
getOptionValue('--experimental-quic') &&
293294
process.config.variables.openssl_version >= 810549279; // >= 3.5.1
294295
},

node.gyp

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
'node_use_bundled_v8%': 'true',
3232
'node_use_node_snapshot%': 'false',
3333
'node_use_openssl%': 'true',
34+
'node_use_quic%': 'false',
3435
'node_use_sqlite%': 'true',
3536
'node_use_v8_platform%': 'true',
3637
'node_v8_options%': '',
@@ -189,22 +190,6 @@
189190
'src/udp_wrap.cc',
190191
'src/util.cc',
191192
'src/uv.cc',
192-
'src/quic/bindingdata.cc',
193-
'src/quic/cid.cc',
194-
'src/quic/data.cc',
195-
'src/quic/logstream.cc',
196-
'src/quic/packet.cc',
197-
'src/quic/preferredaddress.cc',
198-
'src/quic/sessionticket.cc',
199-
'src/quic/tokens.cc',
200-
'src/quic/application.cc',
201-
'src/quic/endpoint.cc',
202-
'src/quic/http3.cc',
203-
'src/quic/session.cc',
204-
'src/quic/streams.cc',
205-
'src/quic/tlscontext.cc',
206-
'src/quic/transportparams.cc',
207-
'src/quic/quic.cc',
208193
# headers to make for a more pleasant IDE experience
209194
'src/aliased_buffer.h',
210195
'src/aliased_buffer-inl.h',
@@ -342,6 +327,24 @@
342327
'src/udp_wrap.h',
343328
'src/util.h',
344329
'src/util-inl.h',
330+
],
331+
'node_quic_sources': [
332+
'src/quic/bindingdata.cc',
333+
'src/quic/cid.cc',
334+
'src/quic/data.cc',
335+
'src/quic/logstream.cc',
336+
'src/quic/packet.cc',
337+
'src/quic/preferredaddress.cc',
338+
'src/quic/sessionticket.cc',
339+
'src/quic/tokens.cc',
340+
'src/quic/application.cc',
341+
'src/quic/endpoint.cc',
342+
'src/quic/http3.cc',
343+
'src/quic/session.cc',
344+
'src/quic/streams.cc',
345+
'src/quic/tlscontext.cc',
346+
'src/quic/transportparams.cc',
347+
'src/quic/quic.cc',
345348
'src/quic/bindingdata.h',
346349
'src/quic/cid.h',
347350
'src/quic/data.h',
@@ -424,6 +427,8 @@
424427
'test/cctest/test_crypto_clienthello.cc',
425428
'test/cctest/test_node_crypto.cc',
426429
'test/cctest/test_node_crypto_env.cc',
430+
],
431+
'node_cctest_quic_sources': [
427432
'test/cctest/test_quic_cid.cc',
428433
'test/cctest/test_quic_error.cc',
429434
'test/cctest/test_quic_preferredaddress.cc',
@@ -993,6 +998,11 @@
993998
'<@(node_sqlite_sources)',
994999
],
9951000
}],
1001+
[ 'node_use_quic=="true"', {
1002+
'sources': [
1003+
'<@(node_quic_sources)',
1004+
],
1005+
}],
9961006
[ 'OS in "linux freebsd mac solaris openharmony" and '
9971007
'target_arch=="x64" and '
9981008
'node_target_type=="executable"', {
@@ -1279,6 +1289,13 @@
12791289
}, {
12801290
'sources!': [ '<@(node_cctest_openssl_sources)' ],
12811291
}],
1292+
[ 'node_use_quic=="true"', {
1293+
'defines': [
1294+
'HAVE_QUIC=1',
1295+
],
1296+
}, {
1297+
'sources!': [ '<@(node_cctest_quic_sources)' ],
1298+
}],
12821299
['v8_enable_inspector==1', {
12831300
'defines': [
12841301
'HAVE_INSPECTOR=1',

node.gypi

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -385,13 +385,9 @@
385385
'defines': [ 'OPENSSL_API_COMPAT=0x10100000L', ],
386386
'dependencies': [
387387
'./deps/openssl/openssl.gyp:openssl',
388-
'./deps/ngtcp2/ngtcp2.gyp:ngtcp2',
389-
'./deps/ngtcp2/ngtcp2.gyp:nghttp3',
390388

391389
# For tests
392390
'./deps/openssl/openssl.gyp:openssl-cli',
393-
'./deps/ngtcp2/ngtcp2.gyp:ngtcp2_test_server',
394-
'./deps/ngtcp2/ngtcp2.gyp:ngtcp2_test_client',
395391
],
396392
'conditions': [
397393
# -force_load or --whole-archive are not applicable for
@@ -443,5 +439,22 @@
443439
}, {
444440
'defines': [ 'HAVE_SQLITE=0' ]
445441
}],
442+
[ 'node_use_quic=="true"', {
443+
'defines': [ 'HAVE_QUIC=1' ],
444+
'conditions': [
445+
[ 'node_shared_openssl=="false"', {
446+
'dependencies': [
447+
'./deps/ngtcp2/ngtcp2.gyp:ngtcp2',
448+
'./deps/ngtcp2/ngtcp2.gyp:nghttp3',
449+
450+
# For tests
451+
'./deps/ngtcp2/ngtcp2.gyp:ngtcp2_test_server',
452+
'./deps/ngtcp2/ngtcp2.gyp:ngtcp2_test_client',
453+
],
454+
}],
455+
],
456+
}, {
457+
'defines': [ 'HAVE_QUIC=0' ]
458+
}],
446459
],
447460
}

src/quic/application.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if HAVE_OPENSSL
1+
#if HAVE_OPENSSL && HAVE_QUIC
22
#include "guard.h"
33
#ifndef OPENSSL_NO_QUIC
44
#include "application.h"
@@ -639,4 +639,4 @@ std::unique_ptr<Session::Application> Session::SelectApplication(
639639
} // namespace node
640640

641641
#endif // OPENSSL_NO_QUIC
642-
#endif // HAVE_OPENSSL
642+
#endif // HAVE_OPENSSL && HAVE_QUIC

src/quic/bindingdata.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if HAVE_OPENSSL
1+
#if HAVE_OPENSSL && HAVE_QUIC
22
#include "guard.h"
33
#ifndef OPENSSL_NO_QUIC
44
#include "bindingdata.h"
@@ -224,4 +224,4 @@ JS_METHOD_IMPL(IllegalConstructor) {
224224
} // namespace node
225225

226226
#endif // OPENSSL_NO_QUIC
227-
#endif // HAVE_OPENSSL
227+
#endif // HAVE_OPENSSL && HAVE_QUIC

src/quic/cid.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if HAVE_OPENSSL
1+
#if HAVE_OPENSSL && HAVE_QUIC
22
#include "guard.h"
33
#ifndef OPENSSL_NO_QUIC
44
#include <crypto/crypto_util.h>
@@ -151,4 +151,4 @@ const CID::Factory& CID::Factory::random() {
151151

152152
} // namespace node::quic
153153
#endif // OPENSSL_NO_QUIC
154-
#endif // HAVE_OPENSS
154+
#endif // HAVE_OPENSSL && HAVE_QUIC

src/quic/data.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if HAVE_OPENSSL
1+
#if HAVE_OPENSSL && HAVE_QUIC
22
#include "guard.h"
33
#ifndef OPENSSL_NO_QUIC
44
#include "data.h"
@@ -394,4 +394,4 @@ const QuicError QuicError::INTERNAL_ERROR = ForNgtcp2Error(NGTCP2_ERR_INTERNAL);
394394
} // namespace node
395395

396396
#endif // OPENSSL_NO_QUIC
397-
#endif // HAVE_OPENSSL
397+
#endif // HAVE_OPENSSL && HAVE_QUIC

src/quic/endpoint.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if HAVE_OPENSSL
1+
#if HAVE_OPENSSL && HAVE_QUIC
22
#include "guard.h"
33
#ifndef OPENSSL_NO_QUIC
44
#include "endpoint.h"
@@ -1740,4 +1740,4 @@ JS_METHOD_IMPL(Endpoint::Ref) {
17401740
} // namespace quic
17411741
} // namespace node
17421742
#endif // OPENSSL_NO_QUIC
1743-
#endif // HAVE_OPENSSL
1743+
#endif // HAVE_OPENSSL && HAVE_QUIC

src/quic/http3.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if HAVE_OPENSSL
1+
#if HAVE_OPENSSL && HAVE_QUIC
22
#include "guard.h"
33
#ifndef OPENSSL_NO_QUIC
44
#include "http3.h"
@@ -996,4 +996,4 @@ std::unique_ptr<Session::Application> Http3Application::Create(
996996
} // namespace quic
997997
} // namespace node
998998
#endif // OPENSSL_NO_QUIC
999-
#endif // HAVE_OPENSSL
999+
#endif // HAVE_OPENSSL && HAVE_QUIC

0 commit comments

Comments
 (0)