xbintsc 0.6.22 → 0.6.23
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/AGENTS.md +5 -0
- package/dist/src/cli/help.d.ts +1 -1
- package/dist/src/driver/build-key.js +2 -1
- package/dist/src/driver/build-key.js.map +1 -1
- package/dist/src/driver/fingerprint.d.ts +11 -0
- package/dist/src/driver/fingerprint.js +25 -0
- package/dist/src/driver/fingerprint.js.map +1 -1
- package/dist/src/driver/link-features.js +36 -11
- package/dist/src/driver/link-features.js.map +1 -1
- package/dist/src/driver/paths.d.ts +10 -0
- package/dist/src/driver/paths.js +18 -0
- package/dist/src/driver/paths.js.map +1 -1
- package/dist/src/driver/runtime-objects.d.ts +1 -1
- package/dist/src/driver/runtime-objects.js +22 -6
- package/dist/src/driver/runtime-objects.js.map +1 -1
- package/dist/src/driver/toolchain.d.ts +1 -1
- package/dist/src/driver/toolchain.js +10 -1
- package/dist/src/driver/toolchain.js.map +1 -1
- package/dist/src/driver/version.d.ts +1 -1
- package/dist/src/driver/version.js +1 -1
- package/dist/src/extensions/node/http2/feature.d.ts +14 -0
- package/dist/src/extensions/node/http2/feature.js +28 -0
- package/dist/src/extensions/node/http2/feature.js.map +1 -0
- package/dist/src/extensions/node/http2/index.d.ts +5 -1
- package/dist/src/extensions/node/http2/index.js +6 -1
- package/dist/src/extensions/node/http2/index.js.map +1 -1
- package/dist/src/extensions/node/index.js +3 -1
- package/dist/src/extensions/node/index.js.map +1 -1
- package/dist/src/extensions/node/tls/feature.d.ts +12 -0
- package/dist/src/extensions/node/tls/feature.js +24 -0
- package/dist/src/extensions/node/tls/feature.js.map +1 -0
- package/dist/src/extensions/node/tls/index.d.ts +5 -1
- package/dist/src/extensions/node/tls/index.js +5 -1
- package/dist/src/extensions/node/tls/index.js.map +1 -1
- package/dist/src/extensions/node/zlib/compression.js +11 -6
- package/dist/src/extensions/node/zlib/compression.js.map +1 -1
- package/dist/src/extensions/registry.js +2 -1
- package/dist/src/extensions/registry.js.map +1 -1
- package/dist/src/extensions/storage.js +4 -3
- package/dist/src/extensions/storage.js.map +1 -1
- package/dist/src/extensions/tls.d.ts +26 -0
- package/dist/src/extensions/tls.js +46 -0
- package/dist/src/extensions/tls.js.map +1 -0
- package/dist/tests/driver/link-features.test.js +9 -0
- package/dist/tests/driver/link-features.test.js.map +1 -1
- package/dist/tests/e2e/fetch.test.js +3 -1
- package/dist/tests/e2e/fetch.test.js.map +1 -1
- package/dist/tests/e2e/http2.test.d.ts +7 -0
- package/dist/tests/e2e/http2.test.js +201 -0
- package/dist/tests/e2e/http2.test.js.map +1 -0
- package/dist/tests/e2e/net-helpers.d.ts +28 -0
- package/dist/tests/e2e/net-helpers.js +59 -0
- package/dist/tests/e2e/net-helpers.js.map +1 -0
- package/dist/tests/e2e/node-modules.test.js +3 -5
- package/dist/tests/e2e/node-modules.test.js.map +1 -1
- package/dist/tests/e2e/tls.test.d.ts +10 -0
- package/dist/tests/e2e/tls.test.js +197 -0
- package/dist/tests/e2e/tls.test.js.map +1 -0
- package/dist/tests/extensions/storage.test.js +3 -2
- package/dist/tests/extensions/storage.test.js.map +1 -1
- package/doc/ai/contributing.md +14 -0
- package/doc/ai/extensions.md +5 -3
- package/doc/ai/language-support.md +1 -1
- package/doc/ai/zh-CN/contributing.md +12 -0
- package/doc/ai/zh-CN/extensions.md +4 -2
- package/doc/ai/zh-CN/language-support.md +1 -1
- package/doc/gui/api.md +1 -1
- package/doc/gui/build.md +5 -3
- package/doc/gui/rendering.md +1 -1
- package/doc/gui.md +1 -1
- package/doc/implemented/async.md +1 -1
- package/doc/implemented/extensions.md +1 -0
- package/doc/implemented/fetch.md +19 -4
- package/doc/implemented/node/http2.md +51 -0
- package/doc/implemented/node/tls.md +56 -0
- package/doc/implemented/node.md +8 -0
- package/doc/implemented/storage.md +2 -1
- package/doc/implemented.md +2 -2
- package/doc/unimplemented/node/modules.md +6 -6
- package/doc/unimplemented/toolchain.md +1 -1
- package/doc/zh-CN/gui/api.md +1 -1
- package/doc/zh-CN/gui/build.md +4 -2
- package/doc/zh-CN/gui/rendering.md +1 -1
- package/doc/zh-CN/gui.md +1 -1
- package/doc/zh-CN/implemented/async.md +1 -1
- package/doc/zh-CN/implemented/extensions.md +1 -0
- package/doc/zh-CN/implemented/fetch.md +15 -3
- package/doc/zh-CN/implemented/node/http2.md +44 -0
- package/doc/zh-CN/implemented/node/tls.md +47 -0
- package/doc/zh-CN/implemented/node.md +7 -0
- package/doc/zh-CN/implemented/storage.md +2 -1
- package/doc/zh-CN/implemented.md +2 -2
- package/doc/zh-CN/unimplemented/node/modules.md +3 -3
- package/doc/zh-CN/unimplemented/toolchain.md +1 -1
- package/package.json +16 -8
- package/runtime/ext_node/http2/http2.c +25 -11
- package/runtime/ext_node/http2/http2_backend.c +48 -0
- package/runtime/ext_node/http2/http2_bridge.c +25 -0
- package/runtime/ext_node/http2/parts/api.inc +40 -0
- package/runtime/ext_node/http2/parts/client.inc +215 -0
- package/runtime/ext_node/http2/parts/common.inc +330 -0
- package/runtime/ext_node/http2/parts/events.inc +139 -0
- package/runtime/ext_node/http2/parts/server.inc +301 -0
- package/runtime/ext_node/http2/parts/streams.inc +254 -0
- package/runtime/ext_node/tls/parts/api.inc +38 -0
- package/runtime/ext_node/tls/parts/connect.inc +107 -0
- package/runtime/ext_node/tls/parts/helpers.inc +121 -0
- package/runtime/ext_node/tls/parts/server.inc +101 -0
- package/runtime/ext_node/tls/parts/socket.inc +171 -0
- package/runtime/ext_node/tls/tls.c +21 -13
- package/runtime/ext_node/tls/tls_backend.c +50 -0
- package/runtime/ext_node/zlib/{miniz/compression_bridge.c → compression_bridge.c} +1 -1
- package/runtime/xt_fetch/async.inc +19 -12
- package/runtime/xt_fetch/socket.inc +55 -0
- package/runtime/xt_fetch.c +3 -0
- package/runtime/xt_http2/nghttp2_compat.h +19 -0
- package/runtime/xt_http2/nghttp2_static.h +18 -0
- package/runtime/xt_http2_api.h +38 -0
- package/runtime/xt_node_tls_api.h +37 -0
- package/runtime/xt_protocol_registry.c +22 -0
- package/runtime/xt_storage/storage_internal.h +3 -3
- package/runtime/xt_tls/parts/api.inc +21 -0
- package/runtime/xt_tls/parts/client.inc +112 -0
- package/runtime/xt_tls/parts/io.inc +157 -0
- package/runtime/xt_tls/parts/server.inc +102 -0
- package/runtime/xt_tls/parts/setup.inc +146 -0
- package/runtime/xt_tls/tls_bridge.c +27 -0
- package/runtime/xt_tls/tls_core.c +39 -0
- package/runtime/xt_tls/tls_internal.h +73 -0
- package/runtime/xt_tls_api.h +73 -0
- package/scripts/build-gui.ts +8 -7
- package/scripts/build-tls.ts +248 -0
- package/scripts/check-file-length.ts +4 -25
- package/scripts/fetch-vendored.ts +244 -0
- package/scripts/package-release.ts +13 -3
- package/src/driver/build-key.ts +7 -1
- package/src/driver/fingerprint.ts +24 -0
- package/src/driver/link-features.ts +33 -11
- package/src/driver/paths.ts +20 -0
- package/src/driver/runtime-objects.ts +25 -6
- package/src/driver/toolchain.ts +11 -2
- package/src/driver/version.ts +1 -1
- package/src/extensions/node/http2/feature.ts +33 -0
- package/src/extensions/node/http2/index.ts +6 -1
- package/src/extensions/node/index.ts +3 -1
- package/src/extensions/node/tls/feature.ts +29 -0
- package/src/extensions/node/tls/index.ts +5 -1
- package/src/extensions/node/zlib/compression.ts +11 -6
- package/src/extensions/registry.ts +2 -1
- package/src/extensions/storage.ts +4 -3
- package/src/extensions/tls.ts +52 -0
- package/{runtime/ext_gui → vendor/stb}/stb_image.h +17 -1
- /package/{runtime/ext_node/zlib → vendor}/miniz/miniz.c +0 -0
- /package/{runtime/ext_node/zlib → vendor}/miniz/miniz.h +0 -0
- /package/{runtime/ext_node/zlib → vendor}/miniz/miniz_common.h +0 -0
- /package/{runtime/ext_node/zlib → vendor}/miniz/miniz_export.h +0 -0
- /package/{runtime/ext_node/zlib → vendor}/miniz/miniz_tdef.c +0 -0
- /package/{runtime/ext_node/zlib → vendor}/miniz/miniz_tdef.h +0 -0
- /package/{runtime/ext_node/zlib → vendor}/miniz/miniz_tinfl.c +0 -0
- /package/{runtime/ext_node/zlib → vendor}/miniz/miniz_tinfl.h +0 -0
- /package/{runtime/ext_node/zlib → vendor}/miniz/miniz_zip.h +0 -0
- /package/{runtime/ext_gui → vendor/nanosvg}/nanosvg.h +0 -0
- /package/{runtime/ext_gui → vendor/nanosvg}/nanosvgrast.h +0 -0
- /package/{runtime/xt_storage → vendor}/sqlite3/sqlite3.c +0 -0
- /package/{runtime/xt_storage → vendor}/sqlite3/sqlite3.h +0 -0
- /package/{runtime/ext_gui → vendor/stb}/stb_truetype.h +0 -0
|
@@ -7,8 +7,9 @@
|
|
|
7
7
|
* the runtime's C, C++, Rust and `#include`d `.inc` fragments plus shell
|
|
8
8
|
* scripts, so *every* code file stays focused and small.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
10
|
+
* Third-party sources are fetched into `vendor/` instead of being committed
|
|
11
|
+
* (see `scripts/fetch-vendored.ts`), so the walk skips that directory: nothing
|
|
12
|
+
* vendored is ours to split, and it is not part of the tree this check owns.
|
|
12
13
|
*
|
|
13
14
|
* Run via `npm run lint` (or `tsx scripts/check-file-length.ts`).
|
|
14
15
|
*/
|
|
@@ -35,28 +36,6 @@ const IGNORED_DIRECTORIES = new Set([
|
|
|
35
36
|
"vendor",
|
|
36
37
|
]);
|
|
37
38
|
|
|
38
|
-
/** Vendored third-party sources that ship verbatim and are not ours to split. */
|
|
39
|
-
const VENDORED_FILES = new Set([
|
|
40
|
-
join("runtime", "ext_gui", "stb_image.h"),
|
|
41
|
-
join("runtime", "ext_gui", "stb_truetype.h"),
|
|
42
|
-
join("runtime", "ext_gui", "nanosvg.h"),
|
|
43
|
-
join("runtime", "ext_gui", "nanosvgrast.h"),
|
|
44
|
-
// miniz, the single-file DEFLATE library used by the `compression` link
|
|
45
|
-
// feature (`node:zlib`), ships verbatim.
|
|
46
|
-
join("runtime", "ext_node", "zlib", "miniz", "miniz.c"),
|
|
47
|
-
join("runtime", "ext_node", "zlib", "miniz", "miniz.h"),
|
|
48
|
-
join("runtime", "ext_node", "zlib", "miniz", "miniz_tdef.c"),
|
|
49
|
-
join("runtime", "ext_node", "zlib", "miniz", "miniz_tdef.h"),
|
|
50
|
-
join("runtime", "ext_node", "zlib", "miniz", "miniz_tinfl.c"),
|
|
51
|
-
join("runtime", "ext_node", "zlib", "miniz", "miniz_tinfl.h"),
|
|
52
|
-
join("runtime", "ext_node", "zlib", "miniz", "miniz_common.h"),
|
|
53
|
-
join("runtime", "ext_node", "zlib", "miniz", "miniz_export.h"),
|
|
54
|
-
// SQLite, the single-file amalgamation backing the `storage` extension
|
|
55
|
-
// (localStorage / sessionStorage / indexedDB), ships verbatim.
|
|
56
|
-
join("runtime", "xt_storage", "sqlite3", "sqlite3.c"),
|
|
57
|
-
join("runtime", "xt_storage", "sqlite3", "sqlite3.h"),
|
|
58
|
-
]);
|
|
59
|
-
|
|
60
39
|
/** Machine-generated files: they are reproduced from their sources by a script,
|
|
61
40
|
* so their size is not a sign of a module that needs splitting. */
|
|
62
41
|
const GENERATED_FILES = new Set([join("runtime", "ext_gui", "renderer_shaders_data.h")]);
|
|
@@ -88,7 +67,7 @@ function collect(dir: string, offenses: Offense[]): void {
|
|
|
88
67
|
const dot = entry.name.lastIndexOf(".");
|
|
89
68
|
if (dot < 0 || !CODE_EXTENSIONS.has(entry.name.slice(dot))) continue;
|
|
90
69
|
const file = relative(root, full);
|
|
91
|
-
if (
|
|
70
|
+
if (GENERATED_FILES.has(file)) continue;
|
|
92
71
|
const lines = countLines(full);
|
|
93
72
|
if (lines > MAX_LINES) offenses.push({ file, lines });
|
|
94
73
|
}
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Fetch the third-party C sources that xbintsc compiles, into `vendor/`.
|
|
4
|
+
*
|
|
5
|
+
* Those libraries are vendored *by version*, not committed: the repository
|
|
6
|
+
* tracks neither their code nor their line count. Each entry pins an immutable
|
|
7
|
+
* upstream revision and the SHA-256 of the extracted file, so a changed pin is
|
|
8
|
+
* a reviewable change and a corrupted download can never reach a build.
|
|
9
|
+
*
|
|
10
|
+
* Layout (sibling of `runtime/`, so `findVendorDir()` can find it in a source
|
|
11
|
+
* checkout, an unpacked release and an npm install alike):
|
|
12
|
+
*
|
|
13
|
+
* vendor/stb/stb_image.h, stb_truetype.h
|
|
14
|
+
* vendor/nanosvg/nanosvg.h, nanosvgrast.h
|
|
15
|
+
* vendor/miniz/… the `compression` link feature
|
|
16
|
+
* vendor/sqlite3/sqlite3.{c,h} the `storage` link feature
|
|
17
|
+
*
|
|
18
|
+
* `build-gui.ts` fetches just `stb`/`nanosvg`; `npm test` fetches everything.
|
|
19
|
+
* CI caches the four directories keyed on this script.
|
|
20
|
+
*
|
|
21
|
+
* Note: miniz's upstream tree has no `miniz_export.h` (its CMake build generates
|
|
22
|
+
* one). The static-only shim below is written here rather than tracked.
|
|
23
|
+
*
|
|
24
|
+
* Run via `npm run vendor` (or `tsx scripts/fetch-vendored.ts`).
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
import { spawnSync } from "node:child_process";
|
|
28
|
+
import { createHash } from "node:crypto";
|
|
29
|
+
import { copyFileSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
30
|
+
import { basename, dirname, join, resolve } from "node:path";
|
|
31
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
32
|
+
import { downloadTarball } from "./fetch-tarball.js";
|
|
33
|
+
|
|
34
|
+
const root = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
|
35
|
+
export const vendorDir = join(root, "vendor");
|
|
36
|
+
|
|
37
|
+
/** The vendored packages, each a directory under `vendor/`. */
|
|
38
|
+
export const VENDOR_PACKAGES = ["stb", "nanosvg", "miniz", "sqlite3"] as const;
|
|
39
|
+
export type VendorPackage = (typeof VENDOR_PACKAGES)[number];
|
|
40
|
+
|
|
41
|
+
interface VendoredFile {
|
|
42
|
+
readonly package: Exclude<VendorPackage, "sqlite3">;
|
|
43
|
+
readonly name: string;
|
|
44
|
+
readonly url: string;
|
|
45
|
+
readonly sha256: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/* Pinned upstream revisions. STB and NanoSVG have no releases, so the commit
|
|
49
|
+
* is the version; miniz is pinned to the commit whose files this tree uses. */
|
|
50
|
+
const STB_IMAGE = "013ac3beddff3dbffafd5177e7972067cd2b5083";
|
|
51
|
+
const STB_TRUETYPE = "c0c982601f40183e74d84a61237e968dca08380e";
|
|
52
|
+
const NANOSVG = "239e102ec2c691f2902e20ace2ed36ee4a35cfe6";
|
|
53
|
+
const MINIZ = "2c50092b3a4010760df02e7842960abdc3f25ee3";
|
|
54
|
+
|
|
55
|
+
const RAW = "https://raw.githubusercontent.com";
|
|
56
|
+
|
|
57
|
+
const FILES: readonly VendoredFile[] = [
|
|
58
|
+
{
|
|
59
|
+
package: "stb",
|
|
60
|
+
name: "stb_image.h",
|
|
61
|
+
url: `${RAW}/nothings/stb/${STB_IMAGE}/stb_image.h`,
|
|
62
|
+
sha256: "594c2fe35d49488b4382dbfaec8f98366defca819d916ac95becf3e75f4200b3",
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
package: "stb",
|
|
66
|
+
name: "stb_truetype.h",
|
|
67
|
+
url: `${RAW}/nothings/stb/${STB_TRUETYPE}/stb_truetype.h`,
|
|
68
|
+
sha256: "a34d8d536ce7c11b9163ab2d524721c1f4df1452cce6595c4f11d3048384f925",
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
package: "nanosvg",
|
|
72
|
+
name: "nanosvg.h",
|
|
73
|
+
url: `${RAW}/memononen/nanosvg/${NANOSVG}/src/nanosvg.h`,
|
|
74
|
+
sha256: "e34fd5d084be106cea972d19ce5d27fd96d17ba89f8d06bdceee058420c8b2b0",
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
package: "nanosvg",
|
|
78
|
+
name: "nanosvgrast.h",
|
|
79
|
+
url: `${RAW}/memononen/nanosvg/${NANOSVG}/src/nanosvgrast.h`,
|
|
80
|
+
sha256: "79a9c5f4db19debf9f3a648a1589e96d92854f245a5cb4f3d823f263785234d8",
|
|
81
|
+
},
|
|
82
|
+
...(
|
|
83
|
+
[
|
|
84
|
+
["miniz.c", "29a0c08c4610d20ab18381cbf18190f91b4b41d05c242376364756061b631f1d"],
|
|
85
|
+
["miniz.h", "2b9c48355793988f0d12b3cef357e52b741d744385157b59cb422237ea226501"],
|
|
86
|
+
["miniz_common.h", "d0770cc478923e33bf22820fc51bbe22b6b99c3230ce4f5fc10eea3debc75623"],
|
|
87
|
+
["miniz_tdef.c", "7b3baaa59f50116eb3e72a23302c505b76cb01cc456672f7957a74d9e7b44047"],
|
|
88
|
+
["miniz_tdef.h", "123050e3c876519828d3934899e0b003ad13a98114919d94f1e06b4b9d02a925"],
|
|
89
|
+
["miniz_tinfl.c", "7113a08a7722d671ce89b8de61fe6d02d0cadca0ff274ba357bf2a9dc85745ca"],
|
|
90
|
+
["miniz_tinfl.h", "2c89615a4cbc5de4eac5b861051849392ec698264ee7dd399ea587c592cf68d1"],
|
|
91
|
+
["miniz_zip.h", "43d09867f79993a9ba1627cb1f3bbd78d3bf5ee0c91cd6e7527aa9ca1e3aed44"],
|
|
92
|
+
] as const
|
|
93
|
+
).map(([name, sha256]) => ({
|
|
94
|
+
package: "miniz" as const,
|
|
95
|
+
name,
|
|
96
|
+
url: `${RAW}/richgel999/miniz/${MINIZ}/${name}`,
|
|
97
|
+
sha256,
|
|
98
|
+
})),
|
|
99
|
+
];
|
|
100
|
+
|
|
101
|
+
/** miniz's static-build export shim (upstream generates it with CMake). */
|
|
102
|
+
const MINIZ_EXPORT_H =
|
|
103
|
+
"/* Minimal export macro for a static miniz build (no DLL import/export). */\n" +
|
|
104
|
+
"#ifndef MINIZ_EXPORT\n" +
|
|
105
|
+
"#define MINIZ_EXPORT\n" +
|
|
106
|
+
"#endif\n";
|
|
107
|
+
|
|
108
|
+
/* SQLite publishes one amalgamation zip per release; only the two files below
|
|
109
|
+
* are compiled. The zip itself is pinned as well: a truncated download is a
|
|
110
|
+
* download to retry, not an amalgamation to build. */
|
|
111
|
+
const SQLITE_PACKAGE = "sqlite-amalgamation-3540100";
|
|
112
|
+
const SQLITE_URL = `https://www.sqlite.org/2026/${SQLITE_PACKAGE}.zip`;
|
|
113
|
+
const SQLITE_ZIP_SHA256 = "0a9c8e34352dad46006aa82836d5383bff9dc6bc9ce5a60553c05aa30e6ad1f9";
|
|
114
|
+
const SQLITE_FILES = [
|
|
115
|
+
{
|
|
116
|
+
name: "sqlite3.c",
|
|
117
|
+
sha256: "0c657666d819f261cc4007526ad57e1669de9949df7a8ea847aa284a2bf0ee52",
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
name: "sqlite3.h",
|
|
121
|
+
sha256: "d6c84557261893439b341d2e6c35187ae3ea24fbfd843ad94616f72d89242b8c",
|
|
122
|
+
},
|
|
123
|
+
] as const;
|
|
124
|
+
|
|
125
|
+
function sha256(file: string): string {
|
|
126
|
+
return createHash("sha256").update(readFileSync(file)).digest("hex");
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function isPinned(file: string, digest: string): boolean {
|
|
130
|
+
return existsSync(file) && sha256(file) === digest;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** Download one file, refusing to leave a mismatched (stale or corrupted) file. */
|
|
134
|
+
function ensureFile(file: VendoredFile): void {
|
|
135
|
+
const target = join(vendorDir, file.package, file.name);
|
|
136
|
+
if (isPinned(target, file.sha256)) return;
|
|
137
|
+
mkdirSync(dirname(target), { recursive: true });
|
|
138
|
+
rmSync(target, { force: true });
|
|
139
|
+
downloadTarball(target, file.url, `${file.package}/${file.name}`);
|
|
140
|
+
if (isPinned(target, file.sha256)) return;
|
|
141
|
+
const actual = sha256(target);
|
|
142
|
+
rmSync(target, { force: true });
|
|
143
|
+
throw new Error(
|
|
144
|
+
`${file.package}/${file.name}: expected sha256 ${file.sha256}, got ${actual}. ` +
|
|
145
|
+
"The upstream pin moved; update the URL and hash in scripts/fetch-vendored.ts deliberately.",
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** Write the generated miniz export shim (no upstream file to download). */
|
|
150
|
+
function ensureMinizExportHeader(): void {
|
|
151
|
+
const target = join(vendorDir, "miniz", "miniz_export.h");
|
|
152
|
+
if (existsSync(target) && readFileSync(target, "utf8") === MINIZ_EXPORT_H) return;
|
|
153
|
+
mkdirSync(dirname(target), { recursive: true });
|
|
154
|
+
writeFileSync(target, MINIZ_EXPORT_H);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** Extract a zip archive; Windows' bsdtar and POSIX's unzip cover the hosts. */
|
|
158
|
+
function extractZip(zip: string, destination: string): void {
|
|
159
|
+
const attempts: readonly (readonly [string, readonly string[]])[] =
|
|
160
|
+
process.platform === "win32"
|
|
161
|
+
? [
|
|
162
|
+
["tar", ["-xf", zip, "-C", destination]],
|
|
163
|
+
["unzip", ["-q", "-o", zip, "-d", destination]],
|
|
164
|
+
]
|
|
165
|
+
: [
|
|
166
|
+
["unzip", ["-q", "-o", zip, "-d", destination]],
|
|
167
|
+
["tar", ["-xf", zip, "-C", destination]],
|
|
168
|
+
];
|
|
169
|
+
for (const [command, args] of attempts) {
|
|
170
|
+
if (spawnSync(command, args, { stdio: "ignore" }).status === 0) return;
|
|
171
|
+
}
|
|
172
|
+
throw new Error(`cannot extract ${basename(zip)}; install unzip (or a tar that reads zip archives)`);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** Fetch the pinned SQLite amalgamation and copy out its two sources. */
|
|
176
|
+
function ensureSqlite(): void {
|
|
177
|
+
const directory = join(vendorDir, "sqlite3");
|
|
178
|
+
if (SQLITE_FILES.every((file) => isPinned(join(directory, file.name), file.sha256))) return;
|
|
179
|
+
|
|
180
|
+
const cache = join(vendorDir, ".cache");
|
|
181
|
+
mkdirSync(cache, { recursive: true });
|
|
182
|
+
const zip = join(cache, `${SQLITE_PACKAGE}.zip`);
|
|
183
|
+
if (!isPinned(zip, SQLITE_ZIP_SHA256)) {
|
|
184
|
+
rmSync(zip, { force: true });
|
|
185
|
+
downloadTarball(zip, SQLITE_URL, `${SQLITE_PACKAGE}.zip`);
|
|
186
|
+
if (!isPinned(zip, SQLITE_ZIP_SHA256)) {
|
|
187
|
+
const actual = sha256(zip);
|
|
188
|
+
rmSync(zip, { force: true });
|
|
189
|
+
throw new Error(`${SQLITE_PACKAGE}.zip: expected sha256 ${SQLITE_ZIP_SHA256}, got ${actual}`);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const extracted = join(cache, SQLITE_PACKAGE);
|
|
194
|
+
rmSync(extracted, { recursive: true, force: true });
|
|
195
|
+
mkdirSync(extracted, { recursive: true });
|
|
196
|
+
extractZip(zip, extracted);
|
|
197
|
+
const sourceDir = join(extracted, SQLITE_PACKAGE);
|
|
198
|
+
if (!existsSync(join(sourceDir, "sqlite3.c"))) {
|
|
199
|
+
throw new Error(`expected ${SQLITE_PACKAGE}/sqlite3.c after extracting ${basename(zip)}`);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
mkdirSync(directory, { recursive: true });
|
|
203
|
+
for (const file of SQLITE_FILES) {
|
|
204
|
+
const target = join(directory, file.name);
|
|
205
|
+
copyFileSync(join(sourceDir, file.name), target);
|
|
206
|
+
if (!isPinned(target, file.sha256)) {
|
|
207
|
+
const actual = sha256(target);
|
|
208
|
+
rmSync(target, { force: true });
|
|
209
|
+
throw new Error(`sqlite3/${file.name}: expected sha256 ${file.sha256}, got ${actual}`);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
rmSync(extracted, { recursive: true, force: true });
|
|
213
|
+
rmSync(zip, { force: true });
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Ensure the requested vendored packages exist and match their pins.
|
|
218
|
+
* Downloads only what is missing; everything else is a content check.
|
|
219
|
+
*/
|
|
220
|
+
export function ensureVendoredSources(packages: readonly VendorPackage[] = VENDOR_PACKAGES): void {
|
|
221
|
+
for (const name of packages) {
|
|
222
|
+
if (name === "sqlite3") {
|
|
223
|
+
ensureSqlite();
|
|
224
|
+
continue;
|
|
225
|
+
}
|
|
226
|
+
for (const file of FILES) {
|
|
227
|
+
if (file.package === name) ensureFile(file);
|
|
228
|
+
}
|
|
229
|
+
if (name === "miniz") ensureMinizExportHeader();
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
const invokedDirectly =
|
|
234
|
+
process.argv[1] !== undefined && import.meta.url === pathToFileURL(process.argv[1]).href;
|
|
235
|
+
|
|
236
|
+
if (invokedDirectly) {
|
|
237
|
+
try {
|
|
238
|
+
ensureVendoredSources();
|
|
239
|
+
console.log("xbintsc: vendored sources are present and match their pins");
|
|
240
|
+
} catch (error) {
|
|
241
|
+
console.error(`xbintsc: ${error instanceof Error ? error.message : String(error)}`);
|
|
242
|
+
process.exit(1);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
* xbintsc-<os>-<arch>/
|
|
22
22
|
* bin/xbintsc[.exe] the self-hosted compiler
|
|
23
23
|
* runtime/ C runtime sources + prebuilt runtime/lib/<slug>
|
|
24
|
+
* vendor/ pinned third-party sources (fetched, not committed)
|
|
24
25
|
* README.md
|
|
25
26
|
*
|
|
26
27
|
* The compiler locates `runtime/` relative to its own executable (see
|
|
@@ -108,13 +109,22 @@ console.log("xbintsc: copying runtime/ into the staging tree");
|
|
|
108
109
|
cpSync(findRuntimeDir(), join(stage, "runtime"), { recursive: true });
|
|
109
110
|
console.log("xbintsc: packaged runtime/");
|
|
110
111
|
|
|
111
|
-
// 3.
|
|
112
|
+
// 3. Vendored sources the driver compiles on demand (SQLite for `storage`,
|
|
113
|
+
// miniz for `compression`). They are fetched by `npm run vendor`, not committed.
|
|
114
|
+
for (const name of ["stb", "nanosvg", "miniz", "sqlite3"]) {
|
|
115
|
+
const source = join(root, "vendor", name);
|
|
116
|
+
if (!existsSync(source)) fail(`missing vendor/${name}; run \`npm run vendor\` before packaging`);
|
|
117
|
+
cpSync(source, join(stage, "vendor", name), { recursive: true });
|
|
118
|
+
}
|
|
119
|
+
console.log("xbintsc: packaged vendor/");
|
|
120
|
+
|
|
121
|
+
// 4. Human-facing notes.
|
|
112
122
|
for (const name of ["README.md", "LICENSE"]) {
|
|
113
123
|
const source = join(root, name);
|
|
114
124
|
if (existsSync(source)) copyFileSync(source, join(stage, name));
|
|
115
125
|
}
|
|
116
126
|
|
|
117
|
-
//
|
|
127
|
+
// 5. Archive it. Prefer zstd when available, otherwise gzip.
|
|
118
128
|
const hasZstd = !spawnSync("zstd", ["--version"], { stdio: "ignore" }).error;
|
|
119
129
|
const extension = releaseArchiveExtension(hasZstd);
|
|
120
130
|
const archive = join(releaseRoot, `${archiveBase}${extension}`);
|
|
@@ -128,7 +138,7 @@ const tar = spawnSync("tar", tarArgs, { stdio: "inherit" });
|
|
|
128
138
|
if (tar.error) fail(`failed to run tar: ${tar.error.message}`);
|
|
129
139
|
if (tar.status !== 0) fail(`tar exited with ${tar.status}`);
|
|
130
140
|
|
|
131
|
-
//
|
|
141
|
+
// 6. Checksum, so users can verify the download.
|
|
132
142
|
const digest = createHash("sha256").update(readFileSync(archive)).digest("hex");
|
|
133
143
|
writeFileSync(`${archive}.sha256`, `${digest} ${basename(archive)}\n`);
|
|
134
144
|
|
package/src/driver/build-key.ts
CHANGED
|
@@ -11,7 +11,12 @@
|
|
|
11
11
|
import type { ExtensionRegistry } from "../extensions/registry.js";
|
|
12
12
|
import { hashParts } from "./cache.js";
|
|
13
13
|
import type { AppConfig } from "./config.js";
|
|
14
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
compilerFingerprint,
|
|
16
|
+
registryFingerprint,
|
|
17
|
+
runtimeFingerprint,
|
|
18
|
+
vendoredRuntimeFingerprint,
|
|
19
|
+
} from "./fingerprint.js";
|
|
15
20
|
import { COMPILER_VERSION } from "./version.js";
|
|
16
21
|
import type { IconInfo } from "./icon.js";
|
|
17
22
|
import type { ResolvedStorage } from "./storage.js";
|
|
@@ -50,6 +55,7 @@ export function buildCacheKey(input: CacheKeyInput): string {
|
|
|
50
55
|
process.platform,
|
|
51
56
|
registryFingerprint(input.registry),
|
|
52
57
|
runtimeFingerprint(input.runtimeDir),
|
|
58
|
+
vendoredRuntimeFingerprint(input.runtimeDir),
|
|
53
59
|
icon ? hashParts(["icon", icon.format, Buffer.from(icon.bytes).toString("base64")]) : "",
|
|
54
60
|
app.name ?? "",
|
|
55
61
|
String(app.bundle ?? false),
|
|
@@ -34,6 +34,30 @@ export function runtimeFingerprint(runtimeDir: string): string {
|
|
|
34
34
|
return hashParts(parts);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
/**
|
|
38
|
+
* Content hash of the vendored C sources a link feature compiles into the
|
|
39
|
+
* program (`vendor/miniz` for `compression`, `vendor/sqlite3` for `storage`).
|
|
40
|
+
*
|
|
41
|
+
* They live outside `runtime/` — the tree is fetched, not committed — so
|
|
42
|
+
* {@link runtimeFingerprint} cannot see them, yet changing one changes the
|
|
43
|
+
* linked binary. Only the two packages compiled at program-build time are
|
|
44
|
+
* hashed: `stb`/`nanosvg` are baked into `gui.a`, whose content the registry
|
|
45
|
+
* fingerprint already covers.
|
|
46
|
+
*/
|
|
47
|
+
export function vendoredRuntimeFingerprint(runtimeDir: string): string {
|
|
48
|
+
const vendorDir = resolve(runtimeDir, "..", "vendor");
|
|
49
|
+
const parts: string[] = [];
|
|
50
|
+
for (const name of ["miniz", "sqlite3"]) {
|
|
51
|
+
const dir = join(vendorDir, name);
|
|
52
|
+
if (!existsSync(dir)) continue;
|
|
53
|
+
for (const entry of readdirSync(dir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
54
|
+
if (!entry.isFile()) continue;
|
|
55
|
+
parts.push(name, entry.name, readFileSync(join(dir, entry.name)).toString("base64"));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return hashParts(parts);
|
|
59
|
+
}
|
|
60
|
+
|
|
37
61
|
/**
|
|
38
62
|
* Content hash of the compiler's own TypeScript sources, when they are present.
|
|
39
63
|
*
|
|
@@ -94,33 +94,55 @@ export function resolveLinkFeatures(
|
|
|
94
94
|
}
|
|
95
95
|
if (specificallyForced || (forceAll && !specificallyBlocked)) forced.add(feature.name);
|
|
96
96
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
97
|
+
/* `strict` records the features whose absence is an error: everything the
|
|
98
|
+
* user asked for, plus its `requires` closure. An auto-detected feature is
|
|
99
|
+
* allowed to be unavailable (the driver warns), but a feature the user named
|
|
100
|
+
* must either link or fail the build. */
|
|
101
|
+
const strict = new Set(forced);
|
|
102
|
+
const expand = (target: Set<string>, roots: readonly string[]): void => {
|
|
103
|
+
const queue = [...roots];
|
|
104
|
+
while (queue.length > 0) {
|
|
105
|
+
const name = queue.pop()!;
|
|
106
|
+
const feature = byName.get(name);
|
|
107
|
+
if (feature === undefined) continue;
|
|
102
108
|
for (const dependency of feature.requires ?? []) {
|
|
103
109
|
if (!byName.has(dependency)) {
|
|
104
110
|
diagnostics.error(
|
|
105
111
|
DiagnosticCode.LinkFeatureUnavailable,
|
|
106
|
-
`link feature '${
|
|
112
|
+
`link feature '${name}' requires unknown feature '${dependency}'`,
|
|
107
113
|
);
|
|
108
114
|
continue;
|
|
109
115
|
}
|
|
110
116
|
if (disabled.has(dependency)) {
|
|
111
117
|
diagnostics.error(
|
|
112
118
|
DiagnosticCode.LinkFeatureUnavailable,
|
|
113
|
-
`link feature '${
|
|
119
|
+
`link feature '${name}' requires '${dependency}', which --no-feature disables`,
|
|
114
120
|
);
|
|
115
121
|
continue;
|
|
116
122
|
}
|
|
117
|
-
if (!
|
|
118
|
-
|
|
119
|
-
|
|
123
|
+
if (!target.has(dependency)) {
|
|
124
|
+
target.add(dependency);
|
|
125
|
+
queue.push(dependency);
|
|
120
126
|
}
|
|
121
127
|
}
|
|
122
128
|
}
|
|
129
|
+
};
|
|
130
|
+
expand(strict, [...strict]);
|
|
131
|
+
for (const name of strict) forced.add(name);
|
|
132
|
+
|
|
133
|
+
/* Select the program's auto-detected features and pull in `requires`
|
|
134
|
+
* transitively. Dependencies are resolved for every selected feature, not
|
|
135
|
+
* just the explicitly forced ones: `node:tls` is auto-detected from the
|
|
136
|
+
* import, and the transport it builds on (`tls`) must be linked with it. */
|
|
137
|
+
const autoRoots: string[] = [];
|
|
138
|
+
for (const { feature } of declarations) {
|
|
139
|
+
if (forced.has(feature.name) || disabled.has(feature.name)) continue;
|
|
140
|
+
if (disableAll && !requested.has(feature.name)) continue;
|
|
141
|
+
if (!feature.used(usage)) continue;
|
|
142
|
+
forced.add(feature.name);
|
|
143
|
+
autoRoots.push(feature.name);
|
|
123
144
|
}
|
|
145
|
+
expand(forced, autoRoots);
|
|
124
146
|
if (diagnostics.hasErrors) return [];
|
|
125
147
|
|
|
126
148
|
const resolved: ResolvedLinkFeature[] = [];
|
|
@@ -139,7 +161,7 @@ export function resolveLinkFeatures(
|
|
|
139
161
|
nativeObjects = feature.nativeObjects?.() ?? [];
|
|
140
162
|
} catch (error) {
|
|
141
163
|
const message = error instanceof Error ? error.message : String(error);
|
|
142
|
-
if (
|
|
164
|
+
if (strict.has(feature.name)) {
|
|
143
165
|
diagnostics.error(DiagnosticCode.LinkFeatureUnavailable, message);
|
|
144
166
|
} else {
|
|
145
167
|
diagnostics.warning(
|
package/src/driver/paths.ts
CHANGED
|
@@ -22,6 +22,26 @@ export function findRuntimeDir(): string {
|
|
|
22
22
|
throw new Error("Unable to locate the xbintsc runtime directory (missing runtime/rt.h)");
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Directory holding the third-party sources fetched by `npm run vendor`
|
|
27
|
+
* (`vendor/` next to `runtime/`).
|
|
28
|
+
*
|
|
29
|
+
* They are not committed: the tree is rebuilt from pinned upstream releases by
|
|
30
|
+
* `scripts/fetch-vendored.ts`. `runtime/xt_storage` and the `compression`
|
|
31
|
+
* feature resolve their C sources here, so a build that needs them fails with
|
|
32
|
+
* the command to run when the directory is missing.
|
|
33
|
+
*/
|
|
34
|
+
export function findVendorDir(): string {
|
|
35
|
+
const candidate = resolve(findRuntimeDir(), "..", "vendor");
|
|
36
|
+
const markers = [join("sqlite3", "sqlite3.c"), join("miniz", "miniz.c")];
|
|
37
|
+
if (markers.some((marker) => existsSync(join(candidate, marker)))) return candidate;
|
|
38
|
+
throw new Error(
|
|
39
|
+
"Unable to locate the xbintsc vendor directory (missing vendor/miniz/miniz.c or " +
|
|
40
|
+
"vendor/sqlite3/sqlite3.c); run `npm run vendor` in a source checkout, or reinstall " +
|
|
41
|
+
"xbintsc so the package's vendored sources are present.",
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
25
45
|
/** Platform-architecture slug, e.g. `darwin-arm64`, `linux-x64`, `win32-x64`. */
|
|
26
46
|
export function platformSlug(): string {
|
|
27
47
|
return `${process.platform}-${process.arch}`;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
10
|
-
import { basename, join, resolve } from "node:path";
|
|
10
|
+
import { basename, join, resolve, sep } from "node:path";
|
|
11
11
|
import type { ExtensionRegistry } from "../extensions/registry.js";
|
|
12
12
|
import type { ResolvedLinkFeature } from "./link-features.js";
|
|
13
13
|
import { hashParts } from "./cache.js";
|
|
@@ -46,6 +46,7 @@ export const RUNTIME_SOURCES = [
|
|
|
46
46
|
"xt_url_object.c",
|
|
47
47
|
"xt_array_buffer.c",
|
|
48
48
|
"xt_io.c",
|
|
49
|
+
"xt_protocol_registry.c",
|
|
49
50
|
] as const;
|
|
50
51
|
|
|
51
52
|
export interface RuntimeObjects {
|
|
@@ -109,15 +110,24 @@ export function ensureRuntimeObjects(options: RuntimeObjectsOptions): RuntimeObj
|
|
|
109
110
|
}
|
|
110
111
|
};
|
|
111
112
|
collectHeaders(runtimeDir);
|
|
113
|
+
/* The link features compile vendors from `vendor/`, so their headers must
|
|
114
|
+
* invalidate objects just like the runtime's own (the packages are sibling to
|
|
115
|
+
* `runtime/`, and absent in a checkout that has not run `npm run vendor`). */
|
|
116
|
+
const vendorDir = resolve(runtimeDir, "..", "vendor");
|
|
117
|
+
for (const name of ["miniz", "sqlite3"]) {
|
|
118
|
+
const dir = join(vendorDir, name);
|
|
119
|
+
if (existsSync(dir)) collectHeaders(dir);
|
|
120
|
+
}
|
|
112
121
|
const headerStamp = hashParts(headerParts);
|
|
113
122
|
|
|
114
|
-
const compileOne = (sourcePath: string, tag: string): string => {
|
|
123
|
+
const compileOne = (sourcePath: string, tag: string, includeDirs: readonly string[]): string => {
|
|
115
124
|
const body = readFileSync(sourcePath, "utf8");
|
|
116
125
|
const key = hashParts([
|
|
117
126
|
"runtime",
|
|
118
127
|
COMPILER_VERSION,
|
|
119
128
|
RUNTIME_CFLAGS.join(" "),
|
|
120
129
|
compileFlags.join(" "),
|
|
130
|
+
includeDirs.join(";"),
|
|
121
131
|
tag,
|
|
122
132
|
headerStamp,
|
|
123
133
|
body,
|
|
@@ -126,15 +136,16 @@ export function ensureRuntimeObjects(options: RuntimeObjectsOptions): RuntimeObj
|
|
|
126
136
|
]);
|
|
127
137
|
const objectPath = join(cacheDir, `${tag}-${key}.o`);
|
|
128
138
|
if (!existsSync(objectPath)) {
|
|
129
|
-
compileC(runner, clang, sourcePath, objectPath,
|
|
139
|
+
compileC(runner, clang, sourcePath, objectPath, includeDirs, env, compileFlags);
|
|
130
140
|
}
|
|
131
141
|
return objectPath;
|
|
132
142
|
};
|
|
133
143
|
|
|
144
|
+
const runtimeInclude = [runtimeDir];
|
|
134
145
|
const coreArchive = preferPrebuilt ? findRuntimeLibrary("core", options.runtimeLibDirs) : undefined;
|
|
135
146
|
const runtimeObjects = coreArchive
|
|
136
147
|
? [coreArchive]
|
|
137
|
-
: RUNTIME_SOURCES.map((source) => compileOne(join(runtimeDir, source), basename(source, ".c")));
|
|
148
|
+
: RUNTIME_SOURCES.map((source) => compileOne(join(runtimeDir, source), basename(source, ".c"), runtimeInclude));
|
|
138
149
|
|
|
139
150
|
/** Prebuilt archives this link uses; the driver retries without them. */
|
|
140
151
|
const prebuiltArchives: string[] = coreArchive ? [coreArchive] : [];
|
|
@@ -156,12 +167,20 @@ export function ensureRuntimeObjects(options: RuntimeObjectsOptions): RuntimeObj
|
|
|
156
167
|
const dedupeKey = resolve(sourcePath);
|
|
157
168
|
if (seen.has(dedupeKey)) continue;
|
|
158
169
|
seen.add(dedupeKey);
|
|
159
|
-
extensionObjects.push(
|
|
170
|
+
extensionObjects.push(
|
|
171
|
+
compileOne(sourcePath, `ext_${extensionObjects.length}_${basename(sourcePath, ".c")}`, runtimeInclude),
|
|
172
|
+
);
|
|
160
173
|
}
|
|
161
174
|
}
|
|
162
175
|
// A native archive may be shared by several manifests; link each once.
|
|
163
176
|
const featureObjects: string[] = [];
|
|
164
177
|
for (const feature of options.features ?? []) {
|
|
178
|
+
/* A feature that compiles a vendored library needs `vendor/` on the include
|
|
179
|
+
* path for its bridge (`sqlite3/sqlite3.h`, `miniz/miniz.h`). */
|
|
180
|
+
const usesVendor = feature.runtimeSources.some((sourcePath) =>
|
|
181
|
+
resolve(sourcePath).startsWith(`${vendorDir}${sep}`),
|
|
182
|
+
);
|
|
183
|
+
const featureInclude = usesVendor ? [runtimeDir, vendorDir] : runtimeInclude;
|
|
165
184
|
/* Feature bridges are always compiled: they are not part of any prebuilt
|
|
166
185
|
* archive, and their references are what make the linker extract the
|
|
167
186
|
* feature's implementation. */
|
|
@@ -170,7 +189,7 @@ export function ensureRuntimeObjects(options: RuntimeObjectsOptions): RuntimeObj
|
|
|
170
189
|
if (seen.has(dedupeKey)) continue;
|
|
171
190
|
seen.add(dedupeKey);
|
|
172
191
|
extensionObjects.push(
|
|
173
|
-
compileOne(sourcePath, `feature_${feature.name}_${basename(sourcePath, ".c")}
|
|
192
|
+
compileOne(sourcePath, `feature_${feature.name}_${basename(sourcePath, ".c")}`, featureInclude),
|
|
174
193
|
);
|
|
175
194
|
}
|
|
176
195
|
featureObjects.push(...feature.nativeObjects);
|
package/src/driver/toolchain.ts
CHANGED
|
@@ -495,13 +495,22 @@ export function compileC(
|
|
|
495
495
|
clang: string,
|
|
496
496
|
sourcePath: string,
|
|
497
497
|
objectPath: string,
|
|
498
|
-
includeDir: string,
|
|
498
|
+
includeDir: string | readonly string[],
|
|
499
499
|
env?: Record<string, string>,
|
|
500
500
|
extraFlags: readonly string[] = [],
|
|
501
501
|
): void {
|
|
502
|
+
const includeDirs = typeof includeDir === "string" ? [includeDir] : includeDir;
|
|
502
503
|
const result = runner.run(
|
|
503
504
|
clang,
|
|
504
|
-
[
|
|
505
|
+
[
|
|
506
|
+
...RUNTIME_CFLAGS,
|
|
507
|
+
...extraFlags,
|
|
508
|
+
"-c",
|
|
509
|
+
sourcePath,
|
|
510
|
+
"-o",
|
|
511
|
+
objectPath,
|
|
512
|
+
...includeDirs.map((dir) => `-I${dir}`),
|
|
513
|
+
],
|
|
505
514
|
{ env },
|
|
506
515
|
);
|
|
507
516
|
if (result.status !== 0) throw new ToolchainError(`${clang} ${sourcePath}`, result.status, result.stderr);
|
package/src/driver/version.ts
CHANGED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `http2` link feature: nghttp2-backed `node:http2`.
|
|
3
|
+
*
|
|
4
|
+
* HTTP/2 framing and HPACK come from the vendored nghttp2 archive; TLS (and
|
|
5
|
+
* therefore ALPN) comes from the `tls` feature, and the JavaScript object
|
|
6
|
+
* surface reuses `node-tls`'s server wrapper for `createSecureServer`. The
|
|
7
|
+
* always-linked `http2` module forwards to the dispatch table this feature
|
|
8
|
+
* installs, so a checkout without the archive still compiles and reports a
|
|
9
|
+
* clear runtime error instead of failing to link.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import type { LinkFeature, ProgramUsage } from "../../link-feature.js";
|
|
13
|
+
import { resolveFrom } from "../module.js";
|
|
14
|
+
import { requireRuntimeLibrary } from "../../tls.js";
|
|
15
|
+
|
|
16
|
+
/** True when the bundled program imports `http2` or uses its server API. */
|
|
17
|
+
export function mentionsHttp2(usage: ProgramUsage): boolean {
|
|
18
|
+
return (
|
|
19
|
+
usage.strings.includes("http2") ||
|
|
20
|
+
usage.strings.includes("node:http2") ||
|
|
21
|
+
usage.identifiers.has("createSecureServer") ||
|
|
22
|
+
usage.identifiers.has("Http2Session")
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const http2Feature: LinkFeature = {
|
|
27
|
+
name: "http2",
|
|
28
|
+
description: "node:http2 client and server using nghttp2 over TLS or cleartext",
|
|
29
|
+
requires: ["tls", "node-tls"],
|
|
30
|
+
runtimeSources: () => [resolveFrom(import.meta.url, "../../../../runtime/ext_node/http2/http2_bridge.c")],
|
|
31
|
+
nativeObjects: () => [requireRuntimeLibrary("nghttp2", "npm run tls")],
|
|
32
|
+
used: mentionsHttp2,
|
|
33
|
+
};
|