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.

refactor(native): one runtime template per platform, not per architecture

esenginef2f95d23b261
diff --git a/.github/workflows/release-desktop.yml b/.github/workflows/release-desktop.yml
index 6f4dbde80..61f9618f0 100644
--- a/.github/workflows/release-desktop.yml
+++ b/.github/workflows/release-desktop.yml
@@ -155,11 +155,16 @@ jobs:
node build-tools/cli.js native --target ios --simulator --no-template
node build-tools/cli.js native --target ios --template-out artifacts
- - name: Build the Android template
+ # Both architectures into ONE template: arm64 is every real device, x86_64 is
+ # the emulator — which is how anyone without a phone tries the game at all.
+ # The emitter keeps the architecture the previous run built.
+ - name: Build the Android template (arm64 + x86_64)
if: matrix.name == 'android'
env:
ANDROID_NDK_HOME: ${{ steps.ndk.outputs.ndk-path }}
- run: node build-tools/cli.js native --template-out artifacts
+ run: |
+ node build-tools/cli.js native --abi arm64-v8a
+ node build-tools/cli.js native --abi x86_64 --template-out artifacts
- name: Upload template artifact
uses: actions/upload-artifact@v7
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 74abca857..86be39941 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -16,6 +16,12 @@ published separately; it ships inside the editor.
### Added
+- **One package installs on a phone AND in an emulator.** A runtime template is
+ now one artifact per PLATFORM rather than one per architecture — iOS already
+ worked that way, with both slices inside one xcframework — so the Android
+ template carries `arm64-v8a` and `x86_64` together and every package it
+ assembles offers both. Nothing to choose, and no second template the editor
+ would never ask for.
- **iOS: the first launch after an install is as fast as the rest.** The runtime
template now carries the SDK's precompiled bytecode on iOS as it already did on
Android, and the export ships it as a bundle resource — so the host reads the
diff --git a/build-tools/tasks/native.js b/build-tools/tasks/native.js
index cc4884752..3aef38765 100644
--- a/build-tools/tasks/native.js
+++ b/build-tools/tasks/native.js
@@ -16,9 +16,9 @@ import * as logger from '../utils/logger.js';
import { runCommand, getCpuCount, resolvePython } from '../utils/emscripten.js';
import { requireSdk, requireNdk, sdkCmake } from '../utils/android.js';
import { emitNativeTemplate, writeTemplateIndex, readEngineVersion } from './nativeTemplateEmit.js';
-import { fetchNativeDeps, pinnedDep, ensureDawnBuild } from './nativeDeps.js';
+import { fetchNativeDeps, pinnedDep, ensureDawnBuild, dawnLibrary, DAWN_TARGETS } from './nativeDeps.js';
import {
- BYTECODE_FILE, DEFAULT_ABI, findTemplate, iosTemplateSources, templateStoreDir,
+ BYTECODE_FILE, findTemplate, iosTemplateSources, templateStoreDir,
} from '../utils/nativeTemplate.js';
import { readAppConfig, fillTemplate, iosInterfaceOrientations } from '../utils/nativeApp.js';
import { emitIosXcodeProject } from '../utils/iosProject.js';
@@ -282,14 +282,18 @@ async function buildAndroidHost(options) {
const { cmake, ninja } = sdkCmake(sdk);
const { dawnDir, dawnBuild } = await dawnPaths(options, 'android', { ndk, cmake, ninja });
- const buildDir = path.join(rootDir, 'build-native');
+ // One build tree per ABI, beside the generated sources they share — a second
+ // architecture must not overwrite the first one's objects.
+ const buildDir = path.join(rootDir, 'build-native', abi);
await mkdir(buildDir, { recursive: true });
// JS host (opt-in): pass --quickjs <dir> (or ESTELLA_QUICKJS_DIR) to also build
// the QuickJS host — a game script driving the engine through the generated
// bindings + the real SDK ptrAccessors.
const quickjs = quickjsDir(options);
- const genDir = quickjs ? await prepareGenerated(rootDir, buildDir, quickjs) : null;
+ // The generated sources are the same for every ABI (bindings, the SDK bundle,
+ // its bytecode), so they live once beside the per-ABI trees.
+ const genDir = quickjs ? await prepareGenerated(rootDir, path.join(rootDir, 'build-native'), quickjs) : null;
logger.step(`Configuring native host (${abi}, ${platform})...`);
const configureArgs = [
@@ -317,14 +321,15 @@ async function buildAndroidHost(options) {
logger.step('Building native host...');
await runCommand(cmake, ['--build', buildDir, '-j', String(getCpuCount())], { cwd: rootDir });
- logger.success(`Host: ${path.join('build-native', 'libestella_js_host.so')}`);
+ logger.success(`Host: ${path.join('build-native', abi, 'libestella_js_host.so')}`);
// The binaries this machine just produced are the same for every game, so they
// are packed for everyone else's — see build-tools/utils/nativeTemplate.js. Only
// the JS host is one: the pure-C++ reference host is not what a game ships on.
if (quickjs && options.template !== false) {
await emitNativeTemplate({
- platform: 'android', abi, root: rootDir, dawnBuild, ndk, sdk,
+ platform: 'android', abis: [abi], root: rootDir, ndk, sdk,
+ dawnLibrary: (want) => (want === abi ? dawnLibrary(dawnBuild, 'android') : null),
androidPlatform: platform, jdk: options.jdk, zipTo: options.templateOut,
});
}
@@ -517,9 +522,9 @@ function packagedContent(options) {
}
/** The installed runtime template for @p platform, or a message naming how to get one. */
-function requireTemplate(platform, abi) {
+function requireTemplate(platform) {
const engineVersion = readEngineVersion(config.paths.root);
- const template = findTemplate({ platform, engineVersion, abi });
+ const template = findTemplate({ platform, engineVersion });
if (!template || template.missing.length > 0) {
throw new Error(`No ${platform} runtime template for v${engineVersion}. Build one with `
+ `\`cli native --target ${platform}\`, or install a release archive into `
@@ -533,8 +538,7 @@ function requireTemplate(platform, abi) {
* with no Android SDK involved. The same call the editor's export makes.
*/
async function packageAndroidApk(options) {
- const abi = options.abi || DEFAULT_ABI.android;
- const template = requireTemplate('android', abi);
+ const template = requireTemplate('android');
const contentDir = packagedContent(options);
const app = readAppConfig(contentDir, (m) => logger.warn(m));
@@ -543,7 +547,7 @@ async function packageAndroidApk(options) {
: debugSigningKey();
if (!options.key) logger.info('Signing with the development key (sideload only — not for a store).');
- const assembly = { templateDir: template.dir, contentDir, app, abi, key };
+ const assembly = { templateDir: template.dir, contentDir, app, key };
logger.step('Assembling the APK...');
const apk = assembleApk(assembly);
const out = path.join(contentDir, apkFileName(app.id));
@@ -591,9 +595,11 @@ async function emitFromExistingBuild(target, options) {
});
}
const sdk = requireSdk();
+ const dawnBuild = options.dawnBuild || process.env.ESTELLA_DAWN_BUILD;
+ const abi = options.abi || 'arm64-v8a';
return emitNativeTemplate({
- platform: 'android', abi: options.abi, root: rootDir,
- dawnBuild: options.dawnBuild || process.env.ESTELLA_DAWN_BUILD,
+ platform: 'android', abis: [abi], root: rootDir,
+ dawnLibrary: (want) => (want === abi && dawnBuild ? dawnLibrary(dawnBuild, 'android') : null),
ndk: requireNdk(sdk), sdk, androidPlatform: options.platform, jdk: options.jdk,
zipTo: options.templateOut,
});
diff --git a/build-tools/tasks/nativeDeps.js b/build-tools/tasks/nativeDeps.js
index 96e837173..bf197606a 100644
--- a/build-tools/tasks/nativeDeps.js
+++ b/build-tools/tasks/nativeDeps.js
@@ -107,6 +107,14 @@ export function dawnLibrary(dawnBuild, target) {
return path.join(dawnBuild, 'src', 'dawn', 'native', name);
}
+/** Dawn's build directory for a target. Android's is per-ABI — an emulator build
+ * and a device build are different binaries — with the default ABI keeping the
+ * plain name a checkout may already have. */
+export function dawnBuildDir(dawn, target, abi) {
+ const suffix = target === 'android' && abi && abi !== 'arm64-v8a' ? `-${abi}` : '';
+ return path.join(dawn, DAWN_TARGETS[target].out + suffix);
+}
+
/**
* Build Dawn for @p target if it is not built already.
*
@@ -116,7 +124,7 @@ export function dawnLibrary(dawnBuild, target) {
export async function ensureDawnBuild(options) {
const target = DAWN_TARGETS[options.target];
if (!target) throw new Error(`Unknown Dawn target ${options.target}.`);
- const buildDir = options.buildDir || path.join(options.dawn, target.out);
+ const buildDir = options.buildDir || dawnBuildDir(options.dawn, options.target, options.abi);
if (existsSync(dawnLibrary(buildDir, options.target))) return buildDir;
const cmake = options.cmake || 'cmake';
diff --git a/build-tools/tasks/nativeTemplateEmit.js b/build-tools/tasks/nativeTemplateEmit.js
index ef5591e7e..0dd9fbdad 100644
--- a/build-tools/tasks/nativeTemplateEmit.js
+++ b/build-tools/tasks/nativeTemplateEmit.js
@@ -19,8 +19,8 @@ import { runCommand } from '../utils/emscripten.js';
import { buildTool, platformJar, ndkTool, ndkLibcxxShared, jdkTool } from '../utils/android.js';
import { makeZip, zipTree } from '../utils/zip.js';
import {
- templateLayout, templateId, DEFAULT_ABI, writeTemplateManifest, missingTemplateFiles,
- installedTemplateDir, templateZipName, TEMPLATE_INDEX, TEMPLATE_FORMAT,
+ templateLayout, templateId, ANDROID_ABIS, templateAbis, writeTemplateManifest,
+ missingTemplateFiles, installedTemplateDir, templateZipName, TEMPLATE_INDEX, TEMPLATE_FORMAT,
} from '../utils/nativeTemplate.js';
/** The Java shim's sources — the IME's own side of an editable field, which has to
@@ -100,11 +100,9 @@ export async function writeTemplateIndex(dir, options = {}) {
const templates = archives.map((file) => {
const bytes = readFileSync(path.join(dir, file));
const id = file.slice('estella-native-'.length, -suffix.length);
- const dash = id.indexOf('-');
return {
id,
- platform: id.slice(0, dash),
- abi: id.slice(dash + 1),
+ platform: id,
file,
bytes: bytes.length,
sha256: createHash('sha256').update(bytes).digest('hex'),
@@ -127,8 +125,8 @@ export async function writeTemplateIndex(dir, options = {}) {
*
* @param {object} options
* @param {'android'|'ios'} options.platform
- * @param {string} [options.abi]
- * @param {string} [options.dawnBuild] Android: the Dawn build whose .so ships.
+ * @param {(abi: string) => string|null} [options.dawnLibrary] Android: where each
+ * ABI's Dawn library is, if it was built.
* @param {string} [options.ndk] Android: for llvm-strip and libc++_shared.
* @param {string} [options.sdk] Android: for d8 (the Java shim).
* @param {string} [options.outDir] Defaults to this machine's template store.
@@ -138,30 +136,45 @@ export async function writeTemplateIndex(dir, options = {}) {
export async function emitNativeTemplate(options) {
const root = options.root || config.paths.root;
const platform = options.platform;
- const abi = options.abi || DEFAULT_ABI[platform];
const engineVersion = readEngineVersion(root);
- const dir = options.outDir || installedTemplateDir(engineVersion, platform, abi);
+ const dir = options.outDir || installedTemplateDir(engineVersion, platform);
const ctx = {
root,
- dawnBuild: options.dawnBuild,
- libcxxShared: platform === 'android' && options.ndk
- ? ndkLibcxxShared(options.ndk, ABI_TRIPLE[abi] || ABI_TRIPLE['arm64-v8a'])
- : null,
+ dawnLibrary: options.dawnLibrary,
+ libcxxShared: (abi) => (platform === 'android' && options.ndk && ABI_TRIPLE[abi]
+ ? ndkLibcxxShared(options.ndk, ABI_TRIPLE[abi]) : null),
};
- // Rewritten wholesale: a template that inherited one file from the previous
- // release is the exact failure the version stamp exists to prevent.
+ // What the previous emit left, so an ABI built on an earlier run survives one
+ // that only rebuilt another — and nothing else does. A template that inherited
+ // a file from the previous RELEASE is the failure the version stamp prevents;
+ // one that keeps an architecture from an hour ago is the point.
+ const kept = platform === 'android' && existsSync(dir)
+ ? templateAbis(dir).filter((abi) => !options.abis || !options.abis.includes(abi))
+ : [];
+ const carry = kept.map((abi) => ({ abi, files: templateLayout('android', { abis: [abi] })
+ .filter((e) => e.abi === abi)
+ .map((e) => ({ rel: e.rel, data: readFileSync(path.join(dir, e.rel)) })) }));
+
await rm(dir, { recursive: true, force: true });
await mkdir(dir, { recursive: true });
+ for (const { files } of carry) {
+ for (const file of files) {
+ await mkdir(path.dirname(path.join(dir, file.rel)), { recursive: true });
+ writeFileSync(path.join(dir, file.rel), file.data);
+ }
+ }
- for (const entry of templateLayout(platform, { abi })) {
+ for (const entry of templateLayout(platform, { abis: options.abis })) {
if (entry.produced) continue;
const src = entry.from(ctx);
const dest = path.join(dir, entry.rel);
if (!src || !existsSync(src)) {
if (entry.optional) {
- logger.warn(`Template omits ${entry.rel} (not built): ${src ?? 'no source'}`);
+ if (!kept.includes(entry.abi)) {
+ logger.warn(`Template omits ${entry.rel} (not built): ${src ?? 'no source'}`);
+ }
continue;
}
throw new Error(`Cannot emit the ${platform} template: ${entry.rel} is missing at ${src ?? '<unset>'}.`);
@@ -183,14 +196,15 @@ export async function emitNativeTemplate(options) {
const manifest = writeTemplateManifest(dir, {
platform,
- abi,
engineVersion,
spineVersion: options.spineVersion || '4.2',
...(platform === 'ios' ? { deploymentTarget: options.deploymentTarget || '17.0' } : {}),
- ...(platform === 'android' ? { androidPlatform: options.androidPlatform || 'android-33' } : {}),
+ ...(platform === 'android'
+ ? { androidPlatform: options.androidPlatform || 'android-33', abis: templateAbis(dir) }
+ : {}),
});
- const missing = missingTemplateFiles(dir, platform, { abi });
+ const missing = missingTemplateFiles(dir, platform);
if (missing.length) throw new Error(`Emitted template is incomplete: ${missing.join(', ')}`);
logger.success(`Runtime template: ${dir}`);
@@ -198,10 +212,11 @@ export async function emitNativeTemplate(options) {
let zip = null;
if (options.zipTo) {
await mkdir(options.zipTo, { recursive: true });
- zip = path.join(options.zipTo, templateZipName(platform, abi, engineVersion));
+ zip = path.join(options.zipTo, templateZipName(platform, engineVersion));
writeFileSync(zip, makeZip(zipTree(dir)));
logger.success(`Template archive: ${zip} (${(readFileSync(zip).length / 1048576).toFixed(1)} MB)`);
}
- logger.info(`The editor picks it up as ${templateId(platform, abi)} for v${engineVersion}.`);
+ logger.info(`The editor picks it up as ${templateId(platform)} for v${engineVersion}`
+ + `${manifest.abis ? ` (${manifest.abis.join(', ')})` : ''}.`);
return { dir, manifest, zip };
}
diff --git a/build-tools/utils/aab.d.ts b/build-tools/utils/aab.d.ts
index e9c56df7c..6d6e25b1c 100644
--- a/build-tools/utils/aab.d.ts
+++ b/build-tools/utils/aab.d.ts
@@ -14,7 +14,6 @@ export function assembleAab(options: {
contentDir: string;
app: ApkAppIdentity;
key: SigningKey;
- abi: string;
}): Buffer;
export function aabFileName(appId: string): string;
diff --git a/build-tools/utils/aab.js b/build-tools/utils/aab.js
index c8f7ec341..4fd5ed663 100644
--- a/build-tools/utils/aab.js
+++ b/build-tools/utils/aab.js
@@ -23,7 +23,7 @@ import { packageEntries } from './apk.js';
import { message, bytesField } from './protobuf.js';
import { compileProtoManifest } from './androidProtoXml.js';
import { appResources } from './androidResources.js';
-import { DEFAULT_ICON } from './nativeTemplate.js';
+import { DEFAULT_ICON, templateAbis } from './nativeTemplate.js';
import { jarSignatureFiles } from './jarSign.js';
import { fillTemplate, androidScreenOrientation } from './nativeApp.js';
@@ -47,7 +47,7 @@ function bundleConfig() {
* @returns {Buffer} the signed bundle.
*/
export function assembleAab(options) {
- const { templateDir, contentDir, app, abi } = options;
+ const { templateDir, contentDir, app } = options;
const dex = path.join(templateDir, 'classes.dex');
const hasDex = existsSync(dex);
const resources = appResources(options.icon ?? readFileSync(path.join(templateDir, DEFAULT_ICON)));
@@ -62,8 +62,10 @@ export function assembleAab(options) {
HAS_CODE: hasDex ? 'true' : 'false',
}), resources.references);
- const libDir = path.join(templateDir, 'lib', abi);
- if (!existsSync(libDir)) throw new Error(`The runtime template has no lib/${abi}.`);
+ // Every architecture: Play splits the bundle per device, which is what the
+ // format is for.
+ const abis = templateAbis(templateDir);
+ if (abis.length === 0) throw new Error('The runtime template carries no native libraries.');
const templateAssets = path.join(templateDir, 'assets');
const entries = [
@@ -72,7 +74,7 @@ export function assembleAab(options) {
{ name: 'base/resources.pb', data: resources.pb },
...resources.files.map((f) => ({ ...f, name: `base/${f.name}` })),
...(hasDex ? [{ name: 'base/dex/classes.dex', data: readFileSync(dex) }] : []),
- ...packageEntries(libDir, `base/lib/${abi}`),
+ ...abis.flatMap((abi) => packageEntries(path.join(templateDir, 'lib', abi), `base/lib/${abi}`)),
...(existsSync(templateAssets) ? packageEntries(templateAssets, 'base/assets') : []),
...packageEntries(contentDir, 'base/assets'),
];
diff --git a/build-tools/utils/apk.d.ts b/build-tools/utils/apk.d.ts
index 166d1bb59..c5ac761b9 100644
--- a/build-tools/utils/apk.d.ts
+++ b/build-tools/utils/apk.d.ts
@@ -21,7 +21,6 @@ export function assembleApk(options: {
contentDir: string;
app: ApkAppIdentity;
key: SigningKey;
- abi: string;
}): Buffer;
export function signApkV2(zip: Buffer, key: SigningKey): Buffer;
diff --git a/build-tools/utils/apk.js b/build-tools/utils/apk.js
index e4ff017e4..29447266a 100644
--- a/build-tools/utils/apk.js
+++ b/build-tools/utils/apk.js
@@ -21,7 +21,7 @@ import { existsSync, readFileSync, readdirSync } from 'fs';
import { makeZip, zipLayout } from './zip.js';
import { compileManifest } from './androidBinaryXml.js';
import { appResources } from './androidResources.js';
-import { DEFAULT_ICON } from './nativeTemplate.js';
+import { DEFAULT_ICON, templateAbis } from './nativeTemplate.js';
import { fillTemplate, androidScreenOrientation } from './nativeApp.js';
/** The boundary a mapped `.so` must start on — a 16 KiB page, which every
@@ -138,12 +138,11 @@ export function packageEntries(dir, prefix) {
* @param {{id: string, name: string, version: string, versionCode: number,
* orientation: 'landscape'|'portrait'}} options.app
* @param {{privateKey: import('crypto').KeyObject, certificate: Buffer}} options.key
- * @param {string} options.abi
* @param {Buffer} [options.icon] The launcher icon; the template's default when absent.
* @returns {Buffer} the signed package.
*/
export function assembleApk(options) {
- const { templateDir, contentDir, app, abi } = options;
+ const { templateDir, contentDir, app } = options;
const dex = path.join(templateDir, 'classes.dex');
const hasDex = existsSync(dex);
const resources = appResources(options.icon ?? readFileSync(path.join(templateDir, DEFAULT_ICON)));
@@ -158,8 +157,10 @@ export function assembleApk(options) {
HAS_CODE: hasDex ? 'true' : 'false',
}), resources.references);
- const libDir = path.join(templateDir, 'lib', abi);
- if (!existsSync(libDir)) throw new Error(`The runtime template has no lib/${abi}.`);
+ // Every architecture the template carries, so one package installs on a phone
+ // and in an emulator alike — the device picks the one it can run.
+ const abis = templateAbis(templateDir);
+ if (abis.length === 0) throw new Error('The runtime template carries no native libraries.');
const templateAssets = path.join(templateDir, 'assets');
const entries = [
@@ -168,7 +169,8 @@ export function assembleApk(options) {
{ name: 'resources.arsc', data: resources.arsc, store: true, align: 4 },
...resources.files,
...(hasDex ? [{ name: 'classes.dex', data: readFileSync(dex) }] : []),
- ...packageEntries(libDir, `lib/${abi}`).map((e) => ({ ...e, store: true, align: PAGE_ALIGNMENT })),
+ ...abis.flatMap((abi) => packageEntries(path.join(templateDir, 'lib', abi), `lib/${abi}`)
+ .map((e) => ({ ...e, store: true, align: PAGE_ALIGNMENT }))),
// The template's assets (the SDK bytecode) first, so a project cannot
// shadow them by accident and quietly change what the host boots.
...(existsSync(templateAssets) ? packageEntries(templateAssets, 'assets') : []),
diff --git a/build-tools/utils/nativeTemplate.d.ts b/build-tools/utils/nativeTemplate.d.ts
index bfda3c982..35153fab0 100644
--- a/build-tools/utils/nativeTemplate.d.ts
+++ b/build-tools/utils/nativeTemplate.d.ts
@@ -11,7 +11,8 @@ export interface NativeTemplateManifest {
formatVersion: number;
id: string;
platform: NativePlatform;
- abi: string;
+ /** Android only: the architectures this template carries. */
+ abis?: string[];
/** Matched EXACTLY against the editor's version: the SDK bundle is compiled
* into the host binary, so a near-miss fails on a device. */
engineVersion: string;
@@ -25,7 +26,6 @@ export interface NativeTemplateManifest {
export interface TemplateWant {
platform: NativePlatform;
engineVersion: string;
- abi?: string;
}
export interface FoundTemplate {
@@ -38,33 +38,35 @@ export interface FoundTemplate {
export const TEMPLATE_FORMAT: number;
export const TEMPLATE_MANIFEST: string;
export const BYTECODE_FILE: string;
-export const DEFAULT_ABI: Readonly<Record<NativePlatform, string>>;
+export const ANDROID_ABIS: readonly string[];
-export function templateId(platform: NativePlatform, abi: string): string;
+export function templateId(platform: NativePlatform): string;
+export function templateAbis(dir: string): string[];
export interface TemplateEntry {
/** Path inside the template. */
rel: string;
+ /** Android: which architecture this file belongs to. */
+ abi?: string;
kind?: 'dir';
optional?: boolean;
/** Produced by the emitter rather than copied (the Java shim's dex). */
produced?: boolean;
}
-export function templateLayout(platform: NativePlatform, options?: { abi?: string }): TemplateEntry[];
-export function requiredTemplateFiles(platform: NativePlatform, options?: { abi?: string }): string[];
-export function missingTemplateFiles(dir: string, platform: NativePlatform, options?: { abi?: string }): string[];
+export function templateLayout(platform: NativePlatform, options?: { abis?: readonly string[] }): TemplateEntry[];
+export function requiredTemplateFiles(platform: NativePlatform, options?: { abis?: readonly string[] }): string[];
+export function missingTemplateFiles(dir: string, platform: NativePlatform, options?: { abis?: readonly string[] }): string[];
export function readTemplateManifest(dir: string): NativeTemplateManifest | null;
export function templateMatches(manifest: NativeTemplateManifest | null, want: TemplateWant): boolean;
-export function templateZipName(platform: NativePlatform, abi: string, engineVersion: string): string;
+export function templateZipName(platform: NativePlatform, engineVersion: string): string;
export function estellaDataDir(): string;
export function templateStoreDir(): string;
export function installedTemplateDir(
- engineVersion: string, platform: NativePlatform, abi: string, storeDir?: string): string;
+ engineVersion: string, platform: NativePlatform, storeDir?: string): string;
export function findTemplate(want: TemplateWant, storeDir?: string): FoundTemplate | null;
export interface PublishedTemplate {
id: string;
platform: NativePlatform;
- abi: string;
/** Archive filename, resolved against the release's asset base. */
file: string;
bytes: number;
diff --git a/build-tools/utils/nativeTemplate.js b/build-tools/utils/nativeTemplate.js
index d4a4e5dd0..0f2f3ebef 100644
--- a/build-tools/utils/nativeTemplate.js
+++ b/build-tools/utils/nativeTemplate.js
@@ -38,14 +38,29 @@ export const BYTECODE_FILE = 'esengine.native.qjsbc';
*/
export const DEFAULT_ICON = 'icon.png';
-/** A template's id: one per thing that must be compiled separately. */
-export function templateId(platform, abi) {
- return `${platform}-${abi}`;
+/**
+ * A template's id: ONE per platform.
+ *
+ * Not per architecture. A platform's template carries every architecture that
+ * platform needs — iOS already did, with the device and simulator slices inside
+ * one xcframework — so naming an architecture in the id would make a second
+ * architecture a second artifact the editor never asks for. Architectures are
+ * data inside a template, not an axis of them.
+ */
+export function templateId(platform) {
+ return platform;
}
-/** The default ABI a platform's template carries. iOS ships both slices inside
- * one xcframework, so its id names the device architecture only. */
-export const DEFAULT_ABI = { android: 'arm64-v8a', ios: 'arm64' };
+/**
+ * The Android ABIs a template can carry, in the order a package lists them.
+ * `arm64-v8a` is every real device; `x86_64` is the emulator, which is how anyone
+ * without a phone tries the game at all.
+ *
+ * The FIRST is required — a template with no device ABI packages nothing — and the
+ * rest are optional, so a build machine that only did one still produces a usable
+ * template.
+ */
+export const ANDROID_ABIS = ['arm64-v8a', 'x86_64'];
/**
* What a template holds, per platform.
@@ -56,10 +71,10 @@ export const DEFAULT_ABI = { android: 'arm64-v8a', ios: 'arm64' };
* shipping it unstripped also broke installing onto a clean device.
*
* @param {'android'|'ios'} platform
- * @param {{abi?: string}} [options]
+ * @param {{abis?: readonly string[]}} [options] Android ABIs to describe.
*/
export function templateLayout(platform, options = {}) {
- const abi = options.abi || DEFAULT_ABI[platform];
+ const abis = options.abis || ANDROID_ABIS;
if (platform === 'ios') {
return [
{
@@ -80,16 +95,25 @@ export function templateLayout(platform, options = {}) {
];
}
if (platform === 'android') {
- return [
+ // 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
+ // phone and in an emulator alike.
+ const libs = abis.flatMap((abi, n) => [
{
- rel: `lib/${abi}/libestella_js_host.so`, strip: true,
- from: (ctx) => path.join(ctx.root, 'build-native', 'libestella_js_host.so'),
+ rel: `lib/${abi}/libestella_js_host.so`, strip: true, abi, optional: n > 0,
+ from: (ctx) => path.join(ctx.root, 'build-native', abi, 'libestella_js_host.so'),
},
{
- rel: `lib/${abi}/libwebgpu_dawn.so`, strip: true,
- from: (ctx) => path.join(ctx.dawnBuild, 'src', 'dawn', 'native', 'libwebgpu_dawn.so'),
+ rel: `lib/${abi}/libwebgpu_dawn.so`, strip: true, abi, optional: n > 0,
+ from: (ctx) => ctx.dawnLibrary?.(abi),
},
- { rel: `lib/${abi}/libc++_shared.so`, from: (ctx) => ctx.libcxxShared },
+ {
+ rel: `lib/${abi}/libc++_shared.so`, abi, optional: n > 0,
+ from: (ctx) => ctx.libcxxShared?.(abi),
+ },
+ ]);
+ return [
+ ...libs,
// Compiled by the emitter (javac + d8), not copied: the IME's own side
// of an editable field has to be Java, and a template exists so that no
// user needs a JDK to package.
@@ -115,6 +139,16 @@ export function requiredTemplateFiles(platform, options) {
return templateLayout(platform, options).filter((e) => !e.optional).map((e) => e.rel);
}
+/**
+ * The Android ABIs a template actually holds — what a package can offer.
+ *
+ * Read off the files rather than the manifest: a template is usable if its files
+ * are there, and asking the directory is what makes that true by construction.
+ */
+export function templateAbis(dir) {
+ return ANDROID_ABIS.filter((abi) => existsSync(path.join(dir, 'lib', abi, 'libestella_js_host.so')));
+}
+
/** What a template is missing, if anything — the one readiness test. */
export function missingTemplateFiles(dir, platform, options) {
return requiredTemplateFiles(platform, options).filter((rel) => !existsSync(path.join(dir, rel)));
@@ -165,13 +199,12 @@ export function writeTemplateManifest(dir, meta) {
export function templateMatches(manifest, want) {
return !!manifest
&& manifest.platform === want.platform
- && manifest.engineVersion === want.engineVersion
- && (!want.abi || manifest.abi === want.abi);
+ && manifest.engineVersion === want.engineVersion;
}
/** The distributed artifact's filename. */
-export function templateZipName(platform, abi, engineVersion) {
- return `estella-native-${templateId(platform, abi)}-${engineVersion}.zip`;
+export function templateZipName(platform, engineVersion) {
+ return `estella-native-${templateId(platform)}-${engineVersion}.zip`;
}
// =============================================================================
@@ -201,7 +234,7 @@ export function parseTemplateIndex(doc, engineVersion) {
if (engineVersion && doc.engineVersion !== engineVersion) return null;
if (!Array.isArray(doc.templates)) return null;
const entries = doc.templates.filter((t) => typeof t?.id === 'string'
- && typeof t.platform === 'string' && typeof t.abi === 'string'
+ && typeof t.platform === 'string'
&& typeof t.file === 'string' && /^[\w.-]+$/.test(t.file)
&& typeof t.sha256 === 'string' && /^[0-9a-f]{64}$/.test(t.sha256)
&& Number.isInteger(t.bytes) && t.bytes > 0);
@@ -232,8 +265,8 @@ export function templateStoreDir() {
/** Where one template installs to. Versioned, so upgrading the editor never
* silently reuses the previous release's binary. */
-export function installedTemplateDir(engineVersion, platform, abi, storeDir = templateStoreDir()) {
- return path.join(storeDir, engineVersion, templateId(platform, abi));
+export function installedTemplateDir(engineVersion, platform, storeDir = templateStoreDir()) {
+ return path.join(storeDir, engineVersion, templateId(platform));
}
/**
@@ -242,11 +275,10 @@ export function installedTemplateDir(engineVersion, platform, abi, storeDir = te
* @returns {{dir: string, manifest: object, missing: string[]}|null}
*/
export function findTemplate(want, storeDir = templateStoreDir()) {
- const abi = want.abi || DEFAULT_ABI[want.platform];
- const dir = installedTemplateDir(want.engineVersion, want.platform, abi, storeDir);
+ const dir = installedTemplateDir(want.engineVersion, want.platform, storeDir);
const manifest = readTemplateManifest(dir);
- if (!templateMatches(manifest, { ...want, abi })) return null;
- return { dir, manifest, missing: missingTemplateFiles(dir, want.platform, { abi }) };
+ if (!templateMatches(manifest, want)) return null;
+ return { dir, manifest, missing: missingTemplateFiles(dir, want.platform) };
}
// =============================================================================
diff --git a/desktop/electron/exportGame.ts b/desktop/electron/exportGame.ts
index fbb4aeac5..453c21028 100644
--- a/desktop/electron/exportGame.ts
+++ b/desktop/electron/exportGame.ts
@@ -428,9 +428,10 @@ export async function exportGame(opts: {
/** iOS: where the prebuilt engine + app shell live, so the export can wrap
* itself in an Xcode project. Omitted (or null) exports content only. */
iosSources?: IosProjectSources | null;
- /** Android: the installed runtime template the APK is assembled from. Omitted
- * (or null) exports content only. */
- androidTemplate?: { dir: string; abi: string } | null;
+ /** Android: the installed runtime template the package is assembled from —
+ * which carries every architecture it will ship. Omitted (or null) exports
+ * content only. */
+ androidTemplate?: string | null;
/** Android: the identity to sign with. Omitted uses the development key, which
* installs on a device and is refused by every store. */
androidKey?: SigningKey;
@@ -697,7 +698,7 @@ export async function exportGame(opts: {
const template = opts.androidTemplate ?? null;
if (template) {
const key = opts.androidKey ?? debugSigningKey();
- const assembly = { templateDir: template.dir, contentDir: absOut, app: appConfig, abi: template.abi, key, icon };
+ const assembly = { templateDir: template, contentDir: absOut, app: appConfig, key, icon };
apkFile = path.join(absOut, apkFileName(appConfig.id));
await writeFile(apkFile, assembleApk(assembly));
if (opts.androidAppBundle) {
diff --git a/desktop/electron/main.ts b/desktop/electron/main.ts
index 00db2386d..49adaa6ed 100644
--- a/desktop/electron/main.ts
+++ b/desktop/electron/main.ts
@@ -900,10 +900,7 @@ ipcMain.handle(
// Android assembles the APK outright — the template carries everything the
// package needs, and signing is ours to do.
androidTemplate: opts?.platform === 'android'
- ? (() => {
- const template = resolveNativeTemplate('android', app.getVersion());
- return template ? { dir: template.dir, abi: template.manifest.abi } : null;
- })()
+ ? (resolveNativeTemplate('android', app.getVersion())?.dir ?? null)
: null,
onProgress: (p) => e.sender.send('project:exportProgress', p),
});
@@ -1011,8 +1008,8 @@ ipcMain.handle('nativeTemplates:install', async () => {
if (res.canceled || res.filePaths.length === 0) return { ok: false, canceled: true };
return installNativeTemplate(res.filePaths[0], app.getVersion());
});
-ipcMain.handle('nativeTemplates:remove', (_e, platform: 'android' | 'ios', abi: string, version: string) =>
- removeNativeTemplate(platform, abi, version),
+ipcMain.handle('nativeTemplates:remove', (_e, platform: 'android' | 'ios', version: string) =>
+ removeNativeTemplate(platform, version),
);
// Download + install this editor version's template. Progress is pushed rather
// than polled: the renderer drew the button, so it owns the progress bar.
diff --git a/desktop/electron/nativeTemplates.ts b/desktop/electron/nativeTemplates.ts
index df2023d87..7924e2503 100644
--- a/desktop/electron/nativeTemplates.ts
+++ b/desktop/electron/nativeTemplates.ts
@@ -21,7 +21,7 @@ import { once } from 'node:events';
import { randomUUID, createHash } from 'node:crypto';
import {
findTemplate, readTemplateManifest, missingTemplateFiles, installedTemplateDir,
- templateStoreDir, iosTemplateSources, DEFAULT_ABI, releaseAssetBase, parseTemplateIndex,
+ templateStoreDir, iosTemplateSources, releaseAssetBase, parseTemplateIndex,
TEMPLATE_INDEX,
type NativePlatform, type NativeTemplateManifest,
} from '../../build-tools/utils/nativeTemplate.js';
@@ -60,7 +60,8 @@ export function iosSourcesFromTemplate(engineVersion: string): {
export interface NativeTemplateEntry {
id: string;
platform: string;
- abi: string;
+ /** Android: the architectures it carries. */
+ abis: string[];
engineVersion: string;
dir: string;
/** Usable by THIS editor — an older release's template stays listed (removing
@@ -82,11 +83,11 @@ export function listNativeTemplates(engineVersion: string): NativeTemplateEntry[
out.push({
id: manifest.id,
platform: manifest.platform,
- abi: manifest.abi,
+ abis: manifest.abis ?? [],
engineVersion: manifest.engineVersion,
dir,
current: manifest.engineVersion === engineVersion
- && missingTemplateFiles(dir, manifest.platform, { abi: manifest.abi }).length === 0,
+ && missingTemplateFiles(dir, manifest.platform).length === 0,
});
}
}
@@ -122,12 +123,12 @@ export function installNativeTemplate(zipPath: string, engineVersion: string): I
if (!manifest) {
return { ok: false, error: 'not an Estella runtime template (no readable template.json)' };
}
- const missing = missingTemplateFiles(staging, manifest.platform, { abi: manifest.abi });
+ const missing = missingTemplateFiles(staging, manifest.platform);
if (missing.length > 0) {
return { ok: false, error: `incomplete template — missing ${missing.join(', ')}` };
}
- const dest = installedTemplateDir(manifest.engineVersion, manifest.platform, manifest.abi, store);
+ const dest = installedTemplateDir(manifest.engineVersion, manifest.platform, store);
rmSync(dest, { recursive: true, force: true });
mkdirSync(path.dirname(dest), { recursive: true });
renameSync(staging, dest);
@@ -184,9 +185,8 @@ export async function downloadNativeTemplate(
const entries = parseTemplateIndex(await indexRes.json(), engineVersion);
if (!entries) return { ok: false, error: `the template index for v${engineVersion} is not readable` };
- const abi = DEFAULT_ABI[platform];
- const entry = entries.find((t) => t.platform === platform && t.abi === abi);
- if (!entry) return { ok: false, error: `v${engineVersion} publishes no ${platform}-${abi} template` };
+ const entry = entries.find((t) => t.platform === platform);
+ if (!entry) return { ok: false, error: `v${engineVersion} publishes no ${platform} template` };
const res = await fetchImpl(`${base}/${entry.file}`);
if (!res.ok || !res.body) return { ok: false, error: `download failed (HTTP ${res.status})` };
@@ -221,8 +221,8 @@ export async function downloadNativeTemplate(
/** Delete an installed template. Takes the id + version rather than a path, so a
* renderer can never ask the main process to remove an arbitrary directory. */
-export function removeNativeTemplate(platform: NativePlatform, abi: string, engineVersion: string): boolean {
- const dir = installedTemplateDir(engineVersion, platform, abi || DEFAULT_ABI[platform]);
+export function removeNativeTemplate(platform: NativePlatform, engineVersion: string): boolean {
+ const dir = installedTemplateDir(engineVersion, platform);
if (!readTemplateManifest(dir)) return false;
rmSync(dir, { recursive: true, force: true });
return true;
diff --git a/desktop/electron/platformCatalog.ts b/desktop/electron/platformCatalog.ts
index 542552a7d..a7f0b0821 100644
--- a/desktop/electron/platformCatalog.ts
+++ b/desktop/electron/platformCatalog.ts
@@ -32,7 +32,7 @@ import {
} from './playableAdProfile';
import { BUILTIN_PLATFORMS, type PlatformPrereq } from '../src/project/platforms';
import { resolveNativeTemplate } from './nativeTemplates';
-import { templateId, DEFAULT_ABI } from '../../build-tools/utils/nativeTemplate.js';
+import { templateId } from '../../build-tools/utils/nativeTemplate.js';
import type { MiniGameExportProfile, MiniGameConfigContext } from './miniGameExportProfile';
/** Where a project keeps its own platform profiles. */
@@ -108,7 +108,7 @@ function builtinReadiness(
// signed here, on any OS, with nothing from the Android SDK.
return resolveNativeTemplate('android', engineVersion)
? { ready: true }
- : { ready: false, prereq: { kind: 'template-missing', id: templateId('android', DEFAULT_ABI.android), version: engineVersion } };
+ : { ready: false, prereq: { kind: 'template-missing', id: templateId('android'), version: engineVersion } };
case 'ios': {
// The template comes first because it is the harder blocker: without it the
@@ -116,7 +116,7 @@ function builtinReadiness(
// writes a complete project (the xcframework included) to carry to a Mac —
// the artifact is portable even though Apple's toolchain is not.
if (!resolveNativeTemplate('ios', engineVersion)) {
- return { ready: false, prereq: { kind: 'template-missing', id: templateId('ios', DEFAULT_ABI.ios), version: engineVersion } };
+ return { ready: false, prereq: { kind: 'template-missing', id: templateId('ios'), version: engineVersion } };
}
if (process.platform !== 'darwin') return { ready: false, prereq: { kind: 'toolchain-missing', tool: 'macos' } };
return existsSync('/Applications/Xcode.app')
diff --git a/desktop/electron/preload.ts b/desktop/electron/preload.ts
index 76098338d..c784b9e9e 100644
--- a/desktop/electron/preload.ts
+++ b/desktop/electron/preload.ts
@@ -229,8 +229,8 @@ const api = {
/** Pick an archive and install it. Main owns the file dialog, so the renderer
* never handles a path it could have made up. */
install: (): Promise<InstallResult & { canceled?: boolean }> => ipcRenderer.invoke('nativeTemplates:install'),
- remove: (platform: 'android' | 'ios', abi: string, version: string): Promise<boolean> =>
- ipcRenderer.invoke('nativeTemplates:remove', platform, abi, version),
+ remove: (platform: 'android' | 'ios', version: string): Promise<boolean> =>
+ ipcRenderer.invoke('nativeTemplates:remove', platform, version),
/** Fetch this editor version's template from the release and install it. */
download: (platform: 'android' | 'ios'): Promise<InstallResult> =>
ipcRenderer.invoke('nativeTemplates:download', platform),
diff --git a/desktop/tests/android-aab.test.ts b/desktop/tests/android-aab.test.ts
index 2b6dcf41d..3bf1c9a31 100644
--- a/desktop/tests/android-aab.test.ts
+++ b/desktop/tests/android-aab.test.ts
@@ -85,6 +85,8 @@ beforeEach(() => {
writeFileSync(path.join(templateDir, 'icon.png'), readFileSync(DEFAULT_ICON_SOURCE));
writeFileSync(path.join(templateDir, 'lib/arm64-v8a/libestella_js_host.so'), Buffer.alloc(40_000, 7));
writeFileSync(path.join(templateDir, 'lib/arm64-v8a/libwebgpu_dawn.so'), Buffer.alloc(30_000, 9));
+ mkdirSync(path.join(templateDir, 'lib', 'x86_64'), { recursive: true });
+ writeFileSync(path.join(templateDir, 'lib/x86_64/libestella_js_host.so'), Buffer.alloc(25_000, 5));
writeFileSync(path.join(templateDir, 'classes.dex'), Buffer.from('dex\n035\0stand-in'));
writeFileSync(path.join(templateDir, 'assets', 'esengine.native.qjsbc'), Buffer.alloc(512, 3));
@@ -99,9 +101,7 @@ afterEach(() => {
rmSync(scratch, { recursive: true, force: true });
});
-const assembly = () => ({
- templateDir, contentDir, app: APP, abi: 'arm64-v8a', key: debugSigningKey(),
-});
+const assembly = () => ({ templateDir, contentDir, app: APP, key: debugSigningKey() });
function build(): string {
const file = path.join(contentDir, aabFileName(APP.id));
@@ -128,9 +128,12 @@ describe('assembling an App Bundle', () => {
const result = verify(build());
expect(result.hasDex).toBe(true);
+ // Every architecture: Play splits the bundle per device, which is the point
+ // of the format.
expect(result.libs).toEqual([
'base/lib/arm64-v8a/libestella_js_host.so',
'base/lib/arm64-v8a/libwebgpu_dawn.so',
+ 'base/lib/x86_64/libestella_js_host.so',
]);
// The template's bytecode plus the export's own files.
expect(result.assets).toBe(3);
diff --git a/desktop/tests/android-apk.test.ts b/desktop/tests/android-apk.test.ts
index 46f7df128..f9136e716 100644
--- a/desktop/tests/android-apk.test.ts
+++ b/desktop/tests/android-apk.test.ts
@@ -72,6 +72,9 @@ beforeEach(() => {
writeFileSync(path.join(templateDir, 'icon.png'), readFileSync(DEFAULT_ICON_SOURCE));
writeFileSync(path.join(templateDir, 'lib/arm64-v8a/libestella_js_host.so'), Buffer.alloc(120_000, 7));
writeFileSync(path.join(templateDir, 'lib/arm64-v8a/libwebgpu_dawn.so'), Buffer.alloc(90_000, 9));
+ // A second architecture, the way a template that was built twice carries one.
+ mkdirSync(path.join(templateDir, 'lib', 'x86_64'), { recursive: true });
+ writeFileSync(path.join(templateDir, 'lib/x86_64/libestella_js_host.so'), Buffer.alloc(110_000, 5));
writeFileSync(path.join(templateDir, 'classes.dex'), Buffer.from('dex\n035\0stand-in'));
writeFileSync(path.join(templateDir, 'assets', 'esengine.native.qjsbc'), Buffer.alloc(2048, 3));
@@ -87,10 +90,10 @@ afterEach(() => {
rmSync(scratch, { recursive: true, force: true });
});
-const assemblyOptions = () => ({ templateDir, contentDir, app: APP, abi: 'arm64-v8a', key: debugSigningKey() });
+const assemblyOptions = () => ({ templateDir, contentDir, app: APP, key: debugSigningKey() });
function build(app = APP): string {
- const apk = assembleApk({ templateDir, contentDir, app, abi: 'arm64-v8a', key: debugSigningKey() });
+ const apk = assembleApk({ templateDir, contentDir, app, key: debugSigningKey() });
const file = path.join(contentDir, apkFileName(app.id));
writeFileSync(file, apk);
return file;
@@ -159,6 +162,9 @@ describe('assembling an APK', () => {
expect(names).toContain('classes.dex');
expect(names).toContain('lib/arm64-v8a/libestella_js_host.so');
expect(names).toContain('lib/arm64-v8a/libwebgpu_dawn.so');
+ // Every architecture the template carries, so one package installs on a
+ // phone and in an emulator alike.
+ expect(names).toContain('lib/x86_64/libestella_js_host.so');
expect(names).toContain('assets/esengine.native.qjsbc');
// The export directory BECOMES assets/, so the cooked tree keeps the
// project-relative paths the host's readAsset() asks for.
@@ -189,7 +195,7 @@ describe('assembling an APK', () => {
}
at = dataAt + compressedSize;
}
- expect(checked).toBe(2);
+ expect(checked).toBe(3);
});
it('carries a launcher icon the platform can resolve, through a table we wrote', () => {
diff --git a/desktop/tests/native-template.test.ts b/desktop/tests/native-template.test.ts
index c5f622676..2c7d10f36 100644
--- a/desktop/tests/native-template.test.ts
+++ b/desktop/tests/native-template.test.ts
@@ -52,9 +52,8 @@ function templateEntries(version: string, omit?: string): { name: string; data:
data: Buffer.from(JSON.stringify({
kind: 'estella-native-template',
formatVersion: TEMPLATE_FORMAT,
- id: 'ios-arm64',
+ id: 'ios',
platform: 'ios',
- abi: 'arm64',
engineVersion: version,
spineVersion: '4.2',
deploymentTarget: '17.0',
@@ -77,7 +76,7 @@ describe('installing a runtime template', () => {
expect(res.ok).toBe(true);
expect(res.versionMismatch).toBe(false);
- expect(res.dir).toBe(installedTemplateDir(VERSION, 'ios', 'arm64', store));
+ expect(res.dir).toBe(installedTemplateDir(VERSION, 'ios', store));
const resolved = resolveNativeTemplate('ios', VERSION);
expect(resolved?.manifest.engineVersion).toBe(VERSION);
@@ -96,7 +95,7 @@ describe('installing a runtime template', () => {
expect(res.engineVersion).toBe('1.0.0');
expect(resolveNativeTemplate('ios', VERSION)).toBeNull();
expect(listNativeTemplates(VERSION)).toEqual([
- expect.objectContaining({ id: 'ios-arm64', engineVersion: '1.0.0', current: false }),
+ expect.objectContaining({ id: 'ios', engineVersion: '1.0.0', current: false }),
]);
});
@@ -128,7 +127,7 @@ describe('installing a runtime template', () => {
it('treats a half-deleted install as absent rather than usable', () => {
installNativeTemplate(writeTemplateZip(VERSION), VERSION);
- rmSync(path.join(installedTemplateDir(VERSION, 'ios', 'arm64', store), 'App', 'main.m'));
+ rmSync(path.join(installedTemplateDir(VERSION, 'ios', store), 'App', 'main.m'));
expect(resolveNativeTemplate('ios', VERSION)).toBeNull();
});
@@ -136,9 +135,9 @@ describe('installing a runtime template', () => {
it('removes an installed template', () => {
installNativeTemplate(writeTemplateZip(VERSION), VERSION);
- expect(removeNativeTemplate('ios', 'arm64', VERSION)).toBe(true);
+ expect(removeNativeTemplate('ios', VERSION)).toBe(true);
expect(resolveNativeTemplate('ios', VERSION)).toBeNull();
- expect(removeNativeTemplate('ios', 'arm64', VERSION)).toBe(false);
+ expect(removeNativeTemplate('ios', VERSION)).toBe(false);
});
});
@@ -151,8 +150,8 @@ describe('downloading a template from a release', () => {
formatVersion: TEMPLATE_FORMAT,
engineVersion: VERSION,
templates: overrides.templates ?? [{
- id: 'ios-arm64', platform: 'ios', abi: 'arm64',
- file: `estella-native-ios-arm64-${VERSION}.zip`,
+ id: 'ios', platform: 'ios',
+ file: `estella-native-ios-${VERSION}.zip`,
bytes: overrides.bytes ?? zip.length,
sha256: overrides.sha256 ?? createHash('sha256').update(zip).digest('hex'),
}],
@@ -184,11 +183,11 @@ describe('downloading a template from a release', () => {
fetchImpl, baseUrl: 'https://example.test/r', onProgress: (p) => progress.push(p.received),
});
- expect(res).toMatchObject({ ok: true, id: 'ios-arm64', versionMismatch: false });
+ expect(res).toMatchObject({ ok: true, id: 'ios', versionMismatch: false });
expect(resolveNativeTemplate('ios', VERSION)).not.toBeNull();
expect(served).toEqual([
`https://example.test/r/${TEMPLATE_INDEX}`,
- `https://example.test/r/estella-native-ios-arm64-${VERSION}.zip`,
+ `https://example.test/r/estella-native-ios-${VERSION}.zip`,
]);
expect(progress).toEqual([100, zip.length]);
});
@@ -217,7 +216,7 @@ describe('downloading a template from a release', () => {
const res = await downloadNativeTemplate('android', VERSION, { fetchImpl, baseUrl: 'https://example.test/r' });
- expect(res.error).toContain('no android-arm64-v8a template');
+ expect(res.error).toContain('no android template');
});
it('treats an unreadable index as no index — a 404 page is not a template list', async () => {
@@ -233,14 +232,14 @@ describe('downloading a template from a release', () => {
it('rejects an index published for another version', () => {
expect(parseTemplateIndex({
kind: 'estella-native-templates', formatVersion: TEMPLATE_FORMAT, engineVersion: '1.0.0',
- templates: [{ id: 'ios-arm64', platform: 'ios', abi: 'arm64', file: 'x.zip', bytes: 1, sha256: 'a'.repeat(64) }],
+ templates: [{ id: 'ios', platform: 'ios', file: 'x.zip', bytes: 1, sha256: 'a'.repeat(64) }],
}, VERSION)).toBeNull();
});
it('drops an entry whose filename could escape the download directory', () => {
expect(parseTemplateIndex({
kind: 'estella-native-templates', formatVersion: TEMPLATE_FORMAT, engineVersion: VERSION,
- templates: [{ id: 'ios-arm64', platform: 'ios', abi: 'arm64', file: '../evil.zip', bytes: 1, sha256: 'a'.repeat(64) }],
+ templates: [{ id: 'ios', platform: 'ios', file: '../evil.zip', bytes: 1, sha256: 'a'.repeat(64) }],
}, VERSION)).toBeNull();
});
});
@@ -253,7 +252,7 @@ describe('the iOS row reports what is missing', () => {
const row = await iosRow();
expect(row.ready).toBe(false);
- expect(row.prereq).toEqual({ kind: 'template-missing', id: 'ios-arm64', version: VERSION });
+ expect(row.prereq).toEqual({ kind: 'template-missing', id: 'ios', version: VERSION });
});
it('moves on to the toolchain once a template is installed', async () => {
@@ -271,7 +270,7 @@ describe('the iOS row reports what is missing', () => {
describe('the template layout is the one source of filenames', () => {
it('assembles the iOS project from paths inside the installed template', () => {
installNativeTemplate(writeTemplateZip(VERSION), VERSION);
- const dir = installedTemplateDir(VERSION, 'ios', 'arm64', store);
+ const dir = installedTemplateDir(VERSION, 'ios', store);
const sources = iosSourcesFromTemplate(VERSION)!;
diff --git a/native/README.md b/native/README.md
index 606471f8b..00401e3a3 100644
--- a/native/README.md
+++ b/native/README.md
@@ -58,6 +58,14 @@ machine's store (`--no-template` opts out); `--template-out <dir>` also writes t
distributable archive, and `--template-only` re-emits from an existing build
without rebuilding.
+There is ONE template per platform, not one per architecture: a platform's
+template carries every architecture that platform needs — iOS already did, with
+the device and simulator slices inside one xcframework, and Android does with
+`lib/arm64-v8a` (every real device) and `lib/x86_64` (the emulator, which is how
+anyone without a phone tries the game). Each `cli native --abi <abi>` run adds its
+architecture and keeps the ones already there, so a package installs everywhere
+without anyone choosing.
+
A release publishes those archives plus `native-templates.json`, written by
`--template-index <dir>` over the set — one digest per template, which is what the
editor checks a download against. The release workflow's `native-templates` job
@@ -136,9 +144,14 @@ minutes, cached in the checkout afterwards); the recipe lives in
`build-tools/tasks/nativeDeps.js`, so CI runs exactly what you run:
```sh
-node build-tools/cli.js native
+node build-tools/cli.js native # arm64-v8a, every real device
+node build-tools/cli.js native --abi x86_64 # adds the emulator's
```
+Per-ABI build trees live under `build-native/<abi>/`, beside the `build-native/gen/`
+they share (the bindings, the SDK bundle and its bytecode are the same for every
+architecture).
+
The build emits this machine's Android runtime template on the way out (the
`.so` payload, the Java shim's `classes.dex`, the SDK bytecode and the manifest
template); packaging a game then reads that template and needs none of the tools