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
feat(build): the desktop runtime template
esenginebdc30d15c106
diff --git a/build-tools/tasks/nativeTemplateEmit.js b/build-tools/tasks/nativeTemplateEmit.jsindex 1ce6293ab..a3f2b26fd 100644--- a/build-tools/tasks/nativeTemplateEmit.js+++ b/build-tools/tasks/nativeTemplateEmit.js@@ -180,7 +180,14 @@ export async function emitNativeTemplate(options) {throw new Error(`Cannot emit the ${platform} template: ${entry.rel} is missing at ${src ?? '<unset>'}.`);}await mkdir(path.dirname(dest), { recursive: true });- if (entry.strip) {+ if (entry.strip && platform === 'macos') {+ // `strip` happens to re-sign today, but an arm64 binary whose+ // signature does not match its bytes is KILLED at launch — too much to+ // leave to a side effect.+ await cp(src, dest);+ await runCommand('strip', ['-x', dest]);+ await runCommand('codesign', ['--force', '--sign', '-', dest]);+ } else if (entry.strip) {await runCommand(ndkTool(options.ndk, 'llvm-strip'), ['--strip-all', '-o', dest, src]);} else {await cp(src, dest, { recursive: entry.kind === 'dir' });diff --git a/build-tools/utils/nativeTemplate.js b/build-tools/utils/nativeTemplate.jsindex 5ccef14f2..4aaeacc2b 100644--- a/build-tools/utils/nativeTemplate.js+++ b/build-tools/utils/nativeTemplate.js@@ -70,7 +70,7 @@ export const ANDROID_ABIS = ['arm64-v8a', 'x86_64'];* whose debug info an app does not need — the host's is most of its size, and* shipping it unstripped also broke installing onto a clean device.*- * @param {'android'|'ios'} platform+ * @param {'android'|'ios'|'macos'} platform* @param {{abis?: readonly string[]}} [options] Android ABIs to describe.*/export function templateLayout(platform, options = {}) {@@ -95,6 +95,29 @@ export function templateLayout(platform, options = {}) {},];}+ if (platform === 'macos') {+ // The shortest layout of the three, because a desktop build embeds+ // everything: Dawn and SDL are linked statically, so the runtime is one+ // executable and there is no second file to find at run time.+ return [+ {+ rel: 'estella_desktop', strip: true,+ from: (ctx) => path.join(ctx.root, 'build/cmake/native-macos', 'estella_desktop'),+ },+ // Beside the game's own files, not in a directory of its own: the host+ // reads it through Platform::readAsset, which is one namespace — the+ // same one the APK's assets/ is.+ {+ rel: BYTECODE_FILE, optional: true, releaseRequired: true,+ from: (ctx) => path.join(ctx.root, 'build/cmake/native-macos', 'gen', BYTECODE_FILE),+ },+ {+ rel: 'Info.plist.in',+ from: (ctx) => path.join(ctx.root, 'native', 'desktop', 'Info.plist.in'),+ },+ { rel: DEFAULT_ICON, from: (ctx) => path.join(ctx.root, 'native', 'icon.png') },+ ];+ }if (platform === 'android') {// Every ABI the build machine produced. Only the first is required: one// architecture is a working template, two is one package that installs on a@@ -144,7 +167,7 @@ export function templateLayout(platform, options = {}) {{ rel: DEFAULT_ICON, from: (ctx) => path.join(ctx.root, 'native', 'icon.png') },];}- throw new Error(`Unknown native platform "${platform}" (expected android or ios).`);+ throw new Error(`Unknown native platform "${platform}" (expected android, ios or macos).`);}/**@@ -394,3 +417,14 @@ export function iosTemplateSources(dir) {bytecode: path.join(dir, 'assets', BYTECODE_FILE),};}++/** The desktop equivalent — the runtime binary and the three files the assembler+ * composes an app bundle from. */+export function desktopTemplateSources(dir) {+ return {+ executable: path.join(dir, 'estella_desktop'),+ infoPlistIn: path.join(dir, 'Info.plist.in'),+ icon: path.join(dir, DEFAULT_ICON),+ bytecode: path.join(dir, BYTECODE_FILE),+ };+}diff --git a/native/desktop/Info.plist.in b/native/desktop/Info.plist.innew file mode 100644index 000000000..987b98c59--- /dev/null+++ b/native/desktop/Info.plist.in@@ -0,0 +1,41 @@+<?xml version="1.0" encoding="UTF-8"?>+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">+<!--+ The macOS app bundle's Info.plist, as a template. The desktop assembler+ substitutes the identity from the exported project's app.config.json, exactly as+ the iOS one and the Android manifest are filled in.++ What is NOT substituted is the host's own requirements: high-resolution drawing+ (without it AppKit hands a retina display a 1x backing store and the whole game+ is soft), and the minimum system the arm64 binary claims.+-->+<plist version="1.0">+<dict>+ <key>CFBundleDevelopmentRegion</key>+ <string>en</string>+ <key>CFBundleExecutable</key>+ <string>@APP_NAME@</string>+ <key>CFBundleIdentifier</key>+ <string>@APP_ID@</string>+ <key>CFBundleInfoDictionaryVersion</key>+ <string>6.0</string>+ <key>CFBundleName</key>+ <string>@APP_NAME@</string>+ <key>CFBundleDisplayName</key>+ <string>@APP_NAME@</string>+ <key>CFBundlePackageType</key>+ <string>APPL</string>+ <key>CFBundleShortVersionString</key>+ <string>@VERSION_NAME@</string>+ <key>CFBundleVersion</key>+ <string>@VERSION_CODE@</string>+ <key>CFBundleIconFile</key>+ <string>AppIcon</string>+ <key>LSMinimumSystemVersion</key>+ <string>@MACOS_MIN@</string>+ <key>NSHighResolutionCapable</key>+ <true/>+ <key>NSSupportsAutomaticGraphicsSwitching</key>+ <true/>+</dict>+</plist>