xbintsc 0.2.8 → 0.3.1
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/README.md +17 -2
- package/README.zh-CN.md +16 -2
- package/bin/xbintsc.js +49 -10
- package/dist/src/ast/expressions.d.ts +2 -0
- package/dist/src/binder/binder.d.ts +24 -98
- package/dist/src/binder/binder.js +13 -559
- package/dist/src/binder/binder.js.map +1 -1
- package/dist/src/binder/declarations.d.ts +16 -0
- package/dist/src/binder/declarations.js +168 -0
- package/dist/src/binder/declarations.js.map +1 -0
- package/dist/src/binder/helpers.d.ts +11 -0
- package/dist/src/binder/helpers.js +46 -0
- package/dist/src/binder/helpers.js.map +1 -0
- package/dist/src/binder/references.d.ts +21 -0
- package/dist/src/binder/references.js +349 -0
- package/dist/src/binder/references.js.map +1 -0
- package/dist/src/binder/types.d.ts +114 -0
- package/dist/src/binder/types.js +27 -0
- package/dist/src/binder/types.js.map +1 -0
- package/dist/src/cli/main.d.ts +1 -0
- package/dist/src/cli/main.js +40 -0
- package/dist/src/cli/main.js.map +1 -1
- package/dist/src/codegen/generator/calls/access.d.ts +13 -0
- package/dist/src/codegen/generator/calls/access.js +115 -0
- package/dist/src/codegen/generator/calls/access.js.map +1 -0
- package/dist/src/codegen/generator/calls/closures.d.ts +11 -0
- package/dist/src/codegen/generator/calls/closures.js +50 -0
- package/dist/src/codegen/generator/calls/closures.js.map +1 -0
- package/dist/src/codegen/generator/calls/invocation.d.ts +18 -0
- package/dist/src/codegen/generator/calls/invocation.js +242 -0
- package/dist/src/codegen/generator/calls/invocation.js.map +1 -0
- package/dist/src/codegen/generator/calls/literals.d.ts +10 -0
- package/dist/src/codegen/generator/calls/literals.js +69 -0
- package/dist/src/codegen/generator/calls/literals.js.map +1 -0
- package/dist/src/codegen/generator/calls/super.d.ts +10 -0
- package/dist/src/codegen/generator/calls/super.js +47 -0
- package/dist/src/codegen/generator/calls/super.js.map +1 -0
- package/dist/src/codegen/generator/calls.d.ts +15 -24
- package/dist/src/codegen/generator/calls.js +15 -482
- package/dist/src/codegen/generator/calls.js.map +1 -1
- package/dist/src/codegen/generator/context.d.ts +1 -1
- package/dist/src/codegen/generator/context.js +2 -2
- package/dist/src/codegen/generator/context.js.map +1 -1
- package/dist/src/codegen/generator/expressions/assignment.d.ts +13 -0
- package/dist/src/codegen/generator/expressions/assignment.js +203 -0
- package/dist/src/codegen/generator/expressions/assignment.js.map +1 -0
- package/dist/src/codegen/generator/expressions/operators.d.ts +14 -0
- package/dist/src/codegen/generator/expressions/operators.js +163 -0
- package/dist/src/codegen/generator/expressions/operators.js.map +1 -0
- package/dist/src/codegen/generator/expressions/primary.d.ts +17 -0
- package/dist/src/codegen/generator/expressions/primary.js +260 -0
- package/dist/src/codegen/generator/expressions/primary.js.map +1 -0
- package/dist/src/codegen/generator/expressions.d.ts +11 -21
- package/dist/src/codegen/generator/expressions.js +11 -494
- package/dist/src/codegen/generator/expressions.js.map +1 -1
- package/dist/src/codegen/generator/module.js +16 -4
- package/dist/src/codegen/generator/module.js.map +1 -1
- package/dist/src/codegen/generator/state.js +8 -0
- package/dist/src/codegen/generator/state.js.map +1 -1
- package/dist/src/codegen/generator/statements/control-flow.d.ts +14 -0
- package/dist/src/codegen/generator/statements/control-flow.js +199 -0
- package/dist/src/codegen/generator/statements/control-flow.js.map +1 -0
- package/dist/src/codegen/generator/statements/dispatch.d.ts +12 -0
- package/dist/src/codegen/generator/statements/dispatch.js +100 -0
- package/dist/src/codegen/generator/statements/dispatch.js.map +1 -0
- package/dist/src/codegen/generator/statements/loops.d.ts +13 -0
- package/dist/src/codegen/generator/statements/loops.js +152 -0
- package/dist/src/codegen/generator/statements/loops.js.map +1 -0
- package/dist/src/codegen/generator/statements/variables.d.ts +13 -0
- package/dist/src/codegen/generator/statements/variables.js +146 -0
- package/dist/src/codegen/generator/statements/variables.js.map +1 -0
- package/dist/src/codegen/generator/statements.d.ts +13 -21
- package/dist/src/codegen/generator/statements.js +13 -568
- package/dist/src/codegen/generator/statements.js.map +1 -1
- package/dist/src/codegen/generator/tables.js +7 -0
- package/dist/src/codegen/generator/tables.js.map +1 -1
- package/dist/src/codegen/values.d.ts +17 -17
- package/dist/src/codegen/values.js +21 -57
- package/dist/src/codegen/values.js.map +1 -1
- package/dist/src/diagnostics/diagnostic.d.ts +1 -0
- package/dist/src/diagnostics/diagnostic.js +1 -0
- package/dist/src/diagnostics/diagnostic.js.map +1 -1
- package/dist/src/diagnostics/source.d.ts +1 -1
- package/dist/src/diagnostics/source.js +7 -12
- package/dist/src/diagnostics/source.js.map +1 -1
- package/dist/src/driver/compiler.d.ts +4 -0
- package/dist/src/driver/compiler.js +51 -16
- package/dist/src/driver/compiler.js.map +1 -1
- package/dist/src/driver/index.d.ts +5 -2
- package/dist/src/driver/index.js +5 -2
- package/dist/src/driver/index.js.map +1 -1
- package/dist/src/driver/paths.d.ts +20 -0
- package/dist/src/driver/paths.js +49 -0
- package/dist/src/driver/paths.js.map +1 -1
- package/dist/src/driver/runtime-lib.d.ts +18 -0
- package/dist/src/driver/runtime-lib.js +31 -0
- package/dist/src/driver/runtime-lib.js.map +1 -0
- package/dist/src/driver/toolchain-download.d.ts +50 -0
- package/dist/src/driver/toolchain-download.js +76 -0
- package/dist/src/driver/toolchain-download.js.map +1 -0
- package/dist/src/driver/toolchain-provider.d.ts +33 -0
- package/dist/src/driver/toolchain-provider.js +71 -0
- package/dist/src/driver/toolchain-provider.js.map +1 -0
- package/dist/src/driver/toolchain.d.ts +9 -4
- package/dist/src/driver/toolchain.js +6 -10
- package/dist/src/driver/toolchain.js.map +1 -1
- package/dist/src/extensions/node/child_process/index.d.ts +4 -2
- package/dist/src/extensions/node/child_process/index.js +4 -2
- package/dist/src/extensions/node/child_process/index.js.map +1 -1
- package/dist/src/extensions/node/events/index.d.ts +10 -0
- package/dist/src/extensions/node/events/index.js +22 -0
- package/dist/src/extensions/node/events/index.js.map +1 -0
- package/dist/src/extensions/node/index.js +6 -0
- package/dist/src/extensions/node/index.js.map +1 -1
- package/dist/src/extensions/node/querystring/index.d.ts +10 -0
- package/dist/src/extensions/node/querystring/index.js +25 -0
- package/dist/src/extensions/node/querystring/index.js.map +1 -0
- package/dist/src/extensions/node/util/index.d.ts +11 -0
- package/dist/src/extensions/node/util/index.js +41 -0
- package/dist/src/extensions/node/util/index.js.map +1 -0
- package/dist/src/extensions/registry.d.ts +6 -0
- package/dist/src/extensions/registry.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/lexer/scanner/identifiers.d.ts +9 -0
- package/dist/src/lexer/scanner/identifiers.js +33 -0
- package/dist/src/lexer/scanner/identifiers.js.map +1 -0
- package/dist/src/lexer/scanner/numbers.d.ts +10 -0
- package/dist/src/lexer/scanner/numbers.js +89 -0
- package/dist/src/lexer/scanner/numbers.js.map +1 -0
- package/dist/src/lexer/scanner/punctuation.d.ts +9 -0
- package/dist/src/lexer/scanner/punctuation.js +151 -0
- package/dist/src/lexer/scanner/punctuation.js.map +1 -0
- package/dist/src/lexer/scanner/regex.d.ts +11 -0
- package/dist/src/lexer/scanner/regex.js +69 -0
- package/dist/src/lexer/scanner/regex.js.map +1 -0
- package/dist/src/lexer/scanner/strings.d.ts +13 -0
- package/dist/src/lexer/scanner/strings.js +118 -0
- package/dist/src/lexer/scanner/strings.js.map +1 -0
- package/dist/src/lexer/scanner.d.ts +20 -27
- package/dist/src/lexer/scanner.js +11 -415
- package/dist/src/lexer/scanner.js.map +1 -1
- package/dist/src/parser/declarations/classes.d.ts +14 -0
- package/dist/src/parser/declarations/classes.js +191 -0
- package/dist/src/parser/declarations/classes.js.map +1 -0
- package/dist/src/parser/declarations/functions.d.ts +17 -0
- package/dist/src/parser/declarations/functions.js +241 -0
- package/dist/src/parser/declarations/functions.js.map +1 -0
- package/dist/src/parser/declarations/type-members.d.ts +16 -0
- package/dist/src/parser/declarations/type-members.js +156 -0
- package/dist/src/parser/declarations/type-members.js.map +1 -0
- package/dist/src/parser/declarations.d.ts +13 -24
- package/dist/src/parser/declarations.js +13 -571
- package/dist/src/parser/declarations.js.map +1 -1
- package/dist/src/parser/helpers.js +13 -4
- package/dist/src/parser/helpers.js.map +1 -1
- package/dist/src/parser/literals.js +10 -1
- package/dist/src/parser/literals.js.map +1 -1
- package/dist/tests/codegen/llvm.test.js +24 -0
- package/dist/tests/codegen/llvm.test.js.map +1 -1
- package/dist/tests/driver/compiler.test.js +3 -0
- package/dist/tests/driver/compiler.test.js.map +1 -1
- package/dist/tests/driver/paths.test.d.ts +1 -0
- package/dist/tests/driver/paths.test.js +26 -0
- package/dist/tests/driver/paths.test.js.map +1 -0
- package/dist/tests/driver/toolchain-download.test.d.ts +1 -0
- package/dist/tests/driver/toolchain-download.test.js +38 -0
- package/dist/tests/driver/toolchain-download.test.js.map +1 -0
- package/dist/tests/driver/toolchain-provider.test.d.ts +1 -0
- package/dist/tests/driver/toolchain-provider.test.js +37 -0
- package/dist/tests/driver/toolchain-provider.test.js.map +1 -0
- package/dist/tests/e2e/compile-node.test.d.ts +7 -0
- package/dist/tests/e2e/compile-node.test.js +123 -0
- package/dist/tests/e2e/compile-node.test.js.map +1 -0
- package/dist/tests/e2e/compile.test.d.ts +4 -1
- package/dist/tests/e2e/compile.test.js +90 -130
- package/dist/tests/e2e/compile.test.js.map +1 -1
- package/dist/tests/e2e/harness.d.ts +36 -0
- package/dist/tests/e2e/harness.js +64 -0
- package/dist/tests/e2e/harness.js.map +1 -0
- package/dist/tests/e2e/node-modules.test.js +60 -0
- package/dist/tests/e2e/node-modules.test.js.map +1 -1
- package/dist/tests/extensions/registry.test.js +4 -0
- package/dist/tests/extensions/registry.test.js.map +1 -1
- package/package.json +5 -3
- package/runtime/ext_node/buffer/buffer.c +12 -552
- package/runtime/ext_node/buffer/parts/byte-access.inc +35 -0
- package/runtime/ext_node/buffer/parts/construction.inc +60 -0
- package/runtime/ext_node/buffer/parts/integer-io.inc +119 -0
- package/runtime/ext_node/buffer/parts/methods.inc +135 -0
- package/runtime/ext_node/buffer/parts/prototype.inc +54 -0
- package/runtime/ext_node/buffer/parts/search.inc +86 -0
- package/runtime/ext_node/buffer/parts/static-api.inc +58 -0
- package/runtime/ext_node/child_process/child_process.c +37 -3
- package/runtime/ext_node/events/events.c +285 -0
- package/runtime/ext_node/http/http.c +11 -736
- package/runtime/ext_node/http/parts/client.inc +290 -0
- package/runtime/ext_node/http/parts/helpers.inc +45 -0
- package/runtime/ext_node/http/parts/prototypes.inc +57 -0
- package/runtime/ext_node/http/parts/response.inc +149 -0
- package/runtime/ext_node/http/parts/server.inc +133 -0
- package/runtime/ext_node/http/parts/string-builder.inc +58 -0
- package/runtime/ext_node/net/net.c +12 -504
- package/runtime/ext_node/net/parts/construction.inc +22 -0
- package/runtime/ext_node/net/parts/platform.inc +60 -0
- package/runtime/ext_node/net/parts/prototypes.inc +35 -0
- package/runtime/ext_node/net/parts/read-loop.inc +58 -0
- package/runtime/ext_node/net/parts/server.inc +131 -0
- package/runtime/ext_node/net/parts/socket-methods.inc +100 -0
- package/runtime/ext_node/net/parts/static-api.inc +93 -0
- package/runtime/ext_node/querystring/querystring.c +251 -0
- package/runtime/ext_node/util/util.c +456 -0
- package/runtime/rt.h +8 -2
- package/runtime/rt_internal.h +34 -0
- package/runtime/xt_bigint/arithmetic.inc +135 -0
- package/runtime/xt_bigint/bits.inc +98 -0
- package/runtime/xt_bigint/bitwise.inc +103 -0
- package/runtime/xt_bigint/compare.inc +30 -0
- package/runtime/xt_bigint/conversions.inc +51 -0
- package/runtime/xt_bigint/division.inc +85 -0
- package/runtime/xt_bigint/format.inc +145 -0
- package/runtime/xt_bigint/helpers.inc +92 -0
- package/runtime/xt_bigint/magnitude.inc +88 -0
- package/runtime/xt_bigint/public.inc +59 -0
- package/runtime/xt_bigint/small-arithmetic.inc +58 -0
- package/runtime/xt_bigint.c +42 -0
- package/runtime/xt_builtins.c +40 -5
- package/runtime/xt_io.c +7 -0
- package/runtime/xt_stdlib/arrays.inc +161 -0
- package/runtime/xt_stdlib/dispatch.inc +116 -0
- package/runtime/xt_stdlib/helpers.inc +23 -0
- package/runtime/xt_stdlib/math.inc +72 -0
- package/runtime/xt_stdlib/strings.inc +178 -0
- package/runtime/xt_stdlib.c +10 -549
- package/runtime/xt_stdlib2/array-statics.inc +37 -0
- package/runtime/xt_stdlib2/arrays.inc +189 -0
- package/runtime/xt_stdlib2/container.inc +23 -0
- package/runtime/xt_stdlib2/date.inc +72 -0
- package/runtime/xt_stdlib2/error.inc +22 -0
- package/runtime/xt_stdlib2/helpers.inc +43 -0
- package/runtime/xt_stdlib2/json.inc +213 -0
- package/runtime/xt_stdlib2/map.inc +95 -0
- package/runtime/xt_stdlib2/number-string-statics.inc +73 -0
- package/runtime/xt_stdlib2/numbers.inc +38 -0
- package/runtime/xt_stdlib2/objects.inc +41 -0
- package/runtime/xt_stdlib2/regexp-match.inc +204 -0
- package/runtime/xt_stdlib2/regexp.inc +20 -0
- package/runtime/xt_stdlib2/set.inc +105 -0
- package/runtime/xt_stdlib2/strings.inc +94 -0
- package/runtime/xt_stdlib2.c +19 -1278
- package/runtime/xt_values.c +155 -12
- package/scripts/build-runtime.ts +109 -0
- package/scripts/fetch-toolchain.ts +101 -0
- package/scripts/package-release.ts +192 -0
- package/src/ast/expressions.ts +2 -0
- package/src/binder/binder.ts +40 -725
- package/src/binder/declarations.ts +203 -0
- package/src/binder/helpers.ts +47 -0
- package/src/binder/references.ts +410 -0
- package/src/binder/types.ts +134 -0
- package/src/cli/main.ts +43 -0
- package/src/codegen/generator/calls/access.ts +139 -0
- package/src/codegen/generator/calls/closures.ts +60 -0
- package/src/codegen/generator/calls/invocation.ts +282 -0
- package/src/codegen/generator/calls/literals.ts +77 -0
- package/src/codegen/generator/calls/super.ts +61 -0
- package/src/codegen/generator/calls.ts +30 -552
- package/src/codegen/generator/context.ts +2 -2
- package/src/codegen/generator/expressions/assignment.ts +226 -0
- package/src/codegen/generator/expressions/operators.ts +182 -0
- package/src/codegen/generator/expressions/primary.ts +304 -0
- package/src/codegen/generator/expressions.ts +22 -553
- package/src/codegen/generator/module.ts +14 -4
- package/src/codegen/generator/state.ts +8 -0
- package/src/codegen/generator/statements/control-flow.ts +225 -0
- package/src/codegen/generator/statements/dispatch.ts +122 -0
- package/src/codegen/generator/statements/loops.ts +173 -0
- package/src/codegen/generator/statements/variables.ts +152 -0
- package/src/codegen/generator/statements.ts +26 -612
- package/src/codegen/generator/tables.ts +7 -0
- package/src/codegen/values.ts +22 -57
- package/src/diagnostics/diagnostic.ts +1 -0
- package/src/diagnostics/source.ts +7 -12
- package/src/driver/compiler.ts +61 -18
- package/src/driver/index.ts +17 -2
- package/src/driver/paths.ts +54 -0
- package/src/driver/runtime-lib.ts +32 -0
- package/src/driver/toolchain-download.ts +108 -0
- package/src/driver/toolchain-provider.ts +91 -0
- package/src/driver/toolchain.ts +29 -11
- package/src/extensions/node/child_process/index.ts +4 -2
- package/src/extensions/node/events/index.ts +27 -0
- package/src/extensions/node/index.ts +6 -0
- package/src/extensions/node/querystring/index.ts +29 -0
- package/src/extensions/node/util/index.ts +48 -0
- package/src/extensions/registry.ts +6 -0
- package/src/index.ts +1 -0
- package/src/lexer/scanner/identifiers.ts +37 -0
- package/src/lexer/scanner/numbers.ts +84 -0
- package/src/lexer/scanner/punctuation.ts +132 -0
- package/src/lexer/scanner/regex.ts +79 -0
- package/src/lexer/scanner/strings.ts +128 -0
- package/src/lexer/scanner.ts +35 -401
- package/src/parser/declarations/classes.ts +215 -0
- package/src/parser/declarations/functions.ts +254 -0
- package/src/parser/declarations/type-members.ts +181 -0
- package/src/parser/declarations.ts +32 -609
- package/src/parser/helpers.ts +13 -6
- package/src/parser/literals.ts +10 -1
- package/scripts/build-runtime.mjs +0 -55
package/dist/src/driver/paths.js
CHANGED
|
@@ -8,6 +8,9 @@ export function findRuntimeDir() {
|
|
|
8
8
|
const candidates = [
|
|
9
9
|
resolve(here, "../../runtime"),
|
|
10
10
|
resolve(here, "../../../runtime"),
|
|
11
|
+
// Packaged release layout: `<root>/bin/xbintsc` next to `<root>/runtime`.
|
|
12
|
+
resolve(here, "../runtime"),
|
|
13
|
+
resolve(here, "runtime"),
|
|
11
14
|
resolve(process.cwd(), "runtime"),
|
|
12
15
|
];
|
|
13
16
|
for (const candidate of candidates) {
|
|
@@ -19,4 +22,50 @@ export function findRuntimeDir() {
|
|
|
19
22
|
export function findPackageRoot() {
|
|
20
23
|
return resolve(findRuntimeDir(), "..");
|
|
21
24
|
}
|
|
25
|
+
/** `<package>/vendor` — where a bundled toolchain is assembled (may not exist). */
|
|
26
|
+
export function vendorRootDir() {
|
|
27
|
+
return resolve(findPackageRoot(), "vendor");
|
|
28
|
+
}
|
|
29
|
+
/** Platform-architecture slug, e.g. `darwin-arm64`, `linux-x64`, `win32-x64`. */
|
|
30
|
+
export function platformSlug() {
|
|
31
|
+
return `${process.platform}-${process.arch}`;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Base name (no extension) of a packaged release archive, e.g.
|
|
35
|
+
* `xbintsc-linux-x64`. Matches the top-level directory inside the archive.
|
|
36
|
+
*/
|
|
37
|
+
export function releaseArchiveBase(platform = process.platform, arch = process.arch) {
|
|
38
|
+
return `xbintsc-${platform}-${arch}`;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Extension for a release archive. `.tar.zst` when a `zstd` binary is available
|
|
42
|
+
* (smaller, faster), otherwise the universally supported `.tar.gz`.
|
|
43
|
+
*/
|
|
44
|
+
export function releaseArchiveExtension(useZstd) {
|
|
45
|
+
return useZstd ? ".tar.zst" : ".tar.gz";
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Directory that may hold a toolchain shipped next to the package:
|
|
49
|
+
* `<package>/vendor/<os>-<arch>` (or a generic `vendor/`). Undefined when none
|
|
50
|
+
* is present, in which case the driver falls back to the system PATH.
|
|
51
|
+
*/
|
|
52
|
+
export function findVendorDir() {
|
|
53
|
+
const roots = [];
|
|
54
|
+
try {
|
|
55
|
+
roots.push(findPackageRoot());
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
// `runtime/` may be absent (e.g. a bare `emit` install); vendor is optional.
|
|
59
|
+
}
|
|
60
|
+
roots.push(resolve(here, "../../.."), resolve(here, "../.."), process.cwd());
|
|
61
|
+
for (const root of roots) {
|
|
62
|
+
const specific = join(root, "vendor", platformSlug());
|
|
63
|
+
if (existsSync(specific))
|
|
64
|
+
return specific;
|
|
65
|
+
const generic = join(root, "vendor");
|
|
66
|
+
if (existsSync(generic))
|
|
67
|
+
return generic;
|
|
68
|
+
}
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
22
71
|
//# sourceMappingURL=paths.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../../../src/driver/paths.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAE1D,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,IAAI,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAErD,iEAAiE;AACjE,MAAM,UAAU,cAAc;IAC5B,MAAM,UAAU,GAAG;QACjB,OAAO,CAAC,IAAI,EAAE,eAAe,CAAC;QAC9B,OAAO,CAAC,IAAI,EAAE,kBAAkB,CAAC;QACjC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,SAAS,CAAC;KAClC,CAAC;IACF,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,IAAI,UAAU,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;YAAE,OAAO,SAAS,CAAC;IAC5D,CAAC;IACD,MAAM,IAAI,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ebuilt runtime archives.
|
|
3
|
+
*
|
|
4
|
+
* The C runtime is normally compiled once into a static archive by
|
|
5
|
+
* `npm run runtime`:
|
|
6
|
+
*
|
|
7
|
+
* runtime/lib/<os>-<arch>/core.a (the core `xt_*.c` runtime)
|
|
8
|
+
* runtime/lib/<os>-<arch>/ext_<name>.a (per-extension sources, e.g. ext_node.a)
|
|
9
|
+
*
|
|
10
|
+
* Shipping these lets `build` link without compiling C, and shortens the first
|
|
11
|
+
* build. When an archive is missing the driver transparently falls back to
|
|
12
|
+
* compiling the `.c` sources, so the archives are an optimization, not a hard
|
|
13
|
+
* dependency.
|
|
14
|
+
*/
|
|
15
|
+
/** Directory holding the prebuilt archives for the current host. */
|
|
16
|
+
export declare function runtimeLibDir(): string;
|
|
17
|
+
/** Absolute path to a prebuilt archive (`core`, `ext_node`, …), if present. */
|
|
18
|
+
export declare function findRuntimeLibrary(name: string): string | undefined;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prebuilt runtime archives.
|
|
3
|
+
*
|
|
4
|
+
* The C runtime is normally compiled once into a static archive by
|
|
5
|
+
* `npm run runtime`:
|
|
6
|
+
*
|
|
7
|
+
* runtime/lib/<os>-<arch>/core.a (the core `xt_*.c` runtime)
|
|
8
|
+
* runtime/lib/<os>-<arch>/ext_<name>.a (per-extension sources, e.g. ext_node.a)
|
|
9
|
+
*
|
|
10
|
+
* Shipping these lets `build` link without compiling C, and shortens the first
|
|
11
|
+
* build. When an archive is missing the driver transparently falls back to
|
|
12
|
+
* compiling the `.c` sources, so the archives are an optimization, not a hard
|
|
13
|
+
* dependency.
|
|
14
|
+
*/
|
|
15
|
+
import { existsSync } from "node:fs";
|
|
16
|
+
import { join } from "node:path";
|
|
17
|
+
import { findRuntimeDir, platformSlug } from "./paths.js";
|
|
18
|
+
/** Directory holding the prebuilt archives for the current host. */
|
|
19
|
+
export function runtimeLibDir() {
|
|
20
|
+
return join(findRuntimeDir(), "lib", platformSlug());
|
|
21
|
+
}
|
|
22
|
+
/** Absolute path to a prebuilt archive (`core`, `ext_node`, …), if present. */
|
|
23
|
+
export function findRuntimeLibrary(name) {
|
|
24
|
+
const base = join(runtimeLibDir(), name);
|
|
25
|
+
for (const candidate of [`${base}.a`, `${base}.lib`]) {
|
|
26
|
+
if (existsSync(candidate))
|
|
27
|
+
return candidate;
|
|
28
|
+
}
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=runtime-lib.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-lib.js","sourceRoot":"","sources":["../../../src/driver/runtime-lib.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1D,oEAAoE;AACpE,MAAM,UAAU,aAAa;IAC3B,OAAO,IAAI,CAAC,cAAc,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,CAAC;AACvD,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,kBAAkB,CAAC,IAAY;IAC7C,MAAM,IAAI,GAAG,IAAI,CAAC,aAAa,EAAE,EAAE,IAAI,CAAC,CAAC;IACzC,KAAK,MAAM,SAAS,IAAI,CAAC,GAAG,IAAI,IAAI,EAAE,GAAG,IAAI,MAAM,CAAC,EAAE,CAAC;QACrD,IAAI,UAAU,CAAC,SAAS,CAAC;YAAE,OAAO,SAAS,CAAC;IAC9C,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which toolchain xbintsc bundles for each host.
|
|
3
|
+
*
|
|
4
|
+
* The end goal is that `build` needs no user-installed compiler. Per the
|
|
5
|
+
* recorded decisions (see `doc/requirements.md`):
|
|
6
|
+
*
|
|
7
|
+
* Linux -> the official LLVM release (clang + lld + llvm-ar)
|
|
8
|
+
* Windows -> llvm-mingw (clang + lld + the MinGW-w64 sysroot/CRT/import libs)
|
|
9
|
+
* macOS -> nothing; the Xcode Command Line Tools are the prerequisite
|
|
10
|
+
*
|
|
11
|
+
* This module only maps a host to a pinned download; the actual fetch lives in
|
|
12
|
+
* `scripts/fetch-toolchain.ts`.
|
|
13
|
+
*/
|
|
14
|
+
/** Pinned LLVM release used for the Linux bundle. */
|
|
15
|
+
export declare const LLVM_VERSION = "18.1.8";
|
|
16
|
+
/** Pinned llvm-mingw release used for the Windows bundle. */
|
|
17
|
+
export declare const LLVM_MINGW_VERSION = "20260908";
|
|
18
|
+
export interface ToolchainDownload {
|
|
19
|
+
/** Download URL. */
|
|
20
|
+
readonly url: string;
|
|
21
|
+
/** Suggested local file name for the archive. */
|
|
22
|
+
readonly archive: string;
|
|
23
|
+
/** Archive type. Both are unpacked with `tar` (bsdtar reads zip). */
|
|
24
|
+
readonly kind: "tar.xz" | "zip";
|
|
25
|
+
/** Leading path segments to strip while extracting. */
|
|
26
|
+
readonly stripComponents: number;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The toolchain to bundle for a host, or undefined when the host's own SDK is
|
|
30
|
+
* used instead (macOS: the Xcode Command Line Tools).
|
|
31
|
+
*/
|
|
32
|
+
export declare function toolchainDownload(platform?: string, arch?: string): ToolchainDownload | undefined;
|
|
33
|
+
export interface SupportLibrary {
|
|
34
|
+
/** Candidate download URLs, tried in order. */
|
|
35
|
+
readonly urls: readonly string[];
|
|
36
|
+
/** Local file name for the downloaded `.deb`. */
|
|
37
|
+
readonly archive: string;
|
|
38
|
+
/** Path inside the extracted `.deb` data tree. */
|
|
39
|
+
readonly member: string;
|
|
40
|
+
/** File name placed in `vendor/<os>-<arch>/lib/`. */
|
|
41
|
+
readonly dest: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Extra shared libraries the bundled toolchain needs but that are not part of
|
|
45
|
+
* the OS C library. The official Linux LLVM build links the legacy
|
|
46
|
+
* `libtinfo.so.5` soname, which current distributions no longer ship, so we
|
|
47
|
+
* bundle it (from the Ubuntu `libtinfo5` package) into `vendor/<os>-<arch>/lib`
|
|
48
|
+
* and point `LD_LIBRARY_PATH` at that directory.
|
|
49
|
+
*/
|
|
50
|
+
export declare function toolchainSupportLibraries(platform?: string, arch?: string): readonly SupportLibrary[];
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which toolchain xbintsc bundles for each host.
|
|
3
|
+
*
|
|
4
|
+
* The end goal is that `build` needs no user-installed compiler. Per the
|
|
5
|
+
* recorded decisions (see `doc/requirements.md`):
|
|
6
|
+
*
|
|
7
|
+
* Linux -> the official LLVM release (clang + lld + llvm-ar)
|
|
8
|
+
* Windows -> llvm-mingw (clang + lld + the MinGW-w64 sysroot/CRT/import libs)
|
|
9
|
+
* macOS -> nothing; the Xcode Command Line Tools are the prerequisite
|
|
10
|
+
*
|
|
11
|
+
* This module only maps a host to a pinned download; the actual fetch lives in
|
|
12
|
+
* `scripts/fetch-toolchain.ts`.
|
|
13
|
+
*/
|
|
14
|
+
/** Pinned LLVM release used for the Linux bundle. */
|
|
15
|
+
export const LLVM_VERSION = "18.1.8";
|
|
16
|
+
/** Pinned llvm-mingw release used for the Windows bundle. */
|
|
17
|
+
export const LLVM_MINGW_VERSION = "20260908";
|
|
18
|
+
/**
|
|
19
|
+
* The toolchain to bundle for a host, or undefined when the host's own SDK is
|
|
20
|
+
* used instead (macOS: the Xcode Command Line Tools).
|
|
21
|
+
*/
|
|
22
|
+
export function toolchainDownload(platform = process.platform, arch = process.arch) {
|
|
23
|
+
if (platform === "linux") {
|
|
24
|
+
if (arch === "x64") {
|
|
25
|
+
return {
|
|
26
|
+
url: `https://github.com/llvm/llvm-project/releases/download/llvmorg-${LLVM_VERSION}/clang+llvm-${LLVM_VERSION}-x86_64-linux-gnu-ubuntu-18.04.tar.xz`,
|
|
27
|
+
archive: `clang+llvm-${LLVM_VERSION}-x86_64-linux-gnu.tar.xz`,
|
|
28
|
+
kind: "tar.xz",
|
|
29
|
+
stripComponents: 1,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
if (arch === "arm64") {
|
|
33
|
+
return {
|
|
34
|
+
url: `https://github.com/llvm/llvm-project/releases/download/llvmorg-${LLVM_VERSION}/clang+llvm-${LLVM_VERSION}-aarch64-linux-gnu.tar.xz`,
|
|
35
|
+
archive: `clang+llvm-${LLVM_VERSION}-aarch64-linux-gnu.tar.xz`,
|
|
36
|
+
kind: "tar.xz",
|
|
37
|
+
stripComponents: 1,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
if (platform === "win32" && arch === "x64") {
|
|
43
|
+
return {
|
|
44
|
+
url: `https://github.com/mstorsjo/llvm-mingw/releases/download/${LLVM_MINGW_VERSION}/llvm-mingw-${LLVM_MINGW_VERSION}-ucrt-x86_64.zip`,
|
|
45
|
+
archive: `llvm-mingw-${LLVM_MINGW_VERSION}-ucrt-x86_64.zip`,
|
|
46
|
+
kind: "zip",
|
|
47
|
+
stripComponents: 1,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
// macOS (and any other host) uses the system SDK; nothing to bundle.
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Extra shared libraries the bundled toolchain needs but that are not part of
|
|
55
|
+
* the OS C library. The official Linux LLVM build links the legacy
|
|
56
|
+
* `libtinfo.so.5` soname, which current distributions no longer ship, so we
|
|
57
|
+
* bundle it (from the Ubuntu `libtinfo5` package) into `vendor/<os>-<arch>/lib`
|
|
58
|
+
* and point `LD_LIBRARY_PATH` at that directory.
|
|
59
|
+
*/
|
|
60
|
+
export function toolchainSupportLibraries(platform = process.platform, arch = process.arch) {
|
|
61
|
+
if (platform === "linux" && arch === "x64") {
|
|
62
|
+
return [
|
|
63
|
+
{
|
|
64
|
+
urls: [
|
|
65
|
+
"https://security.ubuntu.com/ubuntu/pool/main/n/ncurses/libtinfo5_6.1-1ubuntu1.18.04.1_amd64.deb",
|
|
66
|
+
"https://archive.ubuntu.com/ubuntu/pool/main/n/ncurses/libtinfo5_6.1-1ubuntu1.18.04.1_amd64.deb",
|
|
67
|
+
],
|
|
68
|
+
archive: "libtinfo5.deb",
|
|
69
|
+
member: "lib/x86_64-linux-gnu/libtinfo.so.5.9",
|
|
70
|
+
dest: "libtinfo.so.5",
|
|
71
|
+
},
|
|
72
|
+
];
|
|
73
|
+
}
|
|
74
|
+
return [];
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=toolchain-download.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolchain-download.js","sourceRoot":"","sources":["../../../src/driver/toolchain-download.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,qDAAqD;AACrD,MAAM,CAAC,MAAM,YAAY,GAAG,QAAQ,CAAC;AACrC,6DAA6D;AAC7D,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAC;AAa7C;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAC/B,WAAmB,OAAO,CAAC,QAAQ,EACnC,OAAe,OAAO,CAAC,IAAI;IAE3B,IAAI,QAAQ,KAAK,OAAO,EAAE,CAAC;QACzB,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;YACnB,OAAO;gBACL,GAAG,EAAE,kEAAkE,YAAY,eAAe,YAAY,uCAAuC;gBACrJ,OAAO,EAAE,cAAc,YAAY,0BAA0B;gBAC7D,IAAI,EAAE,QAAQ;gBACd,eAAe,EAAE,CAAC;aACnB,CAAC;QACJ,CAAC;QACD,IAAI,IAAI,KAAK,OAAO,EAAE,CAAC;YACrB,OAAO;gBACL,GAAG,EAAE,kEAAkE,YAAY,eAAe,YAAY,2BAA2B;gBACzI,OAAO,EAAE,cAAc,YAAY,2BAA2B;gBAC9D,IAAI,EAAE,QAAQ;gBACd,eAAe,EAAE,CAAC;aACnB,CAAC;QACJ,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,IAAI,QAAQ,KAAK,OAAO,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;QAC3C,OAAO;YACL,GAAG,EAAE,4DAA4D,kBAAkB,eAAe,kBAAkB,kBAAkB;YACtI,OAAO,EAAE,cAAc,kBAAkB,kBAAkB;YAC3D,IAAI,EAAE,KAAK;YACX,eAAe,EAAE,CAAC;SACnB,CAAC;IACJ,CAAC;IAED,qEAAqE;IACrE,OAAO,SAAS,CAAC;AACnB,CAAC;AAaD;;;;;;GAMG;AACH,MAAM,UAAU,yBAAyB,CACvC,WAAmB,OAAO,CAAC,QAAQ,EACnC,OAAe,OAAO,CAAC,IAAI;IAE3B,IAAI,QAAQ,KAAK,OAAO,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;QAC3C,OAAO;YACL;gBACE,IAAI,EAAE;oBACJ,iGAAiG;oBACjG,gGAAgG;iBACjG;gBACD,OAAO,EAAE,eAAe;gBACxB,MAAM,EAAE,sCAAsC;gBAC9C,IAAI,EAAE,eAAe;aACtB;SACF,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Toolchain selection.
|
|
3
|
+
*
|
|
4
|
+
* xbintsc shells out to a clang-compatible driver for three jobs: lowering LLVM
|
|
5
|
+
* IR to an object, compiling the C runtime, and linking. This module decides
|
|
6
|
+
* *which* driver to use, in a fixed priority order, so a bundled toolchain can
|
|
7
|
+
* shadow the system one without touching the driver code:
|
|
8
|
+
*
|
|
9
|
+
* 1. an explicit `xbintsc_CLANG` / `xbintsc_TOOLCHAIN`
|
|
10
|
+
* 2. a toolchain shipped next to the package (`vendor/<os>-<arch>/bin`)
|
|
11
|
+
* 3. the system `PATH` (`findClang`)
|
|
12
|
+
*
|
|
13
|
+
* Extra linker arguments (for example `-fuse-ld=lld`) can be supplied through
|
|
14
|
+
* `xbintsc_LINKER_ARGS`.
|
|
15
|
+
*/
|
|
16
|
+
import { type Runner } from "./toolchain.js";
|
|
17
|
+
export type ToolchainSource = "env" | "vendor" | "system";
|
|
18
|
+
export interface ResolvedToolchain {
|
|
19
|
+
/** Path or name of the clang-compatible driver to invoke. */
|
|
20
|
+
readonly clang: string;
|
|
21
|
+
/** Where the driver came from. */
|
|
22
|
+
readonly source: ToolchainSource;
|
|
23
|
+
/** Extra arguments to pass to the link step. */
|
|
24
|
+
readonly linkerArgs: readonly string[];
|
|
25
|
+
/**
|
|
26
|
+
* Extra environment for the toolchain subprocesses, merged over the current
|
|
27
|
+
* environment. Used to point `LD_LIBRARY_PATH` at bundled shared libraries
|
|
28
|
+
* (for example the legacy `libtinfo.so.5` the official Linux build needs).
|
|
29
|
+
*/
|
|
30
|
+
readonly env: Record<string, string>;
|
|
31
|
+
}
|
|
32
|
+
/** Resolve the toolchain that `build` should use. See the module docblock. */
|
|
33
|
+
export declare function resolveToolchain(runner?: Runner): ResolvedToolchain;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Toolchain selection.
|
|
3
|
+
*
|
|
4
|
+
* xbintsc shells out to a clang-compatible driver for three jobs: lowering LLVM
|
|
5
|
+
* IR to an object, compiling the C runtime, and linking. This module decides
|
|
6
|
+
* *which* driver to use, in a fixed priority order, so a bundled toolchain can
|
|
7
|
+
* shadow the system one without touching the driver code:
|
|
8
|
+
*
|
|
9
|
+
* 1. an explicit `xbintsc_CLANG` / `xbintsc_TOOLCHAIN`
|
|
10
|
+
* 2. a toolchain shipped next to the package (`vendor/<os>-<arch>/bin`)
|
|
11
|
+
* 3. the system `PATH` (`findClang`)
|
|
12
|
+
*
|
|
13
|
+
* Extra linker arguments (for example `-fuse-ld=lld`) can be supplied through
|
|
14
|
+
* `xbintsc_LINKER_ARGS`.
|
|
15
|
+
*/
|
|
16
|
+
import { existsSync } from "node:fs";
|
|
17
|
+
import { join } from "node:path";
|
|
18
|
+
import { findVendorDir } from "./paths.js";
|
|
19
|
+
import { findClang, realRunner } from "./toolchain.js";
|
|
20
|
+
function works(runner, command, env) {
|
|
21
|
+
try {
|
|
22
|
+
return runner.run(command, ["--version"], env ? { env } : undefined).status === 0;
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function linkerArgs(fallback) {
|
|
29
|
+
const raw = process.env.xbintsc_LINKER_ARGS;
|
|
30
|
+
if (raw)
|
|
31
|
+
return raw.split(" ").filter((part) => part.length > 0);
|
|
32
|
+
return [...fallback];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Environment overrides for a bundled toolchain. The official Linux build links
|
|
36
|
+
* the removed `libtinfo.so.5` soname, so when we ship it under `vendor/lib/` we
|
|
37
|
+
* prepend that directory to the dynamic linker search path.
|
|
38
|
+
*/
|
|
39
|
+
function vendorEnv(vendor) {
|
|
40
|
+
const libDir = join(vendor, "lib");
|
|
41
|
+
if (process.platform !== "linux" || !existsSync(libDir))
|
|
42
|
+
return {};
|
|
43
|
+
const existing = process.env.LD_LIBRARY_PATH;
|
|
44
|
+
return { LD_LIBRARY_PATH: existing ? libDir + ":" + existing : libDir };
|
|
45
|
+
}
|
|
46
|
+
/** Resolve the toolchain that `build` should use. See the module docblock. */
|
|
47
|
+
export function resolveToolchain(runner = realRunner) {
|
|
48
|
+
const explicit = process.env.xbintsc_CLANG ?? process.env.xbintsc_TOOLCHAIN;
|
|
49
|
+
if (explicit && works(runner, explicit)) {
|
|
50
|
+
return { clang: explicit, source: "env", linkerArgs: linkerArgs([]), env: {} };
|
|
51
|
+
}
|
|
52
|
+
const vendor = findVendorDir();
|
|
53
|
+
if (vendor) {
|
|
54
|
+
const env = vendorEnv(vendor);
|
|
55
|
+
const names = process.platform === "win32" ? ["clang.exe", "clang"] : ["clang"];
|
|
56
|
+
for (const name of names) {
|
|
57
|
+
const candidate = join(vendor, "bin", name);
|
|
58
|
+
if (existsSync(candidate) && works(runner, candidate, env)) {
|
|
59
|
+
// A bundled toolchain ships `ld.lld`, so prefer lld over any system linker.
|
|
60
|
+
return {
|
|
61
|
+
clang: candidate,
|
|
62
|
+
source: "vendor",
|
|
63
|
+
linkerArgs: linkerArgs(["-fuse-ld=lld"]),
|
|
64
|
+
env,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return { clang: findClang(runner), source: "system", linkerArgs: linkerArgs([]), env: {} };
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=toolchain-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolchain-provider.js","sourceRoot":"","sources":["../../../src/driver/toolchain-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,UAAU,EAAe,MAAM,gBAAgB,CAAC;AAmBpE,SAAS,KAAK,CAAC,MAAc,EAAE,OAAe,EAAE,GAA4B;IAC1E,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,WAAW,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;IACpF,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,SAAS,UAAU,CAAC,QAA2B;IAC7C,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC;IAC5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,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QAChF,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;YAC5C,IAAI,UAAU,CAAC,SAAS,CAAC,IAAI,KAAK,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,CAAC,EAAE,CAAC;gBAC3D,4EAA4E;gBAC5E,OAAO;oBACL,KAAK,EAAE,SAAS;oBAChB,MAAM,EAAE,QAAQ;oBAChB,UAAU,EAAE,UAAU,CAAC,CAAC,cAAc,CAAC,CAAC;oBACxC,GAAG;iBACJ,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC;AAC7F,CAAC"}
|
|
@@ -9,10 +9,13 @@ export interface CommandResult {
|
|
|
9
9
|
readonly stdout: string;
|
|
10
10
|
readonly stderr: string;
|
|
11
11
|
}
|
|
12
|
+
export interface RunOptions {
|
|
13
|
+
readonly cwd?: string;
|
|
14
|
+
/** Extra environment variables, merged over `process.env`. */
|
|
15
|
+
readonly env?: Record<string, string>;
|
|
16
|
+
}
|
|
12
17
|
export interface Runner {
|
|
13
|
-
run(command: string, args: readonly string[], options?:
|
|
14
|
-
cwd?: string;
|
|
15
|
-
}): CommandResult;
|
|
18
|
+
run(command: string, args: readonly string[], options?: RunOptions): CommandResult;
|
|
16
19
|
}
|
|
17
20
|
export declare const realRunner: Runner;
|
|
18
21
|
export declare class ToolchainError extends Error {
|
|
@@ -28,6 +31,7 @@ export interface CompileIrOptions {
|
|
|
28
31
|
readonly irPath: string;
|
|
29
32
|
readonly objectPath: string;
|
|
30
33
|
readonly optimize: string;
|
|
34
|
+
readonly env?: Record<string, string>;
|
|
31
35
|
}
|
|
32
36
|
/** Compile an LLVM IR file to a native object file. */
|
|
33
37
|
export declare function compileIr(runner: Runner, options: CompileIrOptions): void;
|
|
@@ -37,7 +41,8 @@ export interface LinkOptions {
|
|
|
37
41
|
readonly outputPath: string;
|
|
38
42
|
readonly linkerFlags: readonly string[];
|
|
39
43
|
readonly optimize: string;
|
|
44
|
+
readonly env?: Record<string, string>;
|
|
40
45
|
}
|
|
41
46
|
export declare function link(runner: Runner, options: LinkOptions): void;
|
|
42
47
|
/** Compile a C source to an object file (used for the runtime and extensions). */
|
|
43
|
-
export declare function compileC(runner: Runner, clang: string, sourcePath: string, objectPath: string, includeDir: string): void;
|
|
48
|
+
export declare function compileC(runner: Runner, clang: string, sourcePath: string, objectPath: string, includeDir: string, env?: Record<string, string>): void;
|
|
@@ -12,6 +12,8 @@ export const realRunner = {
|
|
|
12
12
|
encoding: "utf8",
|
|
13
13
|
maxBuffer: 64 * 1024 * 1024,
|
|
14
14
|
};
|
|
15
|
+
if (options.env)
|
|
16
|
+
spawnOptions.env = Object.assign({}, process.env, options.env);
|
|
15
17
|
const result = spawnSync(command, [...args], spawnOptions);
|
|
16
18
|
return {
|
|
17
19
|
status: result.status ?? (result.error ? 1 : 0),
|
|
@@ -51,25 +53,19 @@ export function findClang(runner = realRunner) {
|
|
|
51
53
|
}
|
|
52
54
|
/** Compile an LLVM IR file to a native object file. */
|
|
53
55
|
export function compileIr(runner, options) {
|
|
54
|
-
const result = runner.run(options.clang, [
|
|
55
|
-
`-O${options.optimize}`,
|
|
56
|
-
"-c",
|
|
57
|
-
options.irPath,
|
|
58
|
-
"-o",
|
|
59
|
-
options.objectPath,
|
|
60
|
-
]);
|
|
56
|
+
const result = runner.run(options.clang, [`-O${options.optimize}`, "-c", options.irPath, "-o", options.objectPath], { env: options.env });
|
|
61
57
|
if (result.status !== 0)
|
|
62
58
|
throw new ToolchainError(`${options.clang} ${options.irPath}`, result.status, result.stderr);
|
|
63
59
|
}
|
|
64
60
|
export function link(runner, options) {
|
|
65
61
|
const args = [`-O${options.optimize}`, ...options.objectPaths, "-o", options.outputPath, ...options.linkerFlags];
|
|
66
|
-
const result = runner.run(options.clang, args);
|
|
62
|
+
const result = runner.run(options.clang, args, { env: options.env });
|
|
67
63
|
if (result.status !== 0)
|
|
68
64
|
throw new ToolchainError(`${options.clang} link`, result.status, result.stderr);
|
|
69
65
|
}
|
|
70
66
|
/** Compile a C source to an object file (used for the runtime and extensions). */
|
|
71
|
-
export function compileC(runner, clang, sourcePath, objectPath, includeDir) {
|
|
72
|
-
const result = runner.run(clang, ["-O2", "-D_CRT_SECURE_NO_WARNINGS", "-c", sourcePath, "-o", objectPath, `-I${includeDir}`]);
|
|
67
|
+
export function compileC(runner, clang, sourcePath, objectPath, includeDir, env) {
|
|
68
|
+
const result = runner.run(clang, ["-O2", "-D_CRT_SECURE_NO_WARNINGS", "-c", sourcePath, "-o", objectPath, `-I${includeDir}`], { env });
|
|
73
69
|
if (result.status !== 0)
|
|
74
70
|
throw new ToolchainError(`${clang} ${sourcePath}`, result.status, result.stderr);
|
|
75
71
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toolchain.js","sourceRoot":"","sources":["../../../src/driver/toolchain.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAyB,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"toolchain.js","sourceRoot":"","sources":["../../../src/driver/toolchain.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAyB,MAAM,oBAAoB,CAAC;AAkBtE,MAAM,CAAC,MAAM,UAAU,GAAW;IAChC,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,GAAG,EAAE;QAC7B,MAAM,YAAY,GAAqB;YACrC,GAAG,EAAE,OAAO,CAAC,GAAG;YAChB,QAAQ,EAAE,MAAM;YAChB,SAAS,EAAE,EAAE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AE,IAAI,EAAE,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IACrE,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,IAAI,cAAc,CAAC,GAAG,OAAO,CAAC,KAAK,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;AAC3G,CAAC;AAED,kFAAkF;AAClF,MAAM,UAAU,QAAQ,CACtB,MAAc,EACd,KAAa,EACb,UAAkB,EAClB,UAAkB,EAClB,UAAkB,EAClB,GAA4B;IAE5B,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CACvB,KAAK,EACL,CAAC,KAAK,EAAE,2BAA2B,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,UAAU,EAAE,CAAC,EAC3F,EAAE,GAAG,EAAE,CACR,CAAC;IACF,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,IAAI,cAAc,CAAC,GAAG,KAAK,IAAI,UAAU,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;AAC5G,CAAC"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Node's `child_process` module: `spawnSync(command, args, options)`, backed by
|
|
3
|
-
* `runtime/ext_node/child_process`. Captures stdout/stderr as UTF-8 strings
|
|
4
|
-
* honours `options.cwd`,
|
|
3
|
+
* `runtime/ext_node/child_process`. Captures stdout/stderr as UTF-8 strings,
|
|
4
|
+
* honours `options.cwd`, and supports `options.stdio: "inherit"` (hand the
|
|
5
|
+
* child the parent's stdout/stderr) — which is all the compiler's toolchain
|
|
6
|
+
* wrapper and `xbintsc run` need.
|
|
5
7
|
*/
|
|
6
8
|
import type { NodeModule } from "../module.js";
|
|
7
9
|
export declare const childProcessModule: NodeModule;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Node's `child_process` module: `spawnSync(command, args, options)`, backed by
|
|
3
|
-
* `runtime/ext_node/child_process`. Captures stdout/stderr as UTF-8 strings
|
|
4
|
-
* honours `options.cwd`,
|
|
3
|
+
* `runtime/ext_node/child_process`. Captures stdout/stderr as UTF-8 strings,
|
|
4
|
+
* honours `options.cwd`, and supports `options.stdio: "inherit"` (hand the
|
|
5
|
+
* child the parent's stdout/stderr) — which is all the compiler's toolchain
|
|
6
|
+
* wrapper and `xbintsc run` need.
|
|
5
7
|
*/
|
|
6
8
|
import { resolveFrom } from "../module.js";
|
|
7
9
|
const builtins = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/extensions/node/child_process/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/extensions/node/child_process/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAG3C,MAAM,QAAQ,GAAoC;IAChD,SAAS,EAAE,EAAE,MAAM,EAAE,6BAA6B,EAAE;CACrD,CAAC;AAEF,MAAM,OAAO,GAAkB;IAC7B,SAAS,EAAE,EAAE,MAAM,EAAE,6BAA6B,EAAE;CACrD,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAe;IAC5C,IAAI,EAAE,eAAe;IACrB,cAAc,EAAE,GAAG,EAAE,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,4DAA4D,CAAC,CAAC;IAClH,QAAQ,EAAE,GAAG,EAAE,CAAC,QAAQ;IACxB,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO;CACvB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node's `events` module.
|
|
3
|
+
*
|
|
4
|
+
* Exposes the standalone `EventEmitter` class plus its statics. `EventEmitter`
|
|
5
|
+
* is provided both as a global constructor and as a named export, so
|
|
6
|
+
* `new EventEmitter()` and `import { EventEmitter } from "events"` both work.
|
|
7
|
+
* The implementation lives in `runtime/ext_node/events/events.c`.
|
|
8
|
+
*/
|
|
9
|
+
import type { NodeModule } from "../module.js";
|
|
10
|
+
export declare const eventsModule: NodeModule;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node's `events` module.
|
|
3
|
+
*
|
|
4
|
+
* Exposes the standalone `EventEmitter` class plus its statics. `EventEmitter`
|
|
5
|
+
* is provided both as a global constructor and as a named export, so
|
|
6
|
+
* `new EventEmitter()` and `import { EventEmitter } from "events"` both work.
|
|
7
|
+
* The implementation lives in `runtime/ext_node/events/events.c`.
|
|
8
|
+
*/
|
|
9
|
+
import { resolveFrom } from "../module.js";
|
|
10
|
+
const methods = ["listenerCount", "getEventListeners", "getMaxListeners", "setMaxListeners", "once"];
|
|
11
|
+
const exports = {
|
|
12
|
+
EventEmitter: { symbol: "xt_event_emitter_ctor", isConstructor: true },
|
|
13
|
+
...Object.fromEntries(methods.map((method) => [method, { namespace: "events", method }])),
|
|
14
|
+
};
|
|
15
|
+
export const eventsModule = {
|
|
16
|
+
name: "events",
|
|
17
|
+
namespace: "events",
|
|
18
|
+
runtimeSources: () => [resolveFrom(import.meta.url, "../../../../runtime/ext_node/events/events.c")],
|
|
19
|
+
builtins: () => ({}),
|
|
20
|
+
exports: () => exports,
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/extensions/node/events/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAG3C,MAAM,OAAO,GAAG,CAAC,eAAe,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,CAAU,CAAC;AAE9G,MAAM,OAAO,GAAkB;IAC7B,YAAY,EAAE,EAAE,MAAM,EAAE,uBAAuB,EAAE,aAAa,EAAE,IAAI,EAAE;IACtE,GAAG,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;CAC1F,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAe;IACtC,IAAI,EAAE,QAAQ;IACd,SAAS,EAAE,QAAQ;IACnB,cAAc,EAAE,GAAG,EAAE,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,8CAA8C,CAAC,CAAC;IACpG,QAAQ,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC;IACpB,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO;CACvB,CAAC"}
|
|
@@ -22,6 +22,9 @@ import { httpModule } from "./http/index.js";
|
|
|
22
22
|
import { urlModule } from "./url/index.js";
|
|
23
23
|
import { cryptoModule } from "./crypto/index.js";
|
|
24
24
|
import { childProcessModule } from "./child_process/index.js";
|
|
25
|
+
import { eventsModule } from "./events/index.js";
|
|
26
|
+
import { utilModule } from "./util/index.js";
|
|
27
|
+
import { querystringModule } from "./querystring/index.js";
|
|
25
28
|
/** Every Node module the extension currently provides. */
|
|
26
29
|
const modules = [
|
|
27
30
|
fsModule,
|
|
@@ -37,6 +40,9 @@ const modules = [
|
|
|
37
40
|
urlModule,
|
|
38
41
|
cryptoModule,
|
|
39
42
|
childProcessModule,
|
|
43
|
+
eventsModule,
|
|
44
|
+
utilModule,
|
|
45
|
+
querystringModule,
|
|
40
46
|
];
|
|
41
47
|
export const nodeExtension = {
|
|
42
48
|
name: "node",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/extensions/node/index.ts"],"names":[],"mappings":"AAAA;;;;;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CAAC,MAAM,CAAC,QAAQ,EAAE;aAC/D,CAAC;YACF,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;YAC7B,OAAO,CAAC,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC,GAAG,KAAK,CAAC;QACzC,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node's `querystring` module.
|
|
3
|
+
*
|
|
4
|
+
* `parse` / `decode` and `stringify` / `encode` are the same functions under
|
|
5
|
+
* two names, alongside `escape` / `unescape`. Both named imports and namespace
|
|
6
|
+
* calls (`import qs from "querystring"`) are supported; the implementation
|
|
7
|
+
* lives in `runtime/ext_node/querystring/querystring.c`.
|
|
8
|
+
*/
|
|
9
|
+
import type { NodeModule } from "../module.js";
|
|
10
|
+
export declare const querystringModule: NodeModule;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node's `querystring` module.
|
|
3
|
+
*
|
|
4
|
+
* `parse` / `decode` and `stringify` / `encode` are the same functions under
|
|
5
|
+
* two names, alongside `escape` / `unescape`. Both named imports and namespace
|
|
6
|
+
* calls (`import qs from "querystring"`) are supported; the implementation
|
|
7
|
+
* lives in `runtime/ext_node/querystring/querystring.c`.
|
|
8
|
+
*/
|
|
9
|
+
import { resolveFrom } from "../module.js";
|
|
10
|
+
const exports = {
|
|
11
|
+
parse: { symbol: "xt_querystring_parse" },
|
|
12
|
+
decode: { symbol: "xt_querystring_parse" },
|
|
13
|
+
stringify: { symbol: "xt_querystring_stringify" },
|
|
14
|
+
encode: { symbol: "xt_querystring_stringify" },
|
|
15
|
+
escape: { symbol: "xt_querystring_escape" },
|
|
16
|
+
unescape: { symbol: "xt_querystring_unescape" },
|
|
17
|
+
};
|
|
18
|
+
export const querystringModule = {
|
|
19
|
+
name: "querystring",
|
|
20
|
+
namespace: "querystring",
|
|
21
|
+
runtimeSources: () => [resolveFrom(import.meta.url, "../../../../runtime/ext_node/querystring/querystring.c")],
|
|
22
|
+
builtins: () => ({}),
|
|
23
|
+
exports: () => exports,
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/extensions/node/querystring/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAG3C,MAAM,OAAO,GAAkB;IAC7B,KAAK,EAAE,EAAE,MAAM,EAAE,sBAAsB,EAAE;IACzC,MAAM,EAAE,EAAE,MAAM,EAAE,sBAAsB,EAAE;IAC1C,SAAS,EAAE,EAAE,MAAM,EAAE,0BAA0B,EAAE;IACjD,MAAM,EAAE,EAAE,MAAM,EAAE,0BAA0B,EAAE;IAC9C,MAAM,EAAE,EAAE,MAAM,EAAE,uBAAuB,EAAE;IAC3C,QAAQ,EAAE,EAAE,MAAM,EAAE,yBAAyB,EAAE;CAChD,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAe;IAC3C,IAAI,EAAE,aAAa;IACnB,SAAS,EAAE,aAAa;IACxB,cAAc,EAAE,GAAG,EAAE,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,wDAAwD,CAAC,CAAC;IAC9G,QAAQ,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC;IACpB,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO;CACvB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node's `util` module.
|
|
3
|
+
*
|
|
4
|
+
* Exposes the commonly used helpers (`format`, `inspect`, `isDeepStrictEqual`,
|
|
5
|
+
* `inherits`, `deprecate`, `promisify`) and the `isX` type predicates. Both
|
|
6
|
+
* `import { format } from "util"` and `import util from "util"` (namespace
|
|
7
|
+
* calls) are supported; the implementation lives in
|
|
8
|
+
* `runtime/ext_node/util/util.c`.
|
|
9
|
+
*/
|
|
10
|
+
import type { NodeModule } from "../module.js";
|
|
11
|
+
export declare const utilModule: NodeModule;
|