Files
scriptc/packages/runtime-pack-common/library-matrix.mjs
Chris Tate c08ab955ae Enforce linting and consistent source formatting
- Enforce oxlint and oxfmt for owned JavaScript and TypeScript with independent CI checks.
- Preserve compiler import boundaries and protected fixtures while cleaning up lint findings.
- Standardize source formatting and validate import, fixture, and embedded-source protections.
2026-10-05 17:51:24 -05:00

44 lines
1.4 KiB
JavaScript

/** Runtime library modes have distinct trap and state ownership contracts. */
export function withLibraryRuntimeFlavors(matrix) {
const omitted = new Set(["scr_async.c", "scr_crypto_async.c", "scr_child.c", "scr_ffi.c"]);
const optional = new Set([
"scr_regex.c",
"scr_assert.c",
"scr_inspect.c",
"scr_console_native.c",
"scr_symbol.c",
"scr_bigint_assert.c",
"scr_url_params.c",
"scr_events_emitter.c",
"scr_dyn_handle.c",
"scr_zlib.c",
"scr_copying.c",
"scr_dyn_invoke.c",
]);
const libraryUnits = [
...matrix.runtime_units.filter(
(unit) => !omitted.has(unit.source) && (unit.predicate === true || optional.has(unit.source)),
),
{
source: "scr_library.c",
predicate: true,
variants: [{ id: "default", when: {}, defines: [] }],
},
].map((unit) => ({
...unit,
variants: unit.variants.filter((variant) => !variant.defines.includes("SCR_DYNAMIC")),
}));
const flavors = { ...matrix.flavors };
for (const [flavor, spec] of Object.entries(matrix.flavors)) {
flavors[`library-${flavor}`] = { ...spec, defines: ["SCR_LIB"], runtime_units: libraryUnits };
if (matrix.target.object_format !== "wasm") {
flavors[`library-thread-${flavor}`] = {
...spec,
defines: ["SCR_LIB", "SCR_THREAD_INSTANCES"],
runtime_units: libraryUnits,
};
}
}
return { ...matrix, flavors };
}