mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-22 05:59:31 +08:00
- Build static programs through the TypeScript 7 frontend, C and LLVM emitters, and native linker without a JavaScript host - Share runtime-pack verification and link planning across native and Node compiler hosts - Handle large C output and deep logical-expression validation during compiler bootstrapping
33 lines
1.5 KiB
TypeScript
33 lines
1.5 KiB
TypeScript
import { readFileSync } from "node:fs";
|
|
import { relative } from "node:path";
|
|
import { loadNativeToolchain } from "../../../packages/compiler/src/native/toolchain.js";
|
|
import { stageNativeRuntimePack } from "../../../packages/compiler/src/backend/runtime-pack-native.js";
|
|
import { validateNativeCodegenVersion } from "../../../packages/compiler/src/backend/native-codegen-core.js";
|
|
import type { NativeLinkFeatures } from "../../../packages/compiler/src/backend/native-link-info.js";
|
|
|
|
const request = JSON.parse(readFileSync(process.argv[2]!, "utf8")) as {
|
|
toolchain: string;
|
|
stage: string;
|
|
features: NativeLinkFeatures;
|
|
action: "stage" | "helper";
|
|
version: Record<string, unknown>;
|
|
};
|
|
try {
|
|
const toolchain = loadNativeToolchain(request.toolchain);
|
|
if (request.action === "helper") {
|
|
const version = validateNativeCodegenVersion(request.version, toolchain.target, toolchain.helper, toolchain.compilerVersion);
|
|
console.log(version.protocol_version, version.scriptc_package_version, version.llvm_version, version.default_target);
|
|
} else {
|
|
const pack = stageNativeRuntimePack(toolchain.runtimePackRoot, request.stage, toolchain.target,
|
|
toolchain.compilerVersion, request.features, "release");
|
|
console.log(JSON.stringify({
|
|
runtime: pack.runtimeObjects.map((path) => relative(request.stage, path)),
|
|
archives: pack.archives.map((path) => relative(request.stage, path)),
|
|
libraries: pack.systemLibraries,
|
|
}));
|
|
}
|
|
} catch (error) {
|
|
console.log(error instanceof Error ? error.message : String(error));
|
|
process.exitCode = 1;
|
|
}
|