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.

docs: getting a runtime template is a download, and Dawn is fetched by the build

esengine8b5f1646d11f
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b993ecf8d..c595ec94f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -16,6 +16,16 @@ published separately; it ships inside the editor.
### Added
+- **Runtime templates are published with the release, and the editor downloads
+ them.** The Android and iOS rows offer **Download** (with progress) beside
+ *Install from file…* for offline installs and mirrors. What is downloaded is
+ checked against the digest in `native-templates.json`, which the release
+ publishes beside the archives — a truncated download, a proxy's cached copy or a
+ captive-portal login page fails by name instead of installing as a broken
+ template. Dawn and QuickJS-ng are now **pinned** in `toolchain.manifest.json`
+ and fetched by `cli native --fetch-deps`, which also removes the hand-run cmake
+ recipes from `native/README.md`: the build produces Dawn for a target the first
+ time it needs it, so CI and a contributor run the same two commands.
- **Android: Package Project hands back a signed APK, with no Android SDK.** With
the Android runtime template installed, the editor compiles the manifest to
binary XML, writes the aligned zip and signs it with **APK Signature Scheme v2**
diff --git a/docs/astro/src/content/docs/guides/mobile.mdx b/docs/astro/src/content/docs/guides/mobile.mdx
index d779daf0e..c5ebbb3e8 100644
--- a/docs/astro/src/content/docs/guides/mobile.mdx
+++ b/docs/astro/src/content/docs/guides/mobile.mdx
@@ -57,14 +57,15 @@ are not the same severity:
<Steps>
1. **Get the runtime for your target.**
- - *iOS* — install the **runtime template**: the engine, prebuilt for arm64,
- published with each release. The iOS row offers *Install from file…*; point it
- at the archive from this version's release page. It is matched **exactly**
- against the editor's version (the SDK is compiled into the app binary), so it
- is one install per editor upgrade — and none of the engine's own build
- dependencies come with it.
- - *Android* — the same, with its own template. Nothing else: the APK is
- compiled, aligned and signed by the editor, on whatever OS it is running on.
+ Install the **runtime template**: the engine, prebuilt for arm64 and published
+ with each release. The target's row offers **Download** — or *Install from
+ file…* if you already have the archive (offline, a mirror, a company share).
+ It is matched **exactly** against the editor's version, because the SDK is
+ compiled into the app binary, so it is one download per editor upgrade — and
+ none of the engine's own build dependencies come with it.
+
+ Android needs nothing else: the APK is compiled, aligned and signed by the
+ editor, on whatever OS it is running on.
2. **Install the platform toolchain — iOS only.**
- *Android* — none. There is no Android SDK, NDK or JDK in this path.
diff --git a/docs/astro/src/content/docs/zh-cn/guides/mobile.mdx b/docs/astro/src/content/docs/zh-cn/guides/mobile.mdx
index a749f3f03..374dad692 100644
--- a/docs/astro/src/content/docs/zh-cn/guides/mobile.mdx
+++ b/docs/astro/src/content/docs/zh-cn/guides/mobile.mdx
@@ -49,12 +49,12 @@ Android 和 iOS 是**两个目标而不是一个"Mobile"**,因为它们被组装
<Steps>
1. **拿到该目标的运行时。**
- - *iOS* —— 安装**运行时模板**:随每个版本发布的、已为 arm64 预编译好的引擎。
- iOS 那一行提供*从文件安装…*,指向本版本发布页里的归档即可。它与编辑器版本
- **精确匹配**(SDK 是编译进应用二进制的),所以每次升级编辑器装一次——引擎自己
- 那一堆构建依赖一样都不用装。
- - *Android* —— 同理,装它自己的模板。此外别无所需:APK 的编译、对齐与签名都由编辑器
- 在它所运行的任何操作系统上完成。
+ 安装**运行时模板**:随每个版本发布的、已为 arm64 预编译好的引擎。目标那一行提供
+ **下载**——如果你已经有归档文件(离线、镜像、公司共享盘),也可以*从文件安装…*。
+ 它与编辑器版本**精确匹配**,因为 SDK 是编译进应用二进制的,所以每次升级编辑器
+ 下载一次即可——引擎自己那一堆构建依赖一样都不用装。
+
+ Android 此外别无所需:APK 的编译、对齐与签名都由编辑器在它所运行的任何操作系统上完成。
2. **装好平台工具链——只有 iOS 需要。**
- *Android* —— 不需要。这条路径上没有 Android SDK、NDK 或 JDK。
diff --git a/native/README.md b/native/README.md
index 9a2f57dfe..dca080aa5 100644
--- a/native/README.md
+++ b/native/README.md
@@ -28,8 +28,9 @@ This directory holds the host and the build recipe:
- `platform/android.cpp` — NativeActivity, APK assets, Vulkan, the ALooper loop.
- `platform/ios.mm` — a CAMetalLayer view, bundle assets, Metal, CADisplayLink.
- **`android/`** — the APK manifest, packaged by `--package`.
-- **`ios/`** — the Xcode app shell (xcodegen) that signs and packages the iOS
- build. It is only an entry point; the app lives in the static library.
+- **`ios/`** — the Xcode app shell (`main.m` + an Info.plist template) that signs
+ and packages the iOS build. It is only an entry point; the app lives in the
+ static library, and the project around it is generated.
There is no built-in demo game and no second, JS-free host. What runs is an editor
export, always: a parallel content path drifts from the one every real game takes,
@@ -57,6 +58,11 @@ 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.
+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
+runs exactly the commands below; nothing about producing a template is CI-only.
+
### The optional runtimes are compiled IN, not side-loaded
On the web, Box2D, the Spine runtime and the MPEG-1 decoder ship as standalone wasm
@@ -109,49 +115,30 @@ takes for the device to have it.
## Build (Android arm64)
-Toolchain: Android SDK + NDK r28 (`android.toolchain.cmake`), SDK CMake ≥ 3.22.
-`cli native` locates the SDK / NDK / CMake automatically (`ANDROID_HOME`, or
-Android Studio's default install) and drives `native/CMakeLists.txt`.
+Toolchain: Android SDK + NDK r28, SDK CMake ≥ 3.22 (`cli native` locates the SDK /
+NDK / CMake automatically — `ANDROID_HOME`, `ANDROID_NDK_HOME`, or Android
+Studio's default install), a JDK for the Java shim, and the SDK bundle
+(`pnpm --filter ./sdk build`) — the host embeds it.
-**One-time: build Dawn for arm64** (Vulkan). Multi-GB; kept out of the tree.
+**One-time: fetch the dependencies.** Dawn and QuickJS-ng are multi-GB / separate
+projects, PINNED in `toolchain.manifest.json` rather than vendored or tracked as
+submodules — a `--depth 1` clone of a branch makes a template unreproducible, and
+Dawn fetches its own dependencies with a script anyway, so a submodule would save
+nobody the fetch while putting a huge clone in front of everyone who only builds
+for the web.
```sh
-git clone --depth 1 https://github.com/google/dawn "$DAWN"
-python "$DAWN/tools/fetch_dawn_dependencies.py" --shallow # NOT depot_tools
-cmake -S "$DAWN" -B "$DAWN/out-android" -G Ninja \
- -DCMAKE_TOOLCHAIN_FILE="$NDK/build/cmake/android.toolchain.cmake" \
- -DANDROID_ABI=arm64-v8a -DANDROID_PLATFORM=android-33 -DANDROID_STL=c++_shared \
- -DDAWN_ENABLE_VULKAN=ON -DDAWN_ENABLE_D3D12=OFF -DDAWN_ENABLE_METAL=OFF \
- -DDAWN_ENABLE_NULL=OFF -DDAWN_ENABLE_OPENGLES=OFF -DDAWN_ENABLE_DESKTOP_GL=OFF \
- -DDAWN_BUILD_SAMPLES=OFF -DDAWN_BUILD_TESTS=OFF -DTINT_BUILD_TESTS=OFF \
- -DDAWN_BUILD_PROTOBUF=OFF -DTINT_BUILD_IR_BINARY=OFF \
- -DDAWN_BUILD_MONOLITHIC_LIBRARY=SHARED -DDAWN_FETCH_DEPENDENCIES=OFF
-cmake --build "$DAWN/out-android" --target webgpu_dawn
+node build-tools/cli.js native --fetch-deps
```
-**Build the host** through the orchestrated task. Build the SDK bundle first (it
-produces the QuickJS-loadable `dist/index.native.bundled.js`), clone QuickJS-ng
-(core is dtoa/libregexp/libunicode/quickjs.c), and pass `--quickjs`:
+**Then build.** Dawn is built for the target the first time it is needed (a few
+minutes, cached in the checkout afterwards); the recipe lives in
+`build-tools/tasks/nativeDeps.js`, so CI runs exactly what you run:
```sh
-(cd sdk && pnpm run build)
-git clone --depth 1 https://github.com/quickjs-ng/quickjs "$QJS"
-node build-tools/cli.js native --dawn "$DAWN" --dawn-build "$DAWN/out-android" --quickjs "$QJS"
+node build-tools/cli.js native
```
-The task generates, into `build-native/gen/` (never committed, so nothing can
-drift from its source):
-
-* `NativeBindings.generated.cpp` — per-component accessors, from the SAME
- reflection as the web bindings (`eht --native-output ... --native-only`)
-* `NativeFunctionBindings.generated.cpp` — the engine's binding entry points, from
- the same `bindings/*.hpp` declarations embind registers (`eht --native-functions`)
-* `esengine_bundle.h` / `host_bootstrap.h` — the real SDK bundle and the host
- bootstrap, embedded as C strings
-
-Paths may also come from `ESTELLA_DAWN_DIR` / `ESTELLA_DAWN_BUILD` /
-`ESTELLA_QUICKJS_DIR`. Output: `build-native/libestella_js_host.so`.
-
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
@@ -160,43 +147,24 @@ above. See *Shipping a project*.
## Build (iOS arm64)
Toolchain: Xcode (the Command Line Tools alone have no iPhoneOS SDK — `cli native`
-falls back to `/Applications/Xcode.app` automatically), CMake ≥ 3.22, Ninja, and
-[xcodegen](https://github.com/yonaskolb/XcodeGen) (`brew install xcodegen`).
+falls back to `/Applications/Xcode.app` automatically), CMake ≥ 3.22 and Ninja.
+No xcodegen: the Xcode project is generated directly (`utils/xcodeProject.js`).
-**One-time: build Dawn for iOS arm64** (Metal, *static* — an app embeds it). Same
-checkout as the Android build; only the output dir differs. ~5 min, 744 targets,
-a 19 MB `libwebgpu_dawn.a`:
+**Build the host, then run it from Xcode.** Dawn is built for the iOS SDK on
+first use (~5 min, a 19 MB static `libwebgpu_dawn.a`, kept in the pinned
+checkout), and there is no pure-C++ reference host here — the app *is* the host:
```sh
-cmake -S "$DAWN" -B "$DAWN/out-ios" -G Ninja \
- -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_ARCHITECTURES=arm64 \
- -DCMAKE_OSX_DEPLOYMENT_TARGET=17.0 -DCMAKE_OSX_SYSROOT=iphoneos \
- -DDAWN_ENABLE_METAL=ON -DDAWN_ENABLE_VULKAN=OFF -DDAWN_ENABLE_D3D12=OFF \
- -DDAWN_ENABLE_NULL=OFF -DDAWN_ENABLE_OPENGLES=OFF -DDAWN_ENABLE_DESKTOP_GL=OFF \
- -DDAWN_BUILD_SAMPLES=OFF -DDAWN_BUILD_TESTS=OFF -DTINT_BUILD_TESTS=OFF \
- -DDAWN_BUILD_PROTOBUF=OFF -DTINT_BUILD_IR_BINARY=OFF \
- -DDAWN_BUILD_MONOLITHIC_LIBRARY=STATIC -DDAWN_FETCH_DEPENDENCIES=OFF
-cmake --build "$DAWN/out-ios" --target webgpu_dawn
-```
-
-**Build the host, then run it from Xcode.** There is no pure-C++ reference host on
-iOS — the app *is* the host, so `--quickjs` is required:
-
-```sh
-(cd sdk && pnpm run build)
-node build-tools/cli.js native --target ios \
- --dawn "$DAWN" --dawn-build "$DAWN/out-ios" --quickjs "$QJS"
-
-cd native/ios && xcodegen && open EstellaiOS.xcodeproj
+pnpm --filter ./sdk build
+node build-tools/cli.js native --fetch-deps # once
+node build-tools/cli.js native --target ios
```
**To run in the simulator** — a different target triple, so it needs its own Dawn
-and its own slice (`-DCMAKE_OSX_SYSROOT=iphonesimulator` on the Dawn command
-above, into `$DAWN/out-ios-sim`):
+and its own slice:
```sh
-node build-tools/cli.js native --target ios --simulator \
- --dawn "$DAWN" --dawn-build "$DAWN/out-ios-sim" --quickjs "$QJS"
+node build-tools/cli.js native --target ios --simulator
```
Both slices land in `build-native-ios/Estella.xcframework`, which is what the app