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(native): Steam is loaded by PATH, and shipped by the project's own SDK
esengined82216e59676
diff --git a/build-tools/cli.js b/build-tools/cli.jsindex 4d5a6ea52..f8496f418 100644--- a/build-tools/cli.js+++ b/build-tools/cli.js@@ -167,7 +167,7 @@ program.option('--dawn-build <dir>', 'Dawn build dir for this target (default: <dawn>/out-<target>, built if absent)').option('--quickjs <dir>', 'QuickJS-ng source dir (default: the pinned checkout; or ESTELLA_QUICKJS_DIR)').option('--sdl <dir>', 'Desktop: SDL3 source dir or install prefix (default: the pinned checkout; or ESTELLA_SDL_DIR)')- .option('--steam-sdk <dir>', 'Desktop template: a Steamworks SDK on this machine; its redistributable rides along so games get achievements with no setup')+ .option('--steam-sdk <dir>', 'Desktop: a Steamworks SDK on this machine; its redistributable ships in the package (and in a template built with --template-out)').option('--macos-archs <archs>', 'Desktop: CMAKE_OSX_ARCHITECTURES (arm64, or "arm64;x86_64" for a universal build)').option('--macos-min <version>', 'Desktop: macOS deployment target').option('--abi <abi>', 'Android ABI', 'arm64-v8a')diff --git a/build-tools/tasks/native.js b/build-tools/tasks/native.jsindex d1c80e776..ef14b48f5 100644--- a/build-tools/tasks/native.js+++ b/build-tools/tasks/native.js@@ -696,7 +696,7 @@ async function packageDesktopApp(options) {: path.dirname(contentDir);logger.step(`Assembling ${app.name} for ${platform}...`);- const bundle = await assembleDesktopApp({+ const { dir: bundle, steamLibrary } = await assembleDesktopApp({platform,templateDir: template.dir,contentDir,@@ -705,9 +705,11 @@ async function packageDesktopApp(options) {iconPng: options.icon,macosMin: options.macosMin || MACOS_MIN,signIdentity: options.signIdentity,+ steamSdkDir: options.steamSdk,warn: (m) => logger.warn(m),});logger.success(`${platform} app: ${path.relative(config.paths.root, bundle) || bundle}`);+ if (steamLibrary) logger.info(`Steam: ${path.basename(steamLibrary)} rides along.`);logger.info(platform === 'macos' ? `Run it with: open "${bundle}"` : `Run it: ${bundle}`);return bundle;}diff --git a/build-tools/utils/desktopApp.d.ts b/build-tools/utils/desktopApp.d.tsindex b50158836..9b3565dfd 100644--- a/build-tools/utils/desktopApp.d.ts+++ b/build-tools/utils/desktopApp.d.ts@@ -25,6 +25,16 @@ export function assembleDesktopApp(options: {macosMin?: string;/** codesign identity; ad-hoc when absent. */signIdentity?: string;- /** Told when the bundle could not be signed (assembling off macOS). */+ /** A Steamworks SDK on this machine; its redistributable ships in the app.+ * Beats one the template was built with — an explicit setting wins. */+ steamSdkDir?: string;+ /** Told when the bundle could not be signed (assembling off macOS), or when a+ * named SDK held no redistributable. */warn?: (message: string) => void;-}): Promise<string>;+}): Promise<{+ /** The app directory. */+ dir: string;+ /** The store library shipped inside it, or null — without one the game runs+ * and every achievement silently reaches nobody. */+ steamLibrary: string | null;+}>;diff --git a/build-tools/utils/desktopApp.js b/build-tools/utils/desktopApp.jsindex 1dd6d6bad..4b6903c5e 100644--- a/build-tools/utils/desktopApp.js+++ b/build-tools/utils/desktopApp.js@@ -18,7 +18,7 @@ import path from 'path';import { existsSync } from 'fs';import { chmod, cp, mkdir, readdir, readFile, rm, writeFile } from 'fs/promises';import { pngToIcns } from './icns.js';-import { desktopTemplateSources } from './nativeTemplate.js';+import { desktopTemplateSources, steamRedistIn } from './nativeTemplate.js';import { fillTemplate } from './nativeApp.js';/** Everything a bundle's Info.plist needs that is not the host's own business. */@@ -60,7 +60,11 @@ const LAYOUT = {* @param {{id: string, name: string, version: string, versionCode: number}} options.app* @param {string} [options.iconPng] Project icon; the template's is used otherwise.* @param {string} [options.macosMin] LSMinimumSystemVersion.- * @returns {Promise<string>} the app directory's path.+ * @param {string} [options.steamSdkDir] A Steamworks SDK on this machine; its+ * redistributable rides along so the game can reach Steam.+ * @returns {Promise<{dir: string, steamLibrary: string | null}>} where the app is,+ * and whether a store library went into it — a caller shipping to Steam has to+ * be able to say so, because without it every achievement silently does nothing.*/export async function assembleDesktopApp(options) {const { platform, templateDir, contentDir, outDir, app } = options;@@ -100,11 +104,23 @@ export async function assembleDesktopApp(options) {await cp(sources.bytecode, path.join(content, path.basename(sources.bytecode)));}- // What the runtime needs beside the executable: Dawn's HLSL compiler (Windows)- // and Steam's redistributable, which the host dlopens if present. Copied rather- // than required — a template without one still produces a game.- for (const dll of [sources.d3dCompiler, sources.steamRedist]) {- if (dll && existsSync(dll)) await cp(dll, path.join(root, path.basename(dll)));+ // What the runtime dlopens goes NEXT TO THE EXECUTABLE, the one directory the+ // host looks in — Contents/MacOS on macOS (Platform::executableDir).+ const besideExe = path.dirname(executable);+ // The project's own SDK beats whatever the template was built with: a template+ // published by CI can carry no Valve file at all.+ const steamLib = steamRedistIn(options.steamSdkDir, platform)+ ?? (existsSync(sources.steamRedist) ? sources.steamRedist : null);+ if (options.steamSdkDir && !steamLib) {+ options.warn?.(`No redistributable under ${options.steamSdkDir} — a Steamworks SDK keeps it `+ + 'at redistributable_bin/<os>/. This build reaches no store.');+ }+ let steamLibrary = null;+ for (const lib of [sources.d3dCompiler, steamLib]) {+ if (!lib || !existsSync(lib)) continue;+ const shipped = path.join(besideExe, path.basename(lib));+ await cp(lib, shipped);+ if (lib === steamLib) steamLibrary = shipped;}const iconPng = options.iconPng && existsSync(options.iconPng) ? options.iconPng : sources.icon;@@ -121,9 +137,9 @@ export async function assembleDesktopApp(options) {VERSION_CODE: String(app.versionCode),MACOS_MIN: options.macosMin || PLIST_DEFAULT_MIN,}));- await signBundle(root, options);+ await signBundle(root, options, steamLibrary ? [steamLibrary] : []);}- return root;+ return { dir: root, steamLibrary };}/**@@ -132,8 +148,12 @@ export async function assembleDesktopApp(options) {* The template's executable is signed AS A FILE; a bundle needs* `_CodeSignature/CodeResources` too, and without it the app still launches — so* nothing tells you until notarization. macOS only.+ *+ * Inside out: a library shipped in the bundle is code, and a bundle whose nested+ * code is unsigned fails `--verify --deep --strict` even though the bundle itself+ * signed cleanly.*/-async function signBundle(bundle, options) {+async function signBundle(bundle, options, nested = []) {if (process.platform !== 'darwin') {options.warn?.(`${path.basename(bundle)} is UNSIGNED — assembling on ${process.platform} `+ 'cannot sign a macOS app. Run `codesign --force --sign - <app>` on a Mac before shipping it.');@@ -142,5 +162,7 @@ async function signBundle(bundle, options) {const { execFile } = await import('node:child_process');const { promisify } = await import('node:util');const identity = options.signIdentity || '-';- await promisify(execFile)('codesign', ['--force', '--sign', identity, bundle]);+ const sign = (target) => promisify(execFile)('codesign', ['--force', '--sign', identity, target]);+ for (const item of nested) await sign(item);+ await sign(bundle);}diff --git a/build-tools/utils/nativeTemplate.js b/build-tools/utils/nativeTemplate.jsindex c5b2897de..18e7844c6 100644--- a/build-tools/utils/nativeTemplate.js+++ b/build-tools/utils/nativeTemplate.js@@ -54,8 +54,13 @@ export const STEAM_REDIST = {linux: 'libsteam_api.so',};-/** The redistributable inside a Steamworks SDK checkout, or null. */-function steamRedist(sdkDir, platform) {+/**+ * The redistributable inside a Steamworks SDK checkout, or null.+ *+ * The one place that knows an SDK's layout: the template build reads it here, and+ * so does the assembler, which is where a project's own SDK reaches a package.+ */+export function steamRedistIn(sdkDir, platform) {if (!sdkDir) return null;const sub = { windows: 'win64', macos: 'osx', linux: 'linux64' }[platform];const file = path.join(sdkDir, 'redistributable_bin', sub, STEAM_REDIST[platform]);@@ -163,7 +168,7 @@ export function templateLayout(platform, options = {}) {// template without it still packages every game.{rel: STEAM_REDIST[platform], optional: true,- from: (ctx) => steamRedist(ctx.steamSdk, platform),+ from: (ctx) => steamRedistIn(ctx.steamSdk, platform),},{ rel: DEFAULT_ICON, from: (ctx) => path.join(ctx.root, 'native', 'icon.png') },];diff --git a/build-tools/utils/steamChannel.d.ts b/build-tools/utils/steamChannel.d.tsindex 3b49cec43..7b1416c6b 100644--- a/build-tools/utils/steamChannel.d.ts+++ b/build-tools/utils/steamChannel.d.ts@@ -20,5 +20,9 @@ export function emitSteamBuild(options: {/** Names the executable a depot maps and Steam launches. */appName: string;depots: { os: SteamDepotOs; depotId: number }[];+ /** Ids the game unlocks; each must be created by hand in the backend. */+ achievements?: string[];+ /** Whether the packages carry Steam's redistributable. */+ steamLibrary?: boolean;description?: string;}): Promise<{ scripts: string[]; checklist: string }>;diff --git a/build-tools/utils/steamChannel.js b/build-tools/utils/steamChannel.jsindex 23965cfe0..c392dd01b 100644--- a/build-tools/utils/steamChannel.js+++ b/build-tools/utils/steamChannel.js@@ -76,6 +76,10 @@ export function defaultDepotId(appId, os) {* @param {string} options.appName The app's name, which names its executable.* @param {{os: string, depotId: number}[]} options.depots* @param {string} [options.description] Build description shown in the backend.+ * @param {string[]} [options.achievements] Ids the game unlocks — each has to+ * exist in the backend, where it is created by hand.+ * @param {boolean} [options.steamLibrary] Whether the packages carry Steam's+ * redistributable. Without it the game runs and reaches no store.* @returns {Promise<{scripts: string[], checklist: string}>}*/export async function emitSteamBuild(options) {@@ -111,17 +115,42 @@ export async function emitSteamBuild(options) {scripts.push(appFile);const checklist = path.join(outDir, 'STEAM.md');- await writeFile(checklist, checklistFor({ appId, appName, depots, appFile }));+ await writeFile(checklist, checklistFor({ ...options, appFile }));return { scripts, checklist };}+/**+ * The two ways achievements silently do nothing, said before they can happen.+ *+ * An id the backend does not have is accepted and dropped; a package with no+ * redistributable never reaches Steam at all. Neither reports anything, and both+ * end with a player noticing months later.+ */+function achievementSection(ids, steamLibrary) {+ const library = steamLibrary+ ? 'This build carries Steam\'s redistributable, so it can reach the store.'+ : '**This build carries no Steam library**, so nothing here reaches Steam: unlocks are '+ + 'recorded locally and `Achievements.available` is false. Point Project Settings → '+ + 'Packaging → Steamworks SDK at your own SDK download and export again.';+ if (ids.length === 0) {+ return `${library}\n\nThis project declares no achievements (Project Settings → Packaging).`;+ }+ return `${library}++Create each of these under **Achievements → Edit** with the SAME API name. Steam+accepts an unlock of an id it does not have and does nothing with it, so a name+that differs by one character is an achievement no player can ever get.++${ids.map((id) => `- \`${id}\``).join('\n')}`;+}+/*** The build's own values, for the settings only the partner backend holds.** Generic instructions belong in the docs; what cannot be looked up is what THIS* build needs pasted where — the launch string, the depot ids, the cloud path.*/-function checklistFor({ appId, appName, depots, appFile }) {+function checklistFor({ appId, appName, depots, appFile, achievements = [], steamLibrary = false }) {const rows = depots.map(({ os, depotId }) =>`| ${os} | \`${depotId}\` | \`${launchTarget(os, appName)}\` |`).join('\n');const cloud = depots.map(({ os }) => {@@ -145,6 +174,10 @@ them against **SteamPipe → Depots** and set \`packaging.platforms.desktop.steaif they differ. An upload to a depot that is not yours fails rather than goingsomewhere wrong.+## Achievements++${achievementSection(achievements, steamLibrary)}+## Cloud savesThe game writes its saves where the OS says it should, which is a path Steamdiff --git a/desktop/electron/exportGame.ts b/desktop/electron/exportGame.tsindex 20d95c0f7..b67603b63 100644--- a/desktop/electron/exportGame.ts+++ b/desktop/electron/exportGame.ts@@ -733,6 +733,7 @@ async function produceExport(opts: ExportGameOptions): Promise<ExportGameResult>// 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 ?? [];+ let steamLibrary = false;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 '@@ -745,14 +746,21 @@ async function produceExport(opts: ExportGameOptions): Promise<ExportGameResult>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),- }),+ const built = await assembleDesktopApp({+ platform: os, templateDir: dir, contentDir: absOut, outDir: absOut, app: appConfig,+ iconPng: opts.appIcon ? path.join(opts.root, opts.appIcon) : undefined,+ steamSdkDir: opts.steam?.sdkPath,+ warn: (m: string) => warnings.push(m),});+ appBundles.push({ os, dir: built.dir });+ steamLibrary ||= built.steamLibrary !== null;+ // Silence is the failure mode: with no library the game runs, every unlock+ // reaches nobody, and nothing reports it until a player does.+ if (opts.desktopChannel === 'steam' && !built.steamLibrary) {+ warnings.push(`The ${os} build carries no Steam library, so it reaches no store: `+ + 'achievements are recorded locally and nothing else. Point Project Settings → '+ + 'Packaging → Steamworks SDK at your own SDK download.');+ }}if (opts.desktopChannel === 'steam' && appBundles.length > 0) {const appId = opts.steam?.appId;@@ -769,6 +777,10 @@ async function produceExport(opts: ExportGameOptions): Promise<ExportGameResult>appId,appName: appConfig.name,description: opts.steam?.description,+ // The checklist is where a build says what the backend must be told AND+ // what this package can actually reach.+ achievements: opts.runtime?.achievements,+ steamLibrary,depots: appBundles.map(({ os }) => ({os, depotId: opts.steam?.depots?.[os] ?? defaultDepotId(appId, os),})),diff --git a/desktop/electron/externalProgram.ts b/desktop/electron/externalProgram.tsindex 173128209..a70fcc6ea 100644--- a/desktop/electron/externalProgram.ts+++ b/desktop/electron/externalProgram.ts@@ -86,3 +86,9 @@ export async function pickProgram(win: BrowserWindow, title: string): Promise<st});return res.canceled || res.filePaths.length === 0 ? null : res.filePaths[0];}++/** Ask for a directory on this machine — an SDK, a toolchain root, a checkout. */+export async function pickDirectory(win: BrowserWindow, title: string): Promise<string | null> {+ const res = await showOpenDialog(win, { title, properties: ['openDirectory'] });+ return res.canceled || res.filePaths.length === 0 ? null : res.filePaths[0];+}diff --git a/desktop/electron/main.ts b/desktop/electron/main.tsindex cabf4050f..d1da8d8a5 100644--- a/desktop/electron/main.ts+++ b/desktop/electron/main.ts@@ -71,7 +71,7 @@ import {PLUGIN_PACKAGE_EXT,} from './pluginPackage';import { findUpdate, downloadUpdate, installUpdate } from './autoUpdate';-import { pickProgram, launchProgram, type LaunchError } from './externalProgram';+import { pickProgram, pickDirectory, launchProgram, type LaunchError } from './externalProgram';import { detectEditors } from './editorCatalog';import {listPlatforms, loadProjectPlatform, createProjectPlatform, setPlatformTrustGate,@@ -993,6 +993,7 @@ ipcMain.handle('shell:openPath', (_e, absPath: string) => shell.openPath(absPath// EMPTY program means the OS default — so which program opens a file is data the// caller passes, not a second IPC it has to choose between.ipcMain.handle('external:pick', async (_e, title: string) => (win ? pickProgram(win, title) : null));+ipcMain.handle('external:pickDir', async (_e, title: string) => (win ? pickDirectory(win, title) : null));// The browser the user named in Settings, mirrored from the renderer that owns// editor-scoped settings — the same shape as the dirty flag above, and for thediff --git a/desktop/electron/preload.ts b/desktop/electron/preload.tsindex 4d10c3851..10c70630c 100644--- a/desktop/electron/preload.ts+++ b/desktop/electron/preload.ts@@ -301,6 +301,7 @@ const api = {openPath: (absPath: string): Promise<string> => ipcRenderer.invoke('shell:openPath', absPath),/** Show a picker for an external program; absolute path, or null if cancelled. */pickProgram: (title: string): Promise<string | null> => ipcRenderer.invoke('external:pick', title),+ pickDirectory: (title: string): Promise<string | null> => ipcRenderer.invoke('external:pickDir', title),/** Mirror the chosen browser to main, which opens urls without a call site. */setBrowser: (program: string): void => ipcRenderer.send('external:browser', program),/** Known code editors actually installed, in preference order. */diff --git a/desktop/scripts/export-project.mjs b/desktop/scripts/export-project.mjsindex f97cdd9e1..94785aff3 100644--- a/desktop/scripts/export-project.mjs+++ b/desktop/scripts/export-project.mjs@@ -19,6 +19,8 @@// --template <dir> android/ios: the runtime template to wrap, else the installed one// --json <file> also write the result here, for a caller that reads it back// --enforce-budget fail (exit 1) when the package is over a size limit+// --steam-sdk <dir> desktop: a Steamworks SDK whose redistributable ships in the app+// --steam-appid <id> desktop: also write the Steam depot scripts for this app id//// Prints the export result as JSON — errors, warnings, and what the package weighs// against the limits in force — so a caller can tell a clean package from one that@@ -65,6 +67,10 @@ function parseArgs(argv) {return opts;}+/** Which desktop template this machine can also RUN, for --template. */+const HOST_DESKTOP_OS = process.platform === 'darwin' ? 'macos'+ : process.platform === 'win32' ? 'windows' : 'linux';+const fileUrl = (p) => `file:///${p.replace(/\\/g, '/')}`;// Bundle exportGame.ts to a temp module and import it. ESM, because the cook reads@@ -164,6 +170,15 @@ const templateDir = nativePlatform? path.resolve(opts.template): firstExisting([installedTemplateDir(engineVersion, platform)]) ?? null): null;+// Desktop takes a template PER OS, and assembles one app for each it finds: the+// assembler is pure Node, so a headless run on one machine produces the same set+// the editor would. --template names one and then it is the only one.+const desktopTemplates = platform !== 'desktop' ? [] : (opts.template+ ? [{ os: HOST_DESKTOP_OS, dir: path.resolve(opts.template) }]+ : ['windows', 'macos', 'linux'].flatMap((os) => {+ const dir = firstExisting([installedTemplateDir(engineVersion, os)]);+ return dir ? [{ os, dir }] : [];+ }));// The engine runtime for this target — the headless half of the editor's// `platformRuntimeDirs`. WeChat's is a different build (WXWebAssembly glue, `-t// wechat`), and handing it the web one produced either a "runtime not found"@@ -196,6 +211,11 @@ try {title: opts.title ?? project.name ?? path.basename(opts.projectDir),orientation: resolveOrientation(project),androidTemplate: platform === 'android' ? templateDir : null,+ desktopTemplates,+ desktopChannel: opts['steam-appid'] ? 'steam' : undefined,+ steam: (opts['steam-appid'] || opts['steam-sdk'])+ ? { appId: Number(opts['steam-appid']) || undefined, sdkPath: opts['steam-sdk'] }+ : undefined,iosSources: platform === 'ios' && templateDir ? iosTemplateSources(templateDir) : null,androidOutput: opts.output === 'project' ? 'project' : undefined,sizeBudgetBytes,diff --git a/desktop/src/components/SettingsDialog.tsx b/desktop/src/components/SettingsDialog.tsxindex 335fb8d78..083996dc1 100644--- a/desktop/src/components/SettingsDialog.tsx+++ b/desktop/src/components/SettingsDialog.tsx@@ -164,7 +164,11 @@ function PathControl({ setting }: { setting: PathSetting }) {}, [setting.detect]);const browse = async () => {- const picked = await window.estella?.shell?.pickProgram?.(setting.pickTitle ?? setting.label);+ const title = setting.pickTitle ?? setting.label;+ const shell = window.estella?.shell;+ const picked = setting.pick === 'directory'+ ? await shell?.pickDirectory?.(title)+ : await shell?.pickProgram?.(title);if (picked) setValue(setting.id, picked);};diff --git a/desktop/src/i18n/messages/settings.ts b/desktop/src/i18n/messages/settings.tsindex 2c83decd5..b92115597 100644--- a/desktop/src/i18n/messages/settings.ts+++ b/desktop/src/i18n/messages/settings.ts@@ -411,6 +411,19 @@ export const settingsMessages = defineMessages({zh: 'depot id 由 Valve 分配;留 0 则使用 App ID + 1、+2…,'+ '生成的 STEAM.md 会提示你去 SteamPipe → Depots 核对。',},+ 'set.project.packaging.desktop.steam.sdkPath': { en: 'Steamworks SDK', zh: 'Steamworks SDK' },+ 'set.project.packaging.desktop.steam.sdkPath.desc': {+ en: 'The Steamworks SDK you downloaded, on this machine. The package takes its '+ + 'redistributable from redistributable_bin/ — the engine ships no copy, because its '+ + 'redistribution is licensed to Steamworks partners. Without it the game still runs, '+ + 'and every achievement silently reaches nobody.',+ zh: '你自己下载的 Steamworks SDK 在本机的位置。打包时会从其 redistributable_bin/ 取那一个动态库——'+ + '引擎不随包携带(它的再分发只授权给 Steamworks 合作伙伴)。不填游戏照常跑,'+ + '但所有成就都会静默地谁也收不到。',+ },+ 'set.project.packaging.desktop.steam.sdkPath.pick': {+ en: 'Choose the Steamworks SDK directory', zh: '选择 Steamworks SDK 目录',+ },'set.project.packaging.desktop.productName': { en: 'Product name', zh: '产品名称' },'set.project.packaging.desktop.productName.desc': {en: 'Display name for the desktop app, and the name of the app itself (defaults to the project name).',diff --git a/desktop/src/project/format.ts b/desktop/src/project/format.tsindex dc7704c07..20d00f347 100644--- a/desktop/src/project/format.ts+++ b/desktop/src/project/format.ts@@ -189,6 +189,14 @@ export interface SteamPackaging {depots?: Partial<Record<'macos' | 'windows' | 'linux', number>>;/** Build description shown in the backend's build list. */description?: string;+ /**+ * A Steamworks SDK on THIS machine — the package takes its redistributable from+ * `redistributable_bin/<os>/`.+ *+ * The engine carries none: redistribution is licensed to partners and one+ * template is shared by every game (docs/REARCH_STEAM.md §5.2).+ */+ sdkPath?: string;}/** Android's slice of the app identity. `appId` is the manifest package — the@@ -619,6 +627,7 @@ export function parseManifest(raw: unknown): ProjectManifest {steam.appId = st.appId;}if (typeof st.description === 'string') steam.description = st.description;+ if (typeof st.sdkPath === 'string' && st.sdkPath.trim()) steam.sdkPath = st.sdkPath.trim();const dp = st.depots as Record<string, unknown> | undefined;if (dp && typeof dp === 'object') {const depots: NonNullable<SteamPackaging['depots']> = {};diff --git a/desktop/src/settings/projectSettings.ts b/desktop/src/settings/projectSettings.tsindex 058eea2f5..cda6686bc 100644--- a/desktop/src/settings/projectSettings.ts+++ b/desktop/src/settings/projectSettings.ts@@ -481,6 +481,23 @@ settingsRegistry.register({},});+// Where Steam's own library comes from. A path rather than a checkbox because the+// engine has no copy to switch on: the SDK is the developer's download, and the+// assembler takes exactly one file out of it.+settingsRegistry.register({+ id: 'project.packaging.desktop.steam.sdkPath',+ type: 'path', pick: 'directory',+ scope: 'project', section: 'packaging', group: t('set.group.steam'),+ label: t('set.project.packaging.desktop.steam.sdkPath'),+ description: t('set.project.packaging.desktop.steam.sdkPath.desc'),+ pickTitle: t('set.project.packaging.desktop.steam.sdkPath.pick'),+ default: '',+ bind: {+ get: () => ProjectStore.platformPackaging().desktop?.steam?.sdkPath ?? '',+ set: (v) => void ProjectStore.setSteamPackaging({ sdkPath: v.trim() || undefined }),+ },+});+// One row per OS, because Valve assigns a depot id per OS and they are rarely the// three consecutive numbers the default guesses. The generated STEAM.md prints// what this build used, next to where to check it.diff --git a/desktop/src/settings/types.ts b/desktop/src/settings/types.tsindex 9c0686a0c..c6d0c7f61 100644--- a/desktop/src/settings/types.ts+++ b/desktop/src/settings/types.ts@@ -100,6 +100,9 @@ export interface PathSetting extends BaseSetting<string> {placeholder?: string;/** Title of the picker dialog. */pickTitle?: string;+ /** What the picker selects. Default a file, because most of these name a+ * program; an SDK or a checkout is a directory. */+ pick?: 'file' | 'directory';/** Offer the code editors found installed, so the row is a choice, not a blank. */detect?: boolean;}diff --git a/desktop/tests/desktop-app.test.ts b/desktop/tests/desktop-app.test.tsindex 2e51127eb..5ff8723e1 100644--- a/desktop/tests/desktop-app.test.ts+++ b/desktop/tests/desktop-app.test.ts@@ -71,7 +71,7 @@ afterEach(() => { rmSync(dir, { recursive: true, force: true }); });describe('macOS app assembly', () => {it('produces a bundle named and executed by the app, not by the runtime', async () => {- const bundle = await assembleDesktopApp({ platform: 'macos', templateDir, contentDir, outDir, app: APP });+ const { dir: bundle } = await assembleDesktopApp({ platform: 'macos', templateDir, contentDir, outDir, app: APP });expect(bundle).toBe(path.join(outDir, 'Acme Game.app'));// The executable carries the app's name because on desktop the executable// IS the identity — the host reads its own argv[0] rather than a config.@@ -80,7 +80,7 @@ describe('macOS app assembly', () => {});it('puts the runtime bytecode in the SAME asset namespace as the game', async () => {- const bundle = await assembleDesktopApp({ platform: 'macos', templateDir, contentDir, outDir, app: APP });+ const { dir: bundle } = await assembleDesktopApp({ platform: 'macos', templateDir, contentDir, outDir, app: APP });const content = path.join(bundle, 'Contents/Resources/Content');expect(readFileSync(path.join(content, 'game.config.json'), 'utf8')).toContain('entryScene');// Beside the game's files, since that is the one path readAsset resolves.@@ -89,7 +89,7 @@ describe('macOS app assembly', () => {});it('fills the identity into Info.plist', async () => {- const bundle = await assembleDesktopApp({+ const { dir: bundle } = await assembleDesktopApp({platform: 'macos', templateDir, contentDir, outDir, app: APP, macosMin: '12.3',});const plist = readFileSync(path.join(bundle, 'Contents/Info.plist'), 'utf8');@@ -113,7 +113,7 @@ describe('macOS app assembly', () => {});it('reassembling replaces the bundle rather than merging into it', async () => {- const bundle = await assembleDesktopApp({ platform: 'macos', templateDir, contentDir, outDir, app: APP });+ const { dir: bundle } = await assembleDesktopApp({ platform: 'macos', templateDir, contentDir, outDir, app: APP });writeFileSync(path.join(bundle, 'Contents/Resources/Content/stale.txt'), 'x');await assembleDesktopApp({ platform: 'macos', templateDir, contentDir, outDir, app: APP });expect(existsSync(path.join(bundle, 'Contents/Resources/Content/stale.txt'))).toBe(false);@@ -128,7 +128,7 @@ describe('Windows assembly', () => {});it('lays the app out as a directory the depot can map whole', async () => {- const root = await assembleDesktopApp({+ const { dir: root } = await assembleDesktopApp({platform: 'windows', templateDir, contentDir, outDir, app: APP,});expect(root).toBe(path.join(outDir, 'Acme Game'));@@ -139,14 +139,14 @@ describe('Windows assembly', () => {});it('ships the HLSL compiler, without which Dawn creates no device at all', async () => {- const root = await assembleDesktopApp({+ const { dir: root } = await assembleDesktopApp({platform: 'windows', templateDir, contentDir, outDir, app: APP,});expect(existsSync(path.join(root, 'd3dcompiler_47.dll'))).toBe(true);});it('writes no Info.plist and no icns — those describe a bundle', async () => {- const root = await assembleDesktopApp({+ const { dir: root } = await assembleDesktopApp({platform: 'windows', templateDir, contentDir, outDir, app: APP,});expect(existsSync(path.join(root, 'Info.plist'))).toBe(false);@@ -160,6 +160,59 @@ describe('Windows assembly', () => {});});+describe('the store library a package carries', () => {+ /** A Steamworks SDK's shape, as far as the assembler is concerned. */+ const fakeSdk = (name: string, os: 'osx' | 'win64', file: string, body: string): string => {+ const sdk = path.join(dir, name);+ mkdirSync(path.join(sdk, 'redistributable_bin', os), { recursive: true });+ writeFileSync(path.join(sdk, 'redistributable_bin', os, file), body);+ return sdk;+ };++ it('ships it NEXT TO THE EXECUTABLE, the one place the host looks', async () => {+ // dlopen given a leaf name never searches the executable's directory, so a+ // bundle that put the dylib anywhere else would report Steam absent on+ // every machine — indistinguishable from a game that never shipped to it.+ const sdk = fakeSdk('sdk', 'osx', 'libsteam_api.dylib', 'DYLIB');+ const { dir: bundle, steamLibrary } = await assembleDesktopApp({+ platform: 'macos', templateDir, contentDir, outDir, app: APP, steamSdkDir: sdk,+ });+ expect(steamLibrary).toBe(path.join(bundle, 'Contents/MacOS/libsteam_api.dylib'));+ expect(existsSync(path.join(bundle, 'libsteam_api.dylib'))).toBe(false);+ expect(existsSync(path.join(bundle, 'Contents/Resources/libsteam_api.dylib'))).toBe(false);+ });++ it('takes the project\'s SDK over whatever the template was built with', async () => {+ // The published template carries none — CI has no Steamworks SDK and may+ // not redistribute one — so the project's is the only source that scales.+ writeFileSync(path.join(templateDir, 'libsteam_api.dylib'), 'FROM TEMPLATE');+ const sdk = fakeSdk('sdk', 'osx', 'libsteam_api.dylib', 'FROM PROJECT');+ const { steamLibrary } = await assembleDesktopApp({+ platform: 'macos', templateDir, contentDir, outDir, app: APP, steamSdkDir: sdk,+ });+ expect(readFileSync(steamLibrary!, 'utf8')).toBe('FROM PROJECT');+ });++ it('says so when the named SDK holds no redistributable', async () => {+ const warnings: string[] = [];+ const empty = path.join(dir, 'empty-sdk');+ mkdirSync(empty, { recursive: true });+ const { steamLibrary } = await assembleDesktopApp({+ platform: 'macos', templateDir, contentDir, outDir, app: APP,+ steamSdkDir: empty, warn: (m) => warnings.push(m),+ });+ expect(steamLibrary).toBeNull();+ expect(warnings.join(' ')).toMatch(/redistributable_bin/);+ });++ it('is absent, not invented, when no SDK is named', async () => {+ const { steamLibrary } = await assembleDesktopApp({+ platform: 'macos', templateDir, contentDir, outDir, app: APP,+ });+ expect(steamLibrary).toBeNull();+ });+});+describe('the icon container', () => {it('writes a slot matching the icon and a length covering the file', () => {const icns = pngToIcns(png(1024));diff --git a/desktop/tests/steam-channel.test.ts b/desktop/tests/steam-channel.test.tsindex 3ded6c82e..2c2b491f7 100644--- a/desktop/tests/steam-channel.test.ts+++ b/desktop/tests/steam-channel.test.ts@@ -74,6 +74,26 @@ describe('the Steam channel', () => {expect(text).toContain('Library/Application Support/Estella/Physics Spinner');});+ it('names the achievements to create, and says when nothing can reach Steam', async () => {+ // Both silences at once: an id the backend does not have is accepted and+ // dropped, and a package with no redistributable never gets that far.+ const { checklist } = await emitSteamBuild({+ outDir: out, appId: 480, appName: 'Spinner',+ depots: [{ os: 'windows', depotId: 481 }],+ achievements: ['FIRST_BLOOD', 'ALL_LEVELS'],+ });+ const text = readFileSync(checklist, 'utf8');+ expect(text).toContain('`FIRST_BLOOD`');+ expect(text).toContain('`ALL_LEVELS`');+ expect(text).toMatch(/carries no Steam library/);++ await emitSteamBuild({+ outDir: out, appId: 480, appName: 'Spinner',+ depots: [{ os: 'windows', depotId: 481 }], steamLibrary: true,+ });+ expect(readFileSync(checklist, 'utf8')).not.toMatch(/carries no Steam library/);+ });+it('says the depot ids are a guess, because Valve assigns them', async () => {const { checklist } = await emit();expect(readFileSync(checklist, 'utf8')).toMatch(/guess|assigns/i);diff --git a/desktop/tests/steam-settings.test.ts b/desktop/tests/steam-settings.test.tsindex 82b3d05d6..51289e9c8 100644--- a/desktop/tests/steam-settings.test.ts+++ b/desktop/tests/steam-settings.test.ts@@ -41,6 +41,14 @@ describe('the Steam packaging settings', () => {expect(setDepot({ depots: { macos: 1 } }, 'macos', undefined)).toBeUndefined();});+ it('keeps the SDK path across an App ID change, and drops a blank one', () => {+ // The SDK is where the redistributable comes from; losing it on an+ // unrelated edit turns achievements off with nothing said.+ const prev: SteamPackaging = { appId: 480, sdkPath: '/opt/steamworks_sdk' };+ expect(mergeSteam(prev, { appId: 500 })?.sdkPath).toBe('/opt/steamworks_sdk');+ expect(mergeSteam(prev, { sdkPath: undefined })).toEqual({ appId: 480 });+ });+it('a zero App ID is absence, not a game id', () => {// The settings row maps 0 to undefined; a build with appId 0 would write// scripts naming an app that is not anyone's.diff --git a/native/host/Host.hpp b/native/host/Host.hppindex aa2c48a0c..87e4ca12e 100644--- a/native/host/Host.hpp+++ b/native/host/Host.hpp@@ -141,6 +141,15 @@ struct Platform {* about a failure that happens on someone else's phone and not on yours. */virtual std::string describe() = 0;+ /**+ * The directory the executable is in, with a trailing separator — the only+ * place a shipped app's sibling libraries are looked for.+ *+ * A leaf name will not find them: `dlopen` does not search it. Empty on a+ * phone, whose loaders then report unavailable.+ */+ virtual std::string executableDir() { return {}; }+/*** Directories a PLAYER can browse to, best first — where a crash record is* copied so it can be sent.diff --git a/native/host/bindings/SteamBindings.cpp b/native/host/bindings/SteamBindings.cppindex c10f6336b..c4deb213b 100644--- a/native/host/bindings/SteamBindings.cpp+++ b/native/host/bindings/SteamBindings.cpp@@ -24,7 +24,10 @@ namespace {JSValue js_steam_init(JSContext* ctx, JSValueConst, int argc, JSValueConst* argv) {int32_t appId = 0;if (argc < 1 || JS_ToInt32(ctx, &appId, argv[0]) < 0 || appId <= 0) return JS_NewBool(ctx, false);- const bool ok = steam().init(static_cast<uint32_t>(appId));+ // The platform says where the redistributable was shipped. A leaf name would+ // do on Windows and silently never resolve on macOS (see SteamApi::init).+ const std::string dir = host().platform ? host().platform->executableDir() : std::string();+ const bool ok = steam().init(static_cast<uint32_t>(appId), dir);if (!ok && !steam().lastError().empty()) {// Not an error: no client, signed out, or a build that does not ship to// Steam. It reaches the boot record so "achievements did nothing" has andiff --git a/native/host/platform/desktop.cpp b/native/host/platform/desktop.cppindex 791dd6b62..800ea54fa 100644--- a/native/host/platform/desktop.cpp+++ b/native/host/platform/desktop.cpp@@ -105,6 +105,8 @@ struct DesktopPlatform final : eshost::Platform {std::string contentRoot;/** SDL_GetPrefPath's directory, kept because every call allocates. */std::string prefPath;+ /** The directory holding this binary — see resolveExecutableDir. */+ std::string exeDir;// Loose files in a directory, not an APK's assets or a bundle: that is what a// depot ships and what an export already is, so packaging copies rather than@@ -126,6 +128,8 @@ struct DesktopPlatform final : eshost::Platform {std::string dataDir() override { return prefPath; }+ std::string executableDir() override { return exeDir; }+/** The same directory: on desktop the player can open it, which is the whole* reason the mobile platforms distinguish a log dir from a private one. */std::string logDir() override { return prefPath; }@@ -259,6 +263,23 @@ std::string resolveContentRoot(int argc, char** argv) {return readFileBytes(content + "game.config.json").empty() ? std::string(base) : content;}+/**+ * The directory this binary is in, with a trailing separator.+ *+ * From argv[0]: SDL_GetBasePath answers `Contents/Resources/` inside a macOS+ * bundle, which holds the game's FILES and not its libraries. Falls back to it+ * when argv[0] carries no directory.+ */+std::string resolveExecutableDir(int argc, char** argv) {+ if (argc > 0 && argv[0] && argv[0][0]) {+ const std::string path = argv[0];+ const size_t slash = path.find_last_of("/\\");+ if (slash != std::string::npos) return path.substr(0, slash + 1);+ }+ const char* base = SDL_GetBasePath();+ return base ? std::string(base) : std::string();+}+/** The app's name, for the window and for the saves directory.** From the executable, which on desktop IS the identity the assembler set.@@ -287,6 +308,7 @@ int main(int argc, char** argv) {const std::string name = appName(argc, argv);g_platform.contentRoot = resolveContentRoot(argc, argv);+ g_platform.exeDir = resolveExecutableDir(argc, argv);// The directory a store's cloud save syncs. Its shape per OS is written down a// second time in build-tools/utils/steamChannel.js (CLOUD_ROOTS), because the// backend has to be told it in its own words — change one and change that.diff --git a/native/host/steam/SteamApi.cpp b/native/host/steam/SteamApi.cppindex 4435faa1e..e0255ef54 100644--- a/native/host/steam/SteamApi.cpp+++ b/native/host/steam/SteamApi.cpp@@ -133,14 +133,21 @@ SteamApi& steam() {return instance;}-bool SteamApi::init(std::uint32_t appId) {+bool SteamApi::init(std::uint32_t appId, const std::string& directory) {if (library_) return available();error_.clear();- library_ = openLibrary(kSteamLibrary);+ if (directory.empty()) {+ error_ = "this host does not know where its own libraries are";+ return false;+ }+ const std::string libraryPath = directory + kSteamLibrary;+ library_ = openLibrary(libraryPath.c_str());if (!library_) {// Ordinary: a build that does not ship to Steam has no reason to carry it.- error_ = std::string(kSteamLibrary) + " is not beside the executable";+ // The PATH is named, not the leaf: "it is not there" and "it is there and+ // the loader looked somewhere else" read identically otherwise.+ error_ = libraryPath + " is not there";return false;}diff --git a/native/host/steam/SteamApi.hpp b/native/host/steam/SteamApi.hppindex cad0839e3..cad7532fd 100644--- a/native/host/steam/SteamApi.hpp+++ b/native/host/steam/SteamApi.hpp@@ -38,13 +38,19 @@ namespace eshost {class SteamApi {public:/**- * Load the library beside the executable and initialise.+ * Load the library out of @p directory and initialise.*- * @param appId The Steam application id, for the ownership check.+ * The directory is required, not assumed: `dlopen` given a leaf name never+ * looks beside the executable, so a macOS app shipping the redistributable+ * next to its binary would report Steam absent forever.+ *+ * @param appId The Steam application id, for the ownership check.+ * @param directory Where the redistributable was shipped, with a trailing+ * separator. Empty ⇒ nothing to load.* @returns false when there is no library, no running client, or no session —* all of which are ordinary, and none of which is an error.*/- bool init(std::uint32_t appId);+ bool init(std::uint32_t appId, const std::string& directory);void shutdown();/** Whether a Steam session is behind this. Everything below is a no-op