rwebtransport 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cargo.lock +666 -666
- package/Cargo.toml +31 -31
- package/LICENSE +202 -202
- package/NOTICE +41 -41
- package/README.md +550 -550
- package/crates/echo-server/Cargo.toml +20 -20
- package/crates/echo-server/src/main.rs +666 -666
- package/crates/native/Cargo.toml +23 -23
- package/crates/native/src/config.rs +129 -129
- package/crates/native/src/driver.rs +463 -463
- package/crates/native/src/lib.rs +821 -821
- package/crates/native/src/server.rs +718 -718
- package/crates/native/src/session.rs +1191 -1191
- package/crates/native/src/tls.rs +96 -96
- package/crates/wtcore/Cargo.toml +15 -15
- package/crates/wtcore/src/h3.rs +226 -226
- package/crates/wtcore/src/lib.rs +9 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +80 -79
- package/prebuilds/darwin-arm64/rwebtransport.node +0 -0
- package/prebuilds/linux-arm64/rwebtransport.node +0 -0
- package/prebuilds/linux-x64/rwebtransport.node +0 -0
- package/prebuilds/win32-x64/rwebtransport.node +0 -0
- package/scripts/bench.mjs +180 -180
- package/scripts/build.js +67 -67
- package/scripts/postinstall.js +67 -67
- package/scripts/setup-unix.sh +129 -129
- package/scripts/setup-windows.ps1 +229 -229
- package/vendor/quiche/AGENTS.md +75 -75
- package/vendor/quiche/COPYING +23 -23
- package/vendor/quiche/Cargo.lock +1212 -1212
- package/vendor/quiche/Cargo.toml +215 -215
- package/vendor/quiche/README.md +466 -466
- package/vendor/quiche/examples/Makefile +46 -46
- package/vendor/quiche/examples/README.md +20 -20
- package/vendor/quiche/examples/cert-big.crt +90 -90
- package/vendor/quiche/examples/cert.crt +18 -18
- package/vendor/quiche/examples/cert.key +28 -28
- package/vendor/quiche/examples/client.c +343 -343
- package/vendor/quiche/examples/client.rs +281 -281
- package/vendor/quiche/examples/gen-certs.sh +15 -15
- package/vendor/quiche/examples/http3-client.c +473 -473
- package/vendor/quiche/examples/http3-client.rs +349 -349
- package/vendor/quiche/examples/http3-server.c +614 -614
- package/vendor/quiche/examples/http3-server.rs +680 -680
- package/vendor/quiche/examples/qpack-decode.rs +87 -87
- package/vendor/quiche/examples/qpack-encode.rs +88 -88
- package/vendor/quiche/examples/rootca.crt +21 -21
- package/vendor/quiche/examples/server.c +529 -529
- package/vendor/quiche/examples/server.rs +529 -529
- package/vendor/quiche/include/quiche.h +1282 -1282
- package/vendor/quiche/src/buffers.rs +105 -105
- package/vendor/quiche/src/build.rs +66 -66
- package/vendor/quiche/src/cid.rs +1079 -1079
- package/vendor/quiche/src/crypto/boringssl.rs +373 -373
- package/vendor/quiche/src/crypto/mod.rs +671 -671
- package/vendor/quiche/src/dgram.rs +118 -118
- package/vendor/quiche/src/error.rs +263 -263
- package/vendor/quiche/src/ffi.rs +2290 -2290
- package/vendor/quiche/src/flowcontrol.rs +246 -246
- package/vendor/quiche/src/frame.rs +2172 -2172
- package/vendor/quiche/src/h3/AGENTS.md +54 -54
- package/vendor/quiche/src/h3/ffi.rs +442 -442
- package/vendor/quiche/src/h3/frame.rs +1404 -1404
- package/vendor/quiche/src/h3/mod.rs +8223 -8223
- package/vendor/quiche/src/h3/qpack/decoder.rs +288 -288
- package/vendor/quiche/src/h3/qpack/encoder.rs +235 -235
- package/vendor/quiche/src/h3/qpack/mod.rs +202 -202
- package/vendor/quiche/src/h3/qpack/static_table.rs +323 -323
- package/vendor/quiche/src/h3/stream.rs +1595 -1595
- package/vendor/quiche/src/lib.rs +9556 -9556
- package/vendor/quiche/src/minmax.rs +446 -446
- package/vendor/quiche/src/packet.rs +2334 -2334
- package/vendor/quiche/src/path.rs +1374 -1374
- package/vendor/quiche/src/pmtud.rs +652 -652
- package/vendor/quiche/src/rand.rs +64 -64
- package/vendor/quiche/src/range_buf.rs +186 -186
- package/vendor/quiche/src/ranges.rs +755 -755
- package/vendor/quiche/src/recovery/AGENTS.md +80 -80
- package/vendor/quiche/src/recovery/bandwidth.rs +565 -565
- package/vendor/quiche/src/recovery/bytes_in_flight.rs +179 -179
- package/vendor/quiche/src/recovery/congestion/cubic.rs +1038 -1038
- package/vendor/quiche/src/recovery/congestion/delivery_rate.rs +514 -514
- package/vendor/quiche/src/recovery/congestion/hystart.rs +241 -241
- package/vendor/quiche/src/recovery/congestion/mod.rs +361 -361
- package/vendor/quiche/src/recovery/congestion/prr.rs +238 -238
- package/vendor/quiche/src/recovery/congestion/recovery.rs +1170 -1170
- package/vendor/quiche/src/recovery/congestion/reno.rs +291 -291
- package/vendor/quiche/src/recovery/congestion/test_sender.rs +201 -201
- package/vendor/quiche/src/recovery/gcongestion/bbr/bandwidth_sampler.rs +1947 -1947
- package/vendor/quiche/src/recovery/gcongestion/bbr/windowed_filter.rs +158 -158
- package/vendor/quiche/src/recovery/gcongestion/bbr.rs +37 -37
- package/vendor/quiche/src/recovery/gcongestion/bbr2/drain.rs +120 -120
- package/vendor/quiche/src/recovery/gcongestion/bbr2/mode.rs +318 -318
- package/vendor/quiche/src/recovery/gcongestion/bbr2/network_model.rs +784 -784
- package/vendor/quiche/src/recovery/gcongestion/bbr2/probe_bw.rs +729 -729
- package/vendor/quiche/src/recovery/gcongestion/bbr2/probe_rtt.rs +175 -175
- package/vendor/quiche/src/recovery/gcongestion/bbr2/startup.rs +190 -190
- package/vendor/quiche/src/recovery/gcongestion/bbr2.rs +855 -855
- package/vendor/quiche/src/recovery/gcongestion/mod.rs +275 -275
- package/vendor/quiche/src/recovery/gcongestion/pacer.rs +294 -294
- package/vendor/quiche/src/recovery/gcongestion/recovery.rs +1384 -1384
- package/vendor/quiche/src/recovery/mod.rs +3086 -3086
- package/vendor/quiche/src/recovery/rtt.rs +152 -152
- package/vendor/quiche/src/stream/mod.rs +2210 -2210
- package/vendor/quiche/src/stream/recv_buf.rs +1236 -1236
- package/vendor/quiche/src/stream/send_buf.rs +849 -849
- package/vendor/quiche/src/test_utils.rs +681 -681
- package/vendor/quiche/src/tests.rs +12922 -12922
- package/vendor/quiche/src/tls/boringssl.rs +375 -375
- package/vendor/quiche/src/tls/mod.rs +1245 -1245
- package/vendor/quiche/src/transport_params.rs +628 -628
package/scripts/build.js
CHANGED
|
@@ -1,67 +1,67 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
// Builds the rwebtransport native addon with cargo and copies the resulting
|
|
6
|
-
// cdylib into prebuilds/<platform>-<arch>/rwebtransport.node so the loader can
|
|
7
|
-
// find it. Used both for local development and as the compile step in CI and in
|
|
8
|
-
// the install-time fallback.
|
|
9
|
-
|
|
10
|
-
const { execFileSync } = require('node:child_process');
|
|
11
|
-
const fs = require('node:fs');
|
|
12
|
-
const path = require('node:path');
|
|
13
|
-
|
|
14
|
-
const root = path.resolve(__dirname, '..');
|
|
15
|
-
const debug = process.argv.includes('--debug');
|
|
16
|
-
const profile = debug ? 'debug' : 'release';
|
|
17
|
-
|
|
18
|
-
const CRATE = 'rwebtransport-native';
|
|
19
|
-
const LIB_BASENAME = 'rwebtransport_native';
|
|
20
|
-
|
|
21
|
-
function cdylibName() {
|
|
22
|
-
switch (process.platform) {
|
|
23
|
-
case 'win32':
|
|
24
|
-
return `${LIB_BASENAME}.dll`;
|
|
25
|
-
case 'darwin':
|
|
26
|
-
return `lib${LIB_BASENAME}.dylib`;
|
|
27
|
-
default:
|
|
28
|
-
return `lib${LIB_BASENAME}.so`;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function run(cmd, args) {
|
|
33
|
-
console.error(`> ${cmd} ${args.join(' ')}`);
|
|
34
|
-
execFileSync(cmd, args, { cwd: root, stdio: 'inherit' });
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function main() {
|
|
38
|
-
const cargoArgs = ['build', '-p', CRATE];
|
|
39
|
-
if (!debug) cargoArgs.push('--release');
|
|
40
|
-
// Allow an explicit target (used by cross-compiling CI jobs).
|
|
41
|
-
const target = process.env.CARGO_BUILD_TARGET;
|
|
42
|
-
if (target) cargoArgs.push('--target', target);
|
|
43
|
-
|
|
44
|
-
run('cargo', cargoArgs);
|
|
45
|
-
|
|
46
|
-
const targetDir = process.env.CARGO_TARGET_DIR
|
|
47
|
-
? path.resolve(process.env.CARGO_TARGET_DIR)
|
|
48
|
-
: path.join(root, 'target');
|
|
49
|
-
const artifactDir = target
|
|
50
|
-
? path.join(targetDir, target, profile)
|
|
51
|
-
: path.join(targetDir, profile);
|
|
52
|
-
const artifact = path.join(artifactDir, cdylibName());
|
|
53
|
-
|
|
54
|
-
if (!fs.existsSync(artifact)) {
|
|
55
|
-
throw new Error(`built artifact not found: ${artifact}`);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const arch = process.env.PREBUILD_ARCH || process.arch;
|
|
59
|
-
const plat = process.env.PREBUILD_PLATFORM || process.platform;
|
|
60
|
-
const outDir = path.join(root, 'prebuilds', `${plat}-${arch}`);
|
|
61
|
-
fs.mkdirSync(outDir, { recursive: true });
|
|
62
|
-
const out = path.join(outDir, 'rwebtransport.node');
|
|
63
|
-
fs.copyFileSync(artifact, out);
|
|
64
|
-
console.error(`copied ${artifact} -> ${out}`);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
main();
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
// Builds the rwebtransport native addon with cargo and copies the resulting
|
|
6
|
+
// cdylib into prebuilds/<platform>-<arch>/rwebtransport.node so the loader can
|
|
7
|
+
// find it. Used both for local development and as the compile step in CI and in
|
|
8
|
+
// the install-time fallback.
|
|
9
|
+
|
|
10
|
+
const { execFileSync } = require('node:child_process');
|
|
11
|
+
const fs = require('node:fs');
|
|
12
|
+
const path = require('node:path');
|
|
13
|
+
|
|
14
|
+
const root = path.resolve(__dirname, '..');
|
|
15
|
+
const debug = process.argv.includes('--debug');
|
|
16
|
+
const profile = debug ? 'debug' : 'release';
|
|
17
|
+
|
|
18
|
+
const CRATE = 'rwebtransport-native';
|
|
19
|
+
const LIB_BASENAME = 'rwebtransport_native';
|
|
20
|
+
|
|
21
|
+
function cdylibName() {
|
|
22
|
+
switch (process.platform) {
|
|
23
|
+
case 'win32':
|
|
24
|
+
return `${LIB_BASENAME}.dll`;
|
|
25
|
+
case 'darwin':
|
|
26
|
+
return `lib${LIB_BASENAME}.dylib`;
|
|
27
|
+
default:
|
|
28
|
+
return `lib${LIB_BASENAME}.so`;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function run(cmd, args) {
|
|
33
|
+
console.error(`> ${cmd} ${args.join(' ')}`);
|
|
34
|
+
execFileSync(cmd, args, { cwd: root, stdio: 'inherit' });
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function main() {
|
|
38
|
+
const cargoArgs = ['build', '-p', CRATE];
|
|
39
|
+
if (!debug) cargoArgs.push('--release');
|
|
40
|
+
// Allow an explicit target (used by cross-compiling CI jobs).
|
|
41
|
+
const target = process.env.CARGO_BUILD_TARGET;
|
|
42
|
+
if (target) cargoArgs.push('--target', target);
|
|
43
|
+
|
|
44
|
+
run('cargo', cargoArgs);
|
|
45
|
+
|
|
46
|
+
const targetDir = process.env.CARGO_TARGET_DIR
|
|
47
|
+
? path.resolve(process.env.CARGO_TARGET_DIR)
|
|
48
|
+
: path.join(root, 'target');
|
|
49
|
+
const artifactDir = target
|
|
50
|
+
? path.join(targetDir, target, profile)
|
|
51
|
+
: path.join(targetDir, profile);
|
|
52
|
+
const artifact = path.join(artifactDir, cdylibName());
|
|
53
|
+
|
|
54
|
+
if (!fs.existsSync(artifact)) {
|
|
55
|
+
throw new Error(`built artifact not found: ${artifact}`);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const arch = process.env.PREBUILD_ARCH || process.arch;
|
|
59
|
+
const plat = process.env.PREBUILD_PLATFORM || process.platform;
|
|
60
|
+
const outDir = path.join(root, 'prebuilds', `${plat}-${arch}`);
|
|
61
|
+
fs.mkdirSync(outDir, { recursive: true });
|
|
62
|
+
const out = path.join(outDir, 'rwebtransport.node');
|
|
63
|
+
fs.copyFileSync(artifact, out);
|
|
64
|
+
console.error(`copied ${artifact} -> ${out}`);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
main();
|
package/scripts/postinstall.js
CHANGED
|
@@ -1,67 +1,67 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
// Ensures a usable native addon after install. If a prebuilt binary already
|
|
6
|
-
// exists for this platform, we do nothing. Otherwise, if a Rust toolchain is
|
|
7
|
-
// available, we compile it now. Failures here are non-fatal: the loader will
|
|
8
|
-
// retry the build lazily on first use and surface a clear error if it can't.
|
|
9
|
-
|
|
10
|
-
const { execFileSync } = require('node:child_process');
|
|
11
|
-
const fs = require('node:fs');
|
|
12
|
-
const path = require('node:path');
|
|
13
|
-
|
|
14
|
-
const root = path.resolve(__dirname, '..');
|
|
15
|
-
|
|
16
|
-
function log(msg) {
|
|
17
|
-
process.stderr.write(`rwebtransport: ${msg}\n`);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function hasPrebuilt() {
|
|
21
|
-
const p = path.join(root, 'prebuilds', `${process.platform}-${process.arch}`, 'rwebtransport.node');
|
|
22
|
-
return fs.existsSync(p);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function hasCargo() {
|
|
26
|
-
try {
|
|
27
|
-
execFileSync('cargo', ['--version'], { stdio: 'ignore' });
|
|
28
|
-
return true;
|
|
29
|
-
} catch {
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function main() {
|
|
35
|
-
// Skip during the package's own repo install / CI (source-tree development).
|
|
36
|
-
if (process.env.RWEBTRANSPORT_SKIP_POSTINSTALL === '1') return;
|
|
37
|
-
|
|
38
|
-
const major = Number(process.versions.node.split('.')[0]);
|
|
39
|
-
if (major !== 24 && major !== 26) {
|
|
40
|
-
log(`warning: Node ${process.versions.node} is unsupported (need 24 or 26).`);
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (hasPrebuilt()) return;
|
|
45
|
-
|
|
46
|
-
if (!hasCargo()) {
|
|
47
|
-
log('no prebuilt binary for this platform and no Rust toolchain found;');
|
|
48
|
-
log('install Rust (https://rustup.rs) + cmake, or use a supported prebuilt platform.');
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
log('no prebuilt binary for this platform; compiling the native addon...');
|
|
53
|
-
try {
|
|
54
|
-
execFileSync(process.execPath, [path.join(root, 'scripts', 'build.js')], {
|
|
55
|
-
cwd: root,
|
|
56
|
-
stdio: 'inherit',
|
|
57
|
-
});
|
|
58
|
-
} catch {
|
|
59
|
-
log('build failed during postinstall; will retry on first use.');
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
try {
|
|
64
|
-
main();
|
|
65
|
-
} catch (e) {
|
|
66
|
-
log(`postinstall skipped: ${e && e.message ? e.message : e}`);
|
|
67
|
-
}
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
// Ensures a usable native addon after install. If a prebuilt binary already
|
|
6
|
+
// exists for this platform, we do nothing. Otherwise, if a Rust toolchain is
|
|
7
|
+
// available, we compile it now. Failures here are non-fatal: the loader will
|
|
8
|
+
// retry the build lazily on first use and surface a clear error if it can't.
|
|
9
|
+
|
|
10
|
+
const { execFileSync } = require('node:child_process');
|
|
11
|
+
const fs = require('node:fs');
|
|
12
|
+
const path = require('node:path');
|
|
13
|
+
|
|
14
|
+
const root = path.resolve(__dirname, '..');
|
|
15
|
+
|
|
16
|
+
function log(msg) {
|
|
17
|
+
process.stderr.write(`rwebtransport: ${msg}\n`);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function hasPrebuilt() {
|
|
21
|
+
const p = path.join(root, 'prebuilds', `${process.platform}-${process.arch}`, 'rwebtransport.node');
|
|
22
|
+
return fs.existsSync(p);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function hasCargo() {
|
|
26
|
+
try {
|
|
27
|
+
execFileSync('cargo', ['--version'], { stdio: 'ignore' });
|
|
28
|
+
return true;
|
|
29
|
+
} catch {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function main() {
|
|
35
|
+
// Skip during the package's own repo install / CI (source-tree development).
|
|
36
|
+
if (process.env.RWEBTRANSPORT_SKIP_POSTINSTALL === '1') return;
|
|
37
|
+
|
|
38
|
+
const major = Number(process.versions.node.split('.')[0]);
|
|
39
|
+
if (major !== 24 && major !== 26) {
|
|
40
|
+
log(`warning: Node ${process.versions.node} is unsupported (need 24 or 26).`);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (hasPrebuilt()) return;
|
|
45
|
+
|
|
46
|
+
if (!hasCargo()) {
|
|
47
|
+
log('no prebuilt binary for this platform and no Rust toolchain found;');
|
|
48
|
+
log('install Rust (https://rustup.rs) + cmake, or use a supported prebuilt platform.');
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
log('no prebuilt binary for this platform; compiling the native addon...');
|
|
53
|
+
try {
|
|
54
|
+
execFileSync(process.execPath, [path.join(root, 'scripts', 'build.js')], {
|
|
55
|
+
cwd: root,
|
|
56
|
+
stdio: 'inherit',
|
|
57
|
+
});
|
|
58
|
+
} catch {
|
|
59
|
+
log('build failed during postinstall; will retry on first use.');
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
try {
|
|
64
|
+
main();
|
|
65
|
+
} catch (e) {
|
|
66
|
+
log(`postinstall skipped: ${e && e.message ? e.message : e}`);
|
|
67
|
+
}
|
package/scripts/setup-unix.sh
CHANGED
|
@@ -1,129 +1,129 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
#
|
|
4
|
-
# scripts/setup-unix.sh
|
|
5
|
-
#
|
|
6
|
-
# Prepares a Linux or macOS machine to build rwebtransport's native addon from
|
|
7
|
-
# source (Cloudflare quiche + BoringSSL via the boring-sys crate). BoringSSL is
|
|
8
|
-
# compiled from source, so you need:
|
|
9
|
-
#
|
|
10
|
-
# * a C/C++ compiler (clang or gcc)
|
|
11
|
-
# * CMake - configures the BoringSSL build
|
|
12
|
-
# * Ninja - the recommended CMake generator (optional; CMake can fall back)
|
|
13
|
-
# * Go - a BoringSSL build-time code generator
|
|
14
|
-
# * Rust - the toolchain that compiles the addon
|
|
15
|
-
# * Node - version 24 or 26 (the only supported lines)
|
|
16
|
-
#
|
|
17
|
-
# NASM is NOT needed off Windows; the system assembler handles BoringSSL here.
|
|
18
|
-
#
|
|
19
|
-
# Usage (from the repository root):
|
|
20
|
-
# bash scripts/setup-unix.sh # install what is missing
|
|
21
|
-
# bash scripts/setup-unix.sh --check # report only, install nothing
|
|
22
|
-
# npm run setup:unix # the same, via npm
|
|
23
|
-
#
|
|
24
|
-
# It uses the native package manager (apt, dnf, pacman, zypper, or Homebrew) and
|
|
25
|
-
# installs Rust via rustup if it is missing. When it finishes, run:
|
|
26
|
-
# npm install
|
|
27
|
-
# npm run build
|
|
28
|
-
|
|
29
|
-
set -euo pipefail
|
|
30
|
-
|
|
31
|
-
info() { printf '\033[36m==>\033[0m %s\n' "$*"; }
|
|
32
|
-
ok() { printf ' \033[32mok\033[0m %s\n' "$*"; }
|
|
33
|
-
warn() { printf ' \033[33m!!\033[0m %s\n' "$*"; }
|
|
34
|
-
|
|
35
|
-
have() { command -v "$1" >/dev/null 2>&1; }
|
|
36
|
-
|
|
37
|
-
CHECK=0
|
|
38
|
-
case "${1:-}" in
|
|
39
|
-
--check | -n) CHECK=1 ;;
|
|
40
|
-
"") ;;
|
|
41
|
-
*) warn "Ignoring unknown argument: $1" ;;
|
|
42
|
-
esac
|
|
43
|
-
|
|
44
|
-
SUDO=""
|
|
45
|
-
if [ "$(id -u)" -ne 0 ] && have sudo; then SUDO="sudo"; fi
|
|
46
|
-
|
|
47
|
-
os="$(uname -s)"
|
|
48
|
-
|
|
49
|
-
install_linux() {
|
|
50
|
-
if have apt-get; then
|
|
51
|
-
$SUDO apt-get update
|
|
52
|
-
$SUDO apt-get install -y cmake ninja-build golang-go build-essential pkg-config curl
|
|
53
|
-
elif have dnf; then
|
|
54
|
-
$SUDO dnf install -y cmake ninja-build golang gcc gcc-c++ pkgconf-pkg-config curl
|
|
55
|
-
elif have pacman; then
|
|
56
|
-
$SUDO pacman -Sy --needed --noconfirm cmake ninja go base-devel pkgconf curl
|
|
57
|
-
elif have zypper; then
|
|
58
|
-
$SUDO zypper install -y cmake ninja go gcc gcc-c++ pkg-config curl
|
|
59
|
-
else
|
|
60
|
-
warn "No supported package manager (apt, dnf, pacman, zypper) was found."
|
|
61
|
-
warn "Install these manually: a C/C++ compiler, cmake, ninja, go."
|
|
62
|
-
return 1
|
|
63
|
-
fi
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
install_mac() {
|
|
67
|
-
if ! xcode-select -p >/dev/null 2>&1 && ! have clang; then
|
|
68
|
-
info "Installing the Xcode Command Line Tools (C/C++ compiler)..."
|
|
69
|
-
xcode-select --install || true
|
|
70
|
-
warn "Finish the Command Line Tools install if a dialog appeared, then re-run."
|
|
71
|
-
fi
|
|
72
|
-
if ! have brew; then
|
|
73
|
-
warn "Homebrew was not found. Install it from https://brew.sh and re-run,"
|
|
74
|
-
warn "or install cmake, ninja, and go by hand."
|
|
75
|
-
return 1
|
|
76
|
-
fi
|
|
77
|
-
brew install cmake ninja go
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if [ "$CHECK" -eq 1 ]; then
|
|
81
|
-
info "Detected $os (check mode: nothing will be installed)"
|
|
82
|
-
else
|
|
83
|
-
info "Detected $os"
|
|
84
|
-
case "$os" in
|
|
85
|
-
Linux) install_linux || warn "Package install step did not fully complete." ;;
|
|
86
|
-
Darwin) install_mac || warn "Package install step did not fully complete." ;;
|
|
87
|
-
*) warn "Unsupported OS '$os'. This script handles Linux and macOS." ;;
|
|
88
|
-
esac
|
|
89
|
-
|
|
90
|
-
# Rust via rustup, if cargo is not already available.
|
|
91
|
-
if have cargo; then
|
|
92
|
-
ok "Rust already installed ($(command -v cargo))"
|
|
93
|
-
else
|
|
94
|
-
info "Installing Rust via rustup..."
|
|
95
|
-
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
|
96
|
-
# shellcheck source=/dev/null
|
|
97
|
-
[ -f "$HOME/.cargo/env" ] && . "$HOME/.cargo/env"
|
|
98
|
-
fi
|
|
99
|
-
fi
|
|
100
|
-
|
|
101
|
-
# Report what the build needs. A missing C compiler, cmake, or go is fatal for
|
|
102
|
-
# the build; ninja is optional (cmake falls back to another generator).
|
|
103
|
-
info "Toolchain status"
|
|
104
|
-
if have cc || have clang || have gcc; then ok "C/C++ compiler present"; else warn "C/C++ compiler MISSING (required)"; fi
|
|
105
|
-
for tool in cmake go cargo; do
|
|
106
|
-
if have "$tool"; then ok "$tool -> $(command -v "$tool")"; else warn "$tool MISSING (required)"; fi
|
|
107
|
-
done
|
|
108
|
-
if have ninja; then ok "ninja -> $(command -v ninja)"; else warn "ninja missing (optional)"; fi
|
|
109
|
-
|
|
110
|
-
info "Node.js (rwebtransport supports 24 and 26 only)"
|
|
111
|
-
if have node; then
|
|
112
|
-
major="$(node -p 'process.versions.node.split(".")[0]' 2>/dev/null || echo '?')"
|
|
113
|
-
if [ "$major" = "24" ] || [ "$major" = "26" ]; then
|
|
114
|
-
ok "Node $(node -v)"
|
|
115
|
-
else
|
|
116
|
-
warn "Node $(node -v) is not supported. Install Node 24 or 26 (nvm, or https://nodejs.org)."
|
|
117
|
-
fi
|
|
118
|
-
else
|
|
119
|
-
warn "Node.js not found. Install Node 24 or 26 (nvm, or https://nodejs.org)."
|
|
120
|
-
fi
|
|
121
|
-
|
|
122
|
-
echo ""
|
|
123
|
-
if [ "$CHECK" -eq 1 ]; then
|
|
124
|
-
info "Check complete. Re-run without --check to install what is missing."
|
|
125
|
-
else
|
|
126
|
-
info "Setup finished. If Rust was just installed, open a new shell (or run '. \"\$HOME/.cargo/env\"'), then:"
|
|
127
|
-
echo " npm install"
|
|
128
|
-
echo " npm run build"
|
|
129
|
-
fi
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
#
|
|
4
|
+
# scripts/setup-unix.sh
|
|
5
|
+
#
|
|
6
|
+
# Prepares a Linux or macOS machine to build rwebtransport's native addon from
|
|
7
|
+
# source (Cloudflare quiche + BoringSSL via the boring-sys crate). BoringSSL is
|
|
8
|
+
# compiled from source, so you need:
|
|
9
|
+
#
|
|
10
|
+
# * a C/C++ compiler (clang or gcc)
|
|
11
|
+
# * CMake - configures the BoringSSL build
|
|
12
|
+
# * Ninja - the recommended CMake generator (optional; CMake can fall back)
|
|
13
|
+
# * Go - a BoringSSL build-time code generator
|
|
14
|
+
# * Rust - the toolchain that compiles the addon
|
|
15
|
+
# * Node - version 24 or 26 (the only supported lines)
|
|
16
|
+
#
|
|
17
|
+
# NASM is NOT needed off Windows; the system assembler handles BoringSSL here.
|
|
18
|
+
#
|
|
19
|
+
# Usage (from the repository root):
|
|
20
|
+
# bash scripts/setup-unix.sh # install what is missing
|
|
21
|
+
# bash scripts/setup-unix.sh --check # report only, install nothing
|
|
22
|
+
# npm run setup:unix # the same, via npm
|
|
23
|
+
#
|
|
24
|
+
# It uses the native package manager (apt, dnf, pacman, zypper, or Homebrew) and
|
|
25
|
+
# installs Rust via rustup if it is missing. When it finishes, run:
|
|
26
|
+
# npm install
|
|
27
|
+
# npm run build
|
|
28
|
+
|
|
29
|
+
set -euo pipefail
|
|
30
|
+
|
|
31
|
+
info() { printf '\033[36m==>\033[0m %s\n' "$*"; }
|
|
32
|
+
ok() { printf ' \033[32mok\033[0m %s\n' "$*"; }
|
|
33
|
+
warn() { printf ' \033[33m!!\033[0m %s\n' "$*"; }
|
|
34
|
+
|
|
35
|
+
have() { command -v "$1" >/dev/null 2>&1; }
|
|
36
|
+
|
|
37
|
+
CHECK=0
|
|
38
|
+
case "${1:-}" in
|
|
39
|
+
--check | -n) CHECK=1 ;;
|
|
40
|
+
"") ;;
|
|
41
|
+
*) warn "Ignoring unknown argument: $1" ;;
|
|
42
|
+
esac
|
|
43
|
+
|
|
44
|
+
SUDO=""
|
|
45
|
+
if [ "$(id -u)" -ne 0 ] && have sudo; then SUDO="sudo"; fi
|
|
46
|
+
|
|
47
|
+
os="$(uname -s)"
|
|
48
|
+
|
|
49
|
+
install_linux() {
|
|
50
|
+
if have apt-get; then
|
|
51
|
+
$SUDO apt-get update
|
|
52
|
+
$SUDO apt-get install -y cmake ninja-build golang-go build-essential pkg-config curl
|
|
53
|
+
elif have dnf; then
|
|
54
|
+
$SUDO dnf install -y cmake ninja-build golang gcc gcc-c++ pkgconf-pkg-config curl
|
|
55
|
+
elif have pacman; then
|
|
56
|
+
$SUDO pacman -Sy --needed --noconfirm cmake ninja go base-devel pkgconf curl
|
|
57
|
+
elif have zypper; then
|
|
58
|
+
$SUDO zypper install -y cmake ninja go gcc gcc-c++ pkg-config curl
|
|
59
|
+
else
|
|
60
|
+
warn "No supported package manager (apt, dnf, pacman, zypper) was found."
|
|
61
|
+
warn "Install these manually: a C/C++ compiler, cmake, ninja, go."
|
|
62
|
+
return 1
|
|
63
|
+
fi
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
install_mac() {
|
|
67
|
+
if ! xcode-select -p >/dev/null 2>&1 && ! have clang; then
|
|
68
|
+
info "Installing the Xcode Command Line Tools (C/C++ compiler)..."
|
|
69
|
+
xcode-select --install || true
|
|
70
|
+
warn "Finish the Command Line Tools install if a dialog appeared, then re-run."
|
|
71
|
+
fi
|
|
72
|
+
if ! have brew; then
|
|
73
|
+
warn "Homebrew was not found. Install it from https://brew.sh and re-run,"
|
|
74
|
+
warn "or install cmake, ninja, and go by hand."
|
|
75
|
+
return 1
|
|
76
|
+
fi
|
|
77
|
+
brew install cmake ninja go
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if [ "$CHECK" -eq 1 ]; then
|
|
81
|
+
info "Detected $os (check mode: nothing will be installed)"
|
|
82
|
+
else
|
|
83
|
+
info "Detected $os"
|
|
84
|
+
case "$os" in
|
|
85
|
+
Linux) install_linux || warn "Package install step did not fully complete." ;;
|
|
86
|
+
Darwin) install_mac || warn "Package install step did not fully complete." ;;
|
|
87
|
+
*) warn "Unsupported OS '$os'. This script handles Linux and macOS." ;;
|
|
88
|
+
esac
|
|
89
|
+
|
|
90
|
+
# Rust via rustup, if cargo is not already available.
|
|
91
|
+
if have cargo; then
|
|
92
|
+
ok "Rust already installed ($(command -v cargo))"
|
|
93
|
+
else
|
|
94
|
+
info "Installing Rust via rustup..."
|
|
95
|
+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
|
96
|
+
# shellcheck source=/dev/null
|
|
97
|
+
[ -f "$HOME/.cargo/env" ] && . "$HOME/.cargo/env"
|
|
98
|
+
fi
|
|
99
|
+
fi
|
|
100
|
+
|
|
101
|
+
# Report what the build needs. A missing C compiler, cmake, or go is fatal for
|
|
102
|
+
# the build; ninja is optional (cmake falls back to another generator).
|
|
103
|
+
info "Toolchain status"
|
|
104
|
+
if have cc || have clang || have gcc; then ok "C/C++ compiler present"; else warn "C/C++ compiler MISSING (required)"; fi
|
|
105
|
+
for tool in cmake go cargo; do
|
|
106
|
+
if have "$tool"; then ok "$tool -> $(command -v "$tool")"; else warn "$tool MISSING (required)"; fi
|
|
107
|
+
done
|
|
108
|
+
if have ninja; then ok "ninja -> $(command -v ninja)"; else warn "ninja missing (optional)"; fi
|
|
109
|
+
|
|
110
|
+
info "Node.js (rwebtransport supports 24 and 26 only)"
|
|
111
|
+
if have node; then
|
|
112
|
+
major="$(node -p 'process.versions.node.split(".")[0]' 2>/dev/null || echo '?')"
|
|
113
|
+
if [ "$major" = "24" ] || [ "$major" = "26" ]; then
|
|
114
|
+
ok "Node $(node -v)"
|
|
115
|
+
else
|
|
116
|
+
warn "Node $(node -v) is not supported. Install Node 24 or 26 (nvm, or https://nodejs.org)."
|
|
117
|
+
fi
|
|
118
|
+
else
|
|
119
|
+
warn "Node.js not found. Install Node 24 or 26 (nvm, or https://nodejs.org)."
|
|
120
|
+
fi
|
|
121
|
+
|
|
122
|
+
echo ""
|
|
123
|
+
if [ "$CHECK" -eq 1 ]; then
|
|
124
|
+
info "Check complete. Re-run without --check to install what is missing."
|
|
125
|
+
else
|
|
126
|
+
info "Setup finished. If Rust was just installed, open a new shell (or run '. \"\$HOME/.cargo/env\"'), then:"
|
|
127
|
+
echo " npm install"
|
|
128
|
+
echo " npm run build"
|
|
129
|
+
fi
|