A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
fix(gates): emcc is one answer, and a run without it says so
esengine9c8ed24314eb
diff --git a/build-tools/utils/emscripten.d.ts b/build-tools/utils/emscripten.d.tsindex 63ec0e451..53e4cc26e 100644--- a/build-tools/utils/emscripten.d.ts+++ b/build-tools/utils/emscripten.d.ts@@ -5,3 +5,6 @@/** The `emcc` to run, or null where no activated emsdk was found. */export function emccPath(): string | null;++export const NO_EMCC: string;+export function proveEmcc(suite: string): void;diff --git a/build-tools/utils/emscripten.js b/build-tools/utils/emscripten.jsindex 2510a7909..de2222ecc 100644--- a/build-tools/utils/emscripten.js+++ b/build-tools/utils/emscripten.js@@ -79,6 +79,28 @@ export function emccPath() {return null;}+/** How a checkout with no emsdk says so, rather than skipping in silence. */+export const NO_EMCC = 'ESTELLA_NO_EMCC';++/**+ * Prove the machine can compile to wasm before a suite claims it compared+ * anything against a module. A skip reads the same in a summary as a test that+ * ran, so a run either has emcc or declares that it has none.+ */+export function proveEmcc(suite) {+ if (emccPath()) return;+ if (process.env[NO_EMCC] === '1') {+ console.warn(`\n[${suite}] ${NO_EMCC}=1 — nothing that needs emcc ran.\n`+ + ' This run compiled no module, so it compared none.\n');+ return;+ }+ throw new Error(+ 'no activated emsdk on this machine.\n'+ + ' The AOT suites build a real module, and skipping them would report a partial run\n'+ + ` as a clean one. Run \`pnpm emsdk:setup\`, or declare the gap with ${NO_EMCC}=1 —\n`+ + ' which the gate runner then counts as something this machine could not answer.');+}+let emsdkActivated = false;/**diff --git a/compiler/tests/globalSetup.ts b/compiler/tests/globalSetup.tsindex 568f7a007..205352084 100644--- a/compiler/tests/globalSetup.ts+++ b/compiler/tests/globalSetup.ts@@ -5,10 +5,14 @@* to have compared the emitted C against the interpreter.** @details The prerequisite belongs to one place, not to each `skipIf` that- * needs it: proved once here, a skip inside means what it says.+ * needs it: proved once here, a skip inside means what it says. Two of+ * them: the differentials compile C for this machine, and the wasm+ * suite compiles a module for the engine's own.*/import { proveHostCC } from '../src/hostCC';+import { proveEmcc } from '../../build-tools/utils/emscripten.js';export default async function setup(): Promise<void> {proveHostCC('compiler-tests');+ proveEmcc('compiler-tests');}diff --git a/pipeline/src/bundle/emccPath.ts b/pipeline/src/bundle/emccPath.tsindex 849b8a062..6b78456f0 100644--- a/pipeline/src/bundle/emccPath.ts+++ b/pipeline/src/bundle/emccPath.ts@@ -15,14 +15,7 @@*/import { existsSync } from 'node:fs';import { spawn } from 'node:child_process';-import path from 'node:path';-import { fileURLToPath } from 'node:url';--/** `emcc` is a .bat on Windows, and spawning it needs the extension. */-const EXE = process.platform === 'win32' ? 'emcc.bat' : 'emcc';--/** The repo root, from this file's own location (pipeline/src/bundle). */-const REPO = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '..', '..');+import { emccPath } from '../../../build-tools/utils/emscripten.js';/*** Run it. Never rejects: a missing binary is a code and a message, so the step@@ -51,11 +44,8 @@ export function resolveEmcc(override?: string | null): string | null {if (override) return existsSync(override) ? override : null;const env = process.env['EMCC'];if (env && existsSync(env)) return env;- const emsdk = process.env['EMSDK'];- if (emsdk) {- const at = path.join(emsdk, 'upstream', 'emscripten', EXE);- if (existsSync(at)) return at;- }- const local = path.join(REPO, 'tools', 'emsdk', 'upstream', 'emscripten', EXE);- return existsSync(local) ? local : null;+ // The one discovery, not a second policy: this looked only at EMSDK and the+ // `tools/emsdk` submodule, so a machine whose emsdk lives anywhere else was+ // told it had no compiler while the SDK suite compiled on it all day.+ return emccPath();}diff --git a/pipeline/tests/globalSetup.ts b/pipeline/tests/globalSetup.tsindex 80ef3ba55..3b3964093 100644--- a/pipeline/tests/globalSetup.ts+++ b/pipeline/tests/globalSetup.ts@@ -8,7 +8,9 @@* in one place, so the `skipIf`s below it mean what they say.*/import { proveHostCC } from '../../compiler/src/hostCC';+import { proveEmcc } from '../../build-tools/utils/emscripten.js';export default async function setup(): Promise<void> {proveHostCC('pipeline-tests');+ proveEmcc('pipeline-tests');}diff --git a/sdk/tests/globalSetup.ts b/sdk/tests/globalSetup.tsindex acb08e69a..6dbd3d0e6 100644--- a/sdk/tests/globalSetup.ts+++ b/sdk/tests/globalSetup.ts@@ -19,6 +19,7 @@import { existsSync } from 'fs';import { resolve } from 'path';import { WASM_DIR, WASM_FILE, SIDE_MODULES, NO_WASM_MODE } from './helpers/loadWasm';+import { proveEmcc } from '../../build-tools/utils/emscripten.js';/** The package this suite belongs to — where it has to be run from. */const SDK_ROOT = resolve(__dirname, '..');@@ -27,6 +28,9 @@ const SDK_ROOT = resolve(__dirname, '..');const CANONICAL = 'pnpm --filter ./sdk test (or: cd sdk && npx vitest run)';export default async function setup(): Promise<void> {+ // The AOT suites build a real module; without emcc they would skip in silence.+ proveEmcc('sdk-tests');+if (NO_WASM_MODE) {console.warn('\n[sdk-tests] SDK_TEST_MODE=no-wasm — the engine boundary suites will NOT run.\n'diff --git a/tools/check-suite-preconditions.mjs b/tools/check-suite-preconditions.mjsindex 7ea83d6f6..46663388c 100644--- a/tools/check-suite-preconditions.mjs+++ b/tools/check-suite-preconditions.mjs@@ -30,6 +30,8 @@ const read = (p) => readFileSync(path.join(ROOT, p), 'utf8');*/const CAPABILITIES = [{ what: 'a host C compiler', probe: 'findHostCC', prover: 'proveHostCC', owner: 'compiler/src/hostCC.ts' },+ { what: 'an activated emsdk', probe: 'emccPath', prover: 'proveEmcc',+ owner: 'build-tools/utils/emscripten.js' },];/** Test files, by the package that owns them. */diff --git a/tools/run-gates.mjs b/tools/run-gates.mjsindex f6cf2c836..9279c9def 100644--- a/tools/run-gates.mjs+++ b/tools/run-gates.mjs@@ -59,6 +59,11 @@ const GAPS = [says: 'no C compiler — the emitted C was NOT compared against the interpreter,'+ ' and the ABI struct checks were not compiled',},+ {+ env: 'ESTELLA_NO_EMCC',+ value: '1',+ says: 'no emsdk — nothing was compiled to wasm, so nothing was compared against a module',+ },];const declared = GAPS.filter((g) => process.env[g.env] === g.value);const gates = gatesFor(SCOPE, HAS_EDITOR, { suites: SUITES });