Skip to content

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.

fix(gates): the twin freshness gate ran on an empty file list on Windows

yhhb0ec6aa8f670
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 121801332..5ac5f2650 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -302,7 +302,7 @@ jobs:
# is WebGPU-dead by design and gen-shader-twins --check exits 1 on it. Covers
# examples/ too so a shipped user shader can never regress to WebGL-only.
- name: Check shader twins
- run: node tools/gen-shader-twins.mjs --check $(find fixtures/scenes examples -name '*.esshader')
+ run: node tools/gen-shader-twins.mjs --check fixtures/scenes examples
# Pipeline smoke: strip a fixture's twins into a temp copy and require the
# vendored converters (glslang wasm + naga WASI wasm) to produce one —
diff --git a/tools/gates.mjs b/tools/gates.mjs
index eac759ae3..fca0a68be 100644
--- a/tools/gates.mjs
+++ b/tools/gates.mjs
@@ -119,7 +119,7 @@ export const GATES = [
// master carrying a stamp older than their own GLSL.
id: 'wgsl-twin-fresh',
run: "if [ -f build/wasm/web/esengine.js ]; then "
- + "node tools/gen-shader-twins.mjs --check $(find fixtures/scenes examples -name '*.esshader'); "
+ + "node tools/gen-shader-twins.mjs --check fixtures/scenes examples; "
+ "else echo 'wgsl-twin-fresh: skipped — no built engine in build/wasm/web'; fi",
where: 'local',
why: 'the check cooks each shader to hash the ASSEMBLED GLSL, so it needs the built engine and skips a machine without one; the render CI job runs it where the binary is',
diff --git a/tools/gen-shader-twins.mjs b/tools/gen-shader-twins.mjs
index 194d74f2f..cfc199694 100644
--- a/tools/gen-shader-twins.mjs
+++ b/tools/gen-shader-twins.mjs
@@ -38,7 +38,7 @@
* the GLSL side uses. Past three toggles the file is skipped and says so —
* each one doubles the emitted programs.
*/
-import { mkdtemp, readFile, rm, writeFile } from 'node:fs/promises';
+import { mkdtemp, readdir, readFile, rm, stat, writeFile } from 'node:fs/promises';
import { createHash } from 'node:crypto';
import { tmpdir } from 'node:os';
import path from 'node:path';
@@ -427,12 +427,29 @@ export async function processFile(module, file, opts) {
}
}
+/** Every .esshader under a directory, or the file itself. A caller that had to
+ * list them needed a shell to do it, and `find` on Windows is a text search that
+ * answers "File not found" and exits 0 -- so the gate ran on an empty list. */
+async function expand(arg) {
+ if (!(await stat(arg)).isDirectory()) return [arg];
+ const out = [];
+ for (const e of await readdir(arg, { withFileTypes: true, recursive: true })) {
+ if (e.isFile() && e.name.endsWith('.esshader')) out.push(path.join(e.parentPath ?? e.path, e.name));
+ }
+ return out.sort();
+}
+
async function main() {
const args = process.argv.slice(2);
const opts = { check: args.includes('--check'), force: args.includes('--force') };
- const files = args.filter((a) => !a.startsWith('--'));
+ const roots = args.filter((a) => !a.startsWith('--'));
+ if (roots.length === 0) {
+ console.error('usage: node tools/gen-shader-twins.mjs [--check] [--force] <file.esshader | dir ...>');
+ process.exit(2);
+ }
+ const files = (await Promise.all(roots.map(expand))).flat();
if (files.length === 0) {
- console.error('usage: node tools/gen-shader-twins.mjs [--check] [--force] <file.esshader ...>');
+ console.error(`gen-shader-twins: no .esshader under ${roots.join(', ')}`);
process.exit(2);
}