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(export): the Steam depot names the OS that was actually built

esenginebb6dc2f36424
diff --git a/build-tools/utils/steamChannel.d.ts b/build-tools/utils/steamChannel.d.ts
index cf4a42c98..3b49cec43 100644
--- a/build-tools/utils/steamChannel.d.ts
+++ b/build-tools/utils/steamChannel.d.ts
@@ -5,8 +5,13 @@
export const STEAM_DIR: string;
-/** `appId + 1 + index` — the usual shape of what Valve assigns, never a fact. */
-export function defaultDepotId(appId: number, index: number): number;
+/** The OSes a Steam depot is written for — the desktop OSes, spelled as the
+ * runtime templates are. */
+export type SteamDepotOs = 'windows' | 'macos' | 'linux';
+
+/** `appId + 1` (windows), `+ 2` (macos), `+ 3` (linux) — the usual shape of what
+ * Valve assigns, never a fact. */
+export function defaultDepotId(appId: number, os: SteamDepotOs): number;
export function emitSteamBuild(options: {
/** The export directory, which is also the depot's content root. */
@@ -14,6 +19,6 @@ export function emitSteamBuild(options: {
appId: number;
/** Names the executable a depot maps and Steam launches. */
appName: string;
- depots: { os: string; depotId: number }[];
+ depots: { os: SteamDepotOs; depotId: number }[];
description?: string;
}): Promise<{ scripts: string[]; checklist: string }>;
diff --git a/build-tools/utils/steamChannel.js b/build-tools/utils/steamChannel.js
index b1fda422d..23965cfe0 100644
--- a/build-tools/utils/steamChannel.js
+++ b/build-tools/utils/steamChannel.js
@@ -56,9 +56,15 @@ function depotMapping(os, appName) {
* Valve ASSIGNS depot ids; appid+1, appid+2 is only the usual shape of what it
* assigns. So this is a starting point that the checklist tells you to check,
* never a fact — an upload to a depot that is not yours simply fails.
+ *
+ * Keyed by OS rather than by position in the build, so installing a second
+ * platform's template cannot renumber the first one's depot: a guess that moves
+ * under an existing project is worse than a guess.
*/
-export function defaultDepotId(appId, index) {
- return appId + 1 + index;
+const DEFAULT_DEPOT_OFFSET = { windows: 1, macos: 2, linux: 3 };
+
+export function defaultDepotId(appId, os) {
+ return appId + (DEFAULT_DEPOT_OFFSET[os] ?? 1);
}
/**
diff --git a/desktop/electron/exportGame.ts b/desktop/electron/exportGame.ts
index 1a75bab7d..20d95c0f7 100644
--- a/desktop/electron/exportGame.ts
+++ b/desktop/electron/exportGame.ts
@@ -49,7 +49,7 @@ import { assembleAab, aabFileName } from '../../build-tools/utils/aab.js';
import { assembleDesktopApp } from '../../build-tools/utils/desktopApp.js';
import { emitSteamBuild, defaultDepotId } from '../../build-tools/utils/steamChannel.js';
import { debugSigningKey, type SigningKey } from '../../build-tools/utils/androidKeystore.js';
-import { isNativePlatform, type ExportPlatform } from '../src/project/platforms';
+import { isNativePlatform, desktopTemplateFor, type DesktopOs, type ExportPlatform } from '../src/project/platforms';
import type { DesktopPackaging, SteamPackaging } from '../src/project/format';
import type { SizeBudget } from '../src/project/sizeBudget';
import { measureBuild, type BuildSizeReport } from './sizeReport';
@@ -205,9 +205,9 @@ export interface ExportGameResult {
/** Android: the signed App Bundle, when the project asked for one. Play takes
* this; it is not installable. */
aabFile?: string;
- /** Desktop: the assembled app bundle. Absent when no desktop runtime template
- * is installed (the export still carries its content). */
- appBundle?: string;
+ /** Desktop: the assembled apps, one per desktop OS a runtime template is
+ * installed for. Empty when none is (the export still carries its content). */
+ appBundles?: { os: DesktopOs; dir: string }[];
/** Desktop, Steam channel: the checklist naming this build's depot ids, launch
* string and cloud paths — the settings only the partner backend holds. */
steamChecklist?: string;
@@ -350,10 +350,11 @@ export interface ExportGameOptions {
* which carries every architecture it will ship. Omitted (or null) exports
* content only. */
androidTemplate?: string | null;
- /** Desktop: the installed runtime template for THIS OS, resolved by the caller
- * (the template ids are per-OS where the platform id is not). Omitted (or
- * null) exports content only. */
- desktopTemplate?: string | null;
+ /** Desktop: every installed runtime template, resolved by the caller — one app
+ * is assembled per entry. Not filtered to the building machine's OS: assembly
+ * is pure Node, and a Steam upload wants all of them. Empty exports content
+ * only. */
+ desktopTemplates?: { os: DesktopOs; dir: string }[];
/** Desktop: where this build goes (`packaging.platforms.desktop.channel`).
* Absent ⇒ standalone, which writes the app and nothing else. */
desktopChannel?: DesktopPackaging['channel'];
@@ -424,10 +425,17 @@ async function attachSizeReport(result: ExportGameResult, opts: ExportGameOption
// there loose, and the one a store/network takes is the deliverable the limit
// applies to. The playable ships its single file as index.html unless a zip
// was written for a zip-delivery network.
- const packages = [result.apkFile, result.aabFile, result.zipFile].filter((p): p is string => !!p);
+ const desktopApps = result.appBundles ?? [];
+ const packages = [result.apkFile, result.aabFile, result.zipFile, ...desktopApps.map((a) => a.dir)]
+ .filter((p): p is string => !!p);
+ // Desktop makes one package per OS; the limit is judged on the one this machine
+ // could run, falling back to the first, because a per-OS budget would be a
+ // different setting and none of the three is "the" upload.
+ const desktopApp = desktopApps.find((a) => a.os === desktopTemplateFor(process.platform))
+ ?? desktopApps[0];
const deliverable = result.platform === 'playable'
? result.zipFile ?? path.join(result.outDir, 'index.html')
- : result.apkFile ?? result.aabFile ?? result.appBundle;
+ : result.apkFile ?? result.aabFile ?? desktopApp?.dir;
try {
const size = await measureBuild({
root: result.outDir,
@@ -553,8 +561,8 @@ async function produceExport(opts: ExportGameOptions): Promise<ExportGameResult>
let androidProject: string | undefined;
let apkFile: string | undefined;
let aabFile: string | undefined;
- /** Desktop: the assembled `<name>.app`. */
- let appBundle: string | undefined;
+ /** Desktop: one assembled app per desktop OS a template is installed for. */
+ let appBundles: { os: DesktopOs; dir: string }[] = [];
/** Desktop, Steam channel: the per-build checklist written beside the scripts. */
let steamChecklist: string | undefined;
await mkdir(payloadDir, { recursive: true });
@@ -721,41 +729,52 @@ async function produceExport(opts: ExportGameOptions): Promise<ExportGameResult>
}
if (platform === 'desktop') {
- const template = opts.desktopTemplate ?? null;
- if (!template) {
+ // One app per installed template, whichever OS is doing the building: the
+ // assembler is pure Node, so a Steam upload can carry every OS from one
+ // machine (docs/REARCH_STEAM.md §6.3).
+ const templates = opts.desktopTemplates ?? [];
+ if (templates.length === 0) {
warnings.push('No desktop runtime template is installed for this editor version, so no app '
+ 'was assembled — the content is here. Install one from the Desktop row in Package '
+ 'Project, then export again.');
- } else if (process.platform === 'darwin' || process.platform === 'win32') {
- progress({ phase: 'Assembling the app' });
- appBundle = await assembleDesktopApp({
- platform: process.platform === 'darwin' ? 'macos' : 'windows',
- templateDir: template, contentDir: absOut, outDir: absOut, app: appConfig,
- iconPng: opts.appIcon ? path.join(opts.root, opts.appIcon) : undefined,
- warn: (m: string) => warnings.push(m),
+ }
+ for (const { os, dir } of templates) {
+ if (os === 'linux') {
+ warnings.push('The Linux desktop host is not written yet, so its template was skipped '
+ + '(docs/REARCH_STEAM.md §0g).');
+ continue;
+ }
+ progress({ phase: `Assembling the ${os} app` });
+ appBundles.push({
+ os,
+ dir: await assembleDesktopApp({
+ platform: os, templateDir: dir, contentDir: absOut, outDir: absOut, app: appConfig,
+ iconPng: opts.appIcon ? path.join(opts.root, opts.appIcon) : undefined,
+ warn: (m: string) => warnings.push(m),
+ }),
});
- if (opts.desktopChannel === 'steam') {
- const appId = opts.steam?.appId;
- if (!appId) {
- warnings.push('The Steam channel is selected but no App ID is set (Project Settings → '
- + 'Packaging → Desktop), so no depot scripts were written — scripts built around a '
- + 'guessed id would name someone else\'s game.');
- } else {
- progress({ phase: 'Writing the Steam build scripts' });
- const os = 'macos';
- const emitted = await emitSteamBuild({
- outDir: absOut,
- appId,
- appName: appConfig.name,
- description: opts.steam?.description,
- depots: [{ os, depotId: opts.steam?.depots?.[os] ?? defaultDepotId(appId, 0) }],
- });
- steamChecklist = emitted.checklist;
- }
+ }
+ if (opts.desktopChannel === 'steam' && appBundles.length > 0) {
+ const appId = opts.steam?.appId;
+ if (!appId) {
+ warnings.push('The Steam channel is selected but no App ID is set (Project Settings → '
+ + 'Packaging → Desktop), so no depot scripts were written — scripts built around a '
+ + 'guessed id would name someone else\'s game.');
+ } else {
+ progress({ phase: 'Writing the Steam build scripts' });
+ // A depot for each app that was actually assembled. Naming an OS whose
+ // app is not there uploads an empty depot and reports success.
+ const emitted = await emitSteamBuild({
+ outDir: absOut,
+ appId,
+ appName: appConfig.name,
+ description: opts.steam?.description,
+ depots: appBundles.map(({ os }) => ({
+ os, depotId: opts.steam?.depots?.[os] ?? defaultDepotId(appId, os),
+ })),
+ });
+ steamChecklist = emitted.checklist;
}
- } else {
- warnings.push(`Assembling a desktop app on ${process.platform} is not written yet — the `
- + 'content is here, and a macOS editor packages it.');
}
}
@@ -789,7 +808,7 @@ async function produceExport(opts: ExportGameOptions): Promise<ExportGameResult>
ok: errors.length === 0, platform, outDir: absOut, included: cook.included.length,
warnings, errors, ...(xcodeProject ? { xcodeProject } : {}), ...(androidProject ? { androidProject } : {}),
...(apkFile ? { apkFile } : {}), ...(aabFile ? { aabFile } : {}),
- ...(appBundle ? { appBundle } : {}),
+ ...(appBundles.length > 0 ? { appBundles } : {}),
...(steamChecklist ? { steamChecklist } : {}),
};
}
diff --git a/desktop/electron/main.ts b/desktop/electron/main.ts
index 25b97f7c5..cabf4050f 100644
--- a/desktop/electron/main.ts
+++ b/desktop/electron/main.ts
@@ -38,7 +38,7 @@ import {
iosSourcesFromTemplate, resolveNativeTemplate, installNativeTemplate, listNativeTemplates,
removeNativeTemplate, downloadNativeTemplate,
} from './nativeTemplates';
-import { desktopTemplateFor } from '../src/project/platforms';
+import { DESKTOP_OSES } from '../src/project/platforms';
import { loopbackServer, closeAllLoopbackServers } from './loopbackServer';
import { httpContentType } from './mimeTypes';
import { buildPlayRealm } from './buildPlayRealm';
@@ -1204,10 +1204,15 @@ ipcMain.handle(
androidTemplate: opts?.platform === 'android'
? (resolveNativeTemplate('android', app.getVersion())?.dir ?? null)
: null,
- // Desktop assembles the same way; the template it needs is this OS's.
- desktopTemplate: opts?.platform === 'desktop'
- ? (resolveNativeTemplate(desktopTemplateFor(process.platform), app.getVersion())?.dir ?? null)
- : null,
+ // Desktop assembles the same way, once per installed template — not once
+ // for this machine's OS. The assembler is pure Node, so which OS is running
+ // it is not an input, and a Steam upload wants every OS at once.
+ desktopTemplates: opts?.platform === 'desktop'
+ ? DESKTOP_OSES.flatMap((os) => {
+ const found = resolveNativeTemplate(os, app.getVersion());
+ return found ? [{ os, dir: found.dir }] : [];
+ })
+ : [],
desktopChannel: plat?.desktop?.channel,
steam: plat?.desktop?.steam,
androidOutput: plat?.android?.output,
diff --git a/desktop/electron/platformCatalog.ts b/desktop/electron/platformCatalog.ts
index b86a0ea0e..4cb61930d 100644
--- a/desktop/electron/platformCatalog.ts
+++ b/desktop/electron/platformCatalog.ts
@@ -30,7 +30,7 @@ import {
BUILTIN_PLAYABLE_PROFILES, builtinPlayableProfile, genericPlayableProfile,
type PlayableAdProfile,
} from './playableAdProfile';
-import { BUILTIN_PLATFORMS, desktopTemplateFor, type PlatformPrereq } from '../src/project/platforms';
+import { BUILTIN_PLATFORMS, DESKTOP_OSES, desktopTemplateFor, type PlatformPrereq } from '../src/project/platforms';
import { resolveNativeTemplate } from './nativeTemplates';
import { templateId } from '../../build-tools/utils/nativeTemplate.js';
import type { MiniGameExportProfile, MiniGameConfigContext } from './miniGameExportProfile';
@@ -92,12 +92,15 @@ function builtinReadiness(
case 'desktop': {
// Like Android: the runtime template IS the prerequisite, because the app is
- // assembled here in pure Node. Which template depends on the OS — the ids
- // are per-OS where the platform id is not.
- const template = desktopTemplateFor(process.platform);
- return resolveNativeTemplate(template, engineVersion)
- ? { ready: true }
- : { ready: false, prereq: { kind: 'template-missing', id: templateId(template), version: engineVersion } };
+ // assembled here in pure Node. ANY desktop template makes the target usable,
+ // not this machine's: assembly does not care which OS runs it, so a Mac with
+ // only the Windows template installed can still package — and does.
+ const installed = DESKTOP_OSES.filter((os) => resolveNativeTemplate(os, engineVersion));
+ if (installed.length > 0) return { ready: true };
+ // Which one to offer, though, IS this machine's: it is the build a developer
+ // can double-click when it comes out.
+ const mine = desktopTemplateFor(process.platform);
+ return { ready: false, prereq: { kind: 'template-missing', id: templateId(mine), version: engineVersion } };
}
case 'playable':
diff --git a/desktop/electron/sizeReport.ts b/desktop/electron/sizeReport.ts
index 623c37540..6aa9f8068 100644
--- a/desktop/electron/sizeReport.ts
+++ b/desktop/electron/sizeReport.ts
@@ -158,6 +158,10 @@ export function bucketIndexFrom(manifest: unknown): Map<string, SizeBucket> {
const normalizeRel = (p: string): string => p.replace(/\\/g, '/').replace(/^\.?\//, '');
+/** Whether @p rel is one of @p roots or sits inside one of them. */
+const isUnder = (rel: string, roots: readonly string[]): boolean =>
+ roots.some((root) => rel === root || rel.startsWith(`${root}/`));
+
/**
* Turn measured files into the report. Pure — the tests drive it with a list of
* paths and sizes, no build required.
@@ -274,7 +278,7 @@ export async function measureBuild(opts: {
deliverable?: string;
/**
* Absolute paths to packages written INSIDE `root` — the .apk, the .aab, the
- * playable's .zip.
+ * playable's .zip, a desktop app DIRECTORY.
*
* Each is a repackaging of content that also sits beside it as loose files, so
* counting both would double every byte and report a build at twice its
@@ -283,13 +287,17 @@ export async function measureBuild(opts: {
*/
packages?: readonly string[];
}): Promise<BuildSizeReport> {
- const excluded = new Set<string>();
+ const excluded: string[] = [];
for (const file of [...(opts.packages ?? []), ...(opts.deliverable ? [opts.deliverable] : [])]) {
const rel = path.relative(opts.root, file);
// path-sandbox: not a boundary — classifying which built files a report counts.
- if (rel && !rel.startsWith('..') && !path.isAbsolute(rel)) excluded.add(normalizeRel(rel));
+ if (rel && !rel.startsWith('..') && !path.isAbsolute(rel)) excluded.push(normalizeRel(rel));
}
- const files = (await collectBuildFiles(opts.root)).filter((f) => !excluded.has(normalizeRel(f.path)));
+ // By prefix, because a package is not always a file: a desktop build's package
+ // is the assembled app DIRECTORY, and excluding only its own name would leave
+ // every byte inside it counted a second time.
+ const files = (await collectBuildFiles(opts.root))
+ .filter((f) => !isUnder(normalizeRel(f.path), excluded));
let manifest: unknown = null;
try {
manifest = JSON.parse(await readFile(path.join(opts.root, 'asset-manifest.json'), 'utf8'));
@@ -298,7 +306,13 @@ export async function measureBuild(opts: {
let deliverableBytes: number | undefined;
if (opts.deliverable) {
try {
- deliverableBytes = (await stat(opts.deliverable)).size;
+ const info = await stat(opts.deliverable);
+ // A directory's own stat size is a few dozen bytes of bookkeeping, so a
+ // desktop app measured that way reports as weightless — and passes every
+ // limit. What ships is what is inside it.
+ deliverableBytes = info.isDirectory()
+ ? (await collectBuildFiles(opts.deliverable)).reduce((n, f) => n + f.bytes, 0)
+ : info.size;
} catch { /* not produced (no template installed) — the limit is then skipped */ }
}
diff --git a/desktop/src/project/platforms.ts b/desktop/src/project/platforms.ts
index 7aba89a1e..94dc50606 100644
--- a/desktop/src/project/platforms.ts
+++ b/desktop/src/project/platforms.ts
@@ -57,12 +57,20 @@ export function isNativePlatform(platform: ExportPlatform): platform is NativePl
}
/**
- * The runtime template a desktop package is assembled from, for the OS building
- * it — per-OS where the platform id is not, because the binaries are.
+ * The desktop OSes one `desktop` target is assembled for — per-OS where the
+ * platform id is not, because the binaries are.
*
- * Assembly is pure Node, but only macOS can sign a macOS bundle.
+ * A build produces one app per INSTALLED template, not one for the machine doing
+ * the building: assembly is pure Node, so the OS running it is not an input. Only
+ * signing a macOS bundle is, and that is a warning on one output rather than a
+ * reason to withhold the others.
*/
-export function desktopTemplateFor(osPlatform: string): 'macos' | 'windows' | 'linux' {
+export const DESKTOP_OSES = ['windows', 'macos', 'linux'] as const;
+export type DesktopOs = (typeof DESKTOP_OSES)[number];
+
+/** The desktop OS this machine is, for the template hint a missing prerequisite
+ * offers and for choosing which build a size limit is judged on. */
+export function desktopTemplateFor(osPlatform: string): DesktopOs {
if (osPlatform === 'darwin') return 'macos';
return osPlatform === 'win32' ? 'windows' : 'linux';
}
diff --git a/desktop/tests/export-desktop.test.ts b/desktop/tests/export-desktop.test.ts
index b88cf9453..835e18d8e 100644
--- a/desktop/tests/export-desktop.test.ts
+++ b/desktop/tests/export-desktop.test.ts
@@ -48,6 +48,30 @@ beforeAll(async () => {
afterAll(() => rmSync(root, { recursive: true, force: true }));
+/** A template with the files the assembler reads. What is under test is the EXPORT
+ * reaching the assembler; the assembler itself is pinned in desktop-app.test.ts. */
+function fakeTemplate(os: 'macos' | 'windows'): string {
+ const dir = path.join(root, `_template-${os}`);
+ mkdirSync(dir, { recursive: true });
+ writeFileSync(path.join(dir, os === 'windows' ? 'estella_desktop.exe' : 'estella_desktop'), 'runtime');
+ writeFileSync(path.join(dir, 'esengine.native.qjsbc'), 'bytecode');
+ writeFileSync(path.join(dir, 'Info.plist.in'),
+ '<plist><dict><key>N</key><string>@APP_NAME@</string></dict></plist>');
+ return dir;
+}
+
+const desktopExport = (outDir: string) => ({
+ root,
+ entryScene: 'scenes/main.esscene',
+ gameHostEntry: GAME_HOST,
+ scriptsEntry: 'src/main.ts',
+ sdkDistDir: path.join(root, '_sdk'),
+ wasmDir: path.join(root, '_wasm'),
+ outDir,
+ title: 'Packed Game',
+ platform: 'desktop' as const,
+});
+
describe('exportGame (desktop)', () => {
it('exports app CONTENT, not a web payload in a shell', async () => {
const res = await exportGame({
@@ -88,48 +112,69 @@ describe('exportGame (desktop)', () => {
// No template installed in this test's environment ⇒ content, and a warning
// that says so rather than a silent half-export.
- if (!res.appBundle) {
+ if (!res.appBundles) {
expect(res.warnings.join(' ')).toMatch(/runtime template/i);
}
}, 60_000);
- it('assembles the app when a runtime template is there', async () => {
- // A fake template, because what is under test is the EXPORT reaching the
- // assembler — the assembler itself is pinned in desktop-app.test.ts.
- const template = path.join(root, '_template');
- mkdirSync(template, { recursive: true });
- writeFileSync(path.join(template, 'estella_desktop'), 'runtime');
- writeFileSync(path.join(template, 'esengine.native.qjsbc'), 'bytecode');
- writeFileSync(path.join(template, 'Info.plist.in'),
- '<plist><dict><key>N</key><string>@APP_NAME@</string></dict></plist>');
-
+ it('assembles one app per installed template, on whatever OS is building', async () => {
const packed = path.join(root, 'dist-desktop-packed');
const res = await exportGame({
- root,
- entryScene: 'scenes/main.esscene',
- gameHostEntry: GAME_HOST,
- scriptsEntry: 'src/main.ts',
- sdkDistDir: path.join(root, '_sdk'),
- wasmDir: path.join(root, '_wasm'),
- outDir: packed,
- title: 'Packed Game',
- platform: 'desktop',
- desktopTemplate: template,
+ ...desktopExport(packed),
+ desktopTemplates: [
+ { os: 'windows', dir: fakeTemplate('windows') },
+ { os: 'macos', dir: fakeTemplate('macos') },
+ ],
});
expect(res.ok).toBe(true);
+ // Both, regardless of process.platform: the assembler is pure Node, so the
+ // machine doing the building is not an input (only signing a .app is).
+ expect(res.appBundles).toEqual([
+ { os: 'windows', dir: path.join(packed, 'Packed Game') },
+ { os: 'macos', dir: path.join(packed, 'Packed Game.app') },
+ ]);
+
+ // The runtime's bytecode joins the game's files in ONE namespace, which is
+ // what the host reads — the whole reason the bundles are laid out this way.
+ for (const content of ['Packed Game/Content', 'Packed Game.app/Contents/Resources/Content']) {
+ expect(existsSync(path.join(packed, content, 'game.config.json'))).toBe(true);
+ expect(existsSync(path.join(packed, content, 'esengine.native.qjsbc'))).toBe(true);
+ }
if (process.platform !== 'darwin') {
- // Honest rather than silent: assembly is written for macOS only so far.
- expect(res.appBundle).toBeUndefined();
- expect(res.warnings.join(' ')).toMatch(/not written yet/);
- return;
+ expect(res.warnings.join(' ')).toMatch(/UNSIGNED/);
}
- expect(res.appBundle).toBe(path.join(packed, 'Packed Game.app'));
- // The runtime's bytecode joins the game's files in ONE namespace, which is
- // what the host reads — the whole reason the bundle is laid out this way.
- const content = path.join(res.appBundle!, 'Contents/Resources/Content');
- expect(existsSync(path.join(content, 'game.config.json'))).toBe(true);
- expect(existsSync(path.join(content, 'esengine.native.qjsbc'))).toBe(true);
+ }, 60_000);
+
+ it('writes a depot for each app it actually assembled, not for one fixed OS', async () => {
+ const packed = path.join(root, 'dist-desktop-steam');
+ const res = await exportGame({
+ ...desktopExport(packed),
+ desktopTemplates: [{ os: 'windows', dir: fakeTemplate('windows') }],
+ desktopChannel: 'steam',
+ steam: { appId: 480 },
+ });
+
+ expect(res.ok).toBe(true);
+ expect(res.steamChecklist).toBe(path.join(packed, 'STEAM.md'));
+
+ // The Windows depot, and NOT a macOS one: a depot naming `<Name>.app/*` in a
+ // build that assembled `<Name>/` maps nothing, uploads an empty depot and
+ // reports success.
+ const scripts = readdirSync(path.join(packed, 'steam')).sort();
+ expect(scripts).toContain('depot_481_windows.vdf');
+ expect(scripts.some((f) => f.includes('macos'))).toBe(false);
+
+ const depot = readFileSync(path.join(packed, 'steam', 'depot_481_windows.vdf'), 'utf8');
+ expect(depot).toContain('"Packed Game/*"');
+ expect(depot).not.toContain('.app');
+
+ // And the checklist says what a player's Steam client will launch, plus where
+ // Auto-Cloud has to look — both per-OS, both wrong if the OS is assumed.
+ const checklist = readFileSync(res.steamChecklist!, 'utf8');
+ expect(checklist).toContain('Packed Game.exe');
+ expect(checklist).toContain('WinAppDataRoaming');
+ expect(checklist).not.toContain('MacHome');
}, 60_000);
it('no longer writes anything electron-builder would read', async () => {
diff --git a/desktop/tests/size-report.test.ts b/desktop/tests/size-report.test.ts
index 7f3628ab5..30ebbc3bf 100644
--- a/desktop/tests/size-report.test.ts
+++ b/desktop/tests/size-report.test.ts
@@ -225,6 +225,23 @@ describe('measuring a build on disk', () => {
expect(report.deliverableName).toBe('com.estella.game.apk');
});
+ it('measures a desktop app as the directory it is, and counts it once', async () => {
+ // A desktop package is a DIRECTORY, and stat() on one reports a few dozen
+ // bytes of bookkeeping — so measured as a file it weighs nothing and passes
+ // every limit, while its contents are still counted loose beside it.
+ await write('assets/hero.png', 1000);
+ await write('game.config.json', 20);
+ await write('Cool Game/Cool Game.exe', 4000);
+ await write('Cool Game/Content/assets/hero.png', 1000);
+ await write('Cool Game/Content/game.config.json', 20);
+ const app = path.join(dir, 'Cool Game');
+ const report = await measureBuild({
+ root: dir, platform: 'desktop', deliverable: app, packages: [app],
+ });
+ expect(report.packageBytes).toBe(1020); // the loose content only
+ expect(report.deliverableBytes).toBe(5020); // everything inside the app
+ });
+
it('reads the manifest the export wrote, so buckets agree with the runtime', async () => {
await write('asset-manifest.json', 0);
await writeFile(path.join(dir, 'asset-manifest.json'), JSON.stringify(MANIFEST));
diff --git a/desktop/tests/steam-channel.test.ts b/desktop/tests/steam-channel.test.ts
index a22e50cf4..3ded6c82e 100644
--- a/desktop/tests/steam-channel.test.ts
+++ b/desktop/tests/steam-channel.test.ts
@@ -24,7 +24,7 @@ afterEach(() => { rmSync(out, { recursive: true, force: true }); });
const emit = () => emitSteamBuild({
outDir: out, appId: 480, appName: 'Physics Spinner',
- depots: [{ os: 'macos', depotId: defaultDepotId(480, 0) }],
+ depots: [{ os: 'macos', depotId: defaultDepotId(480, 'macos') }],
});
describe('the Steam channel', () => {
@@ -52,7 +52,7 @@ describe('the Steam channel', () => {
// a depot that took both would ship every asset twice.
writeFileSync(path.join(out, 'game.config.json'), '{}');
await emit();
- const depot = readFileSync(path.join(out, 'steam', 'depot_481_macos.vdf'), 'utf8');
+ const depot = readFileSync(path.join(out, 'steam', 'depot_482_macos.vdf'), 'utf8');
expect(depot).toContain('"LocalPath"\t\t"Physics Spinner.app/*"');
expect(depot).not.toContain('"LocalPath"\t\t"*"');
});
@@ -67,7 +67,7 @@ describe('the Steam channel', () => {
it('tells this build what the backend needs, not what a manual would', async () => {
const { checklist } = await emit();
const text = readFileSync(checklist, 'utf8');
- expect(text).toContain('`481`'); // the depot id in use
+ expect(text).toContain('`482`'); // the depot id in use
expect(text).toContain('`Physics Spinner.app`'); // the launch string
// The save path the engine actually writes to, in the words Auto-Cloud uses.
expect(text).toContain('`MacHome`');
@@ -79,6 +79,31 @@ describe('the Steam channel', () => {
expect(readFileSync(checklist, 'utf8')).toMatch(/guess|assigns/i);
});
+ it('guesses a depot id per OS, so a second platform cannot renumber the first', () => {
+ // Keyed by OS, not by position in the build: a project that shipped a macOS
+ // depot and then installs the Windows template must not find its macOS
+ // guess pointing at someone else's depot.
+ expect([480, 480, 480].map((id, n) => defaultDepotId(id, (['windows', 'macos', 'linux'] as const)[n])))
+ .toEqual([481, 482, 483]);
+ });
+
+ it('writes one depot per OS the build actually produced', async () => {
+ const { scripts } = await emitSteamBuild({
+ outDir: out, appId: 480, appName: 'Spinner',
+ depots: [
+ { os: 'windows', depotId: defaultDepotId(480, 'windows') },
+ { os: 'macos', depotId: defaultDepotId(480, 'macos') },
+ ],
+ });
+ expect(scripts.map((s) => path.basename(s))).toEqual([
+ 'depot_481_windows.vdf', 'depot_482_macos.vdf', 'app_build_480.vdf',
+ ]);
+ // Both listed in the app build, or steamcmd uploads only the one it sees.
+ const build = readFileSync(path.join(out, 'steam', 'app_build_480.vdf'), 'utf8');
+ expect(build).toContain('"481"\t\t"depot_481_windows.vdf"');
+ expect(build).toContain('"482"\t\t"depot_482_macos.vdf"');
+ });
+
it('honours depot ids the project was given', async () => {
await emitSteamBuild({
outDir: out, appId: 480, appName: 'G', depots: [{ os: 'macos', depotId: 90210 }],