Files
scriptc/packages/cli/scripts/warm-cache.mjs
Chris Tate 64b2a285d5 feat(runtime): ship precompiled macOS artifacts (#248)
* feat(runtime): ship precompiled macOS artifacts

- Add a versioned macOS arm64 runtime pack with deterministic feature selection and artifact verification.
- Link LLVM helper objects against release-built runtime and vendor inputs without compiling user-machine C.
- Wire package publishing, cache validation, documentation, and full-gate coverage for the new path.

* fix(runtime): harden precompiled artifact handling

* fix(runtime): make precompiled artifacts reproducible

* fix(runtime): reject opaque linkers from executable cache

* fix(runtime): normalize precompiled archive metadata

* fix(runtime): harden precompiled artifact caching

* fix(runtime): close executable cache link race

* fix(runtime): stage verified pack artifacts

* fix(runtime): bracket helper cache inputs

* fix(runtime): preserve executable link identity

* fix(runtime): trace selected linker dependencies
2026-08-28 09:29:21 -05:00

31 lines
1.3 KiB
JavaScript

#!/usr/bin/env node
import { existsSync } from "node:fs";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
import { hostSupportsRuntimePack } from "./runtime-pack-host.mjs";
// Workspace installs should stay cheap and deterministic: repository test
// images already manage cache warming explicitly. Published npm packages do
// not contain src/, so only installed consumers take this best-effort path.
const packageRoot = dirname(dirname(fileURLToPath(import.meta.url)));
if (
!existsSync(join(packageRoot, "src")) &&
process.env["SCRIPTC_NO_CACHE"] !== "1" &&
// A supported macOS arm64 install already carries immutable release/dev
// runtime artifacts. Older macOS hosts retain the source-toolchain path.
!hostSupportsRuntimePack()
) {
try {
const { warmNativeCaches } = await import("@scriptc/compiler");
await warmNativeCaches();
} catch (error) {
// Installation must never depend on a native toolchain. A machine without
// clang/ar (or with lifecycle scripts disabled) retains ordinary lazy
// first-build behavior; explicit `scriptc cache warm` reports errors.
if (process.env["SCRIPTC_CACHE_WARM_DEBUG"] === "1") {
process.stderr.write(`scriptc: cache warm skipped: ${error instanceof Error ? error.message : String(error)}\n`);
}
}
}