Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

fix: verify prebuilt native apps without packaging templates

yhhbd445affe03c
diff --git a/tools/tests/native-boot-prebuilt.test.ts b/tools/tests/native-boot-prebuilt.test.ts
new file mode 100644
index 000000000..e32caa302
--- /dev/null
+++ b/tools/tests/native-boot-prebuilt.test.ts
@@ -0,0 +1,34 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+import { spawnSync } from 'node:child_process';
+import path from 'node:path';
+import { fileURLToPath } from 'node:url';
+import { describe, expect, it } from 'vitest';
+
+const root = fileURLToPath(new URL('../../', import.meta.url));
+const absent = path.join(root, 'build', 'native-boot-no-template-fixture');
+const run = (args: string[]) => spawnSync(process.execPath, [
+ path.join(root, 'tools', 'verify-native-boot.mjs'),
+ '--platform', 'android', '--template', absent,
+ '--out', path.join(root, 'build', 'native-boot-prebuilt-review'), ...args,
+], {
+ cwd: root, encoding: 'utf8', timeout: 10000,
+ env: { ...process.env, ANDROID_HOME: absent },
+});
+
+describe('native boot verification inputs', () => {
+ it('can reach device verification for a prebuilt APK without a packaging template', () => {
+ const result = run(['--apk', path.join(absent, 'game.apk')]);
+ expect(result.error).toBeUndefined();
+ expect(result.status).toBe(2);
+ expect(result.stderr).toContain('no android device or simulator is available');
+ expect(result.stderr).not.toContain('runtime template');
+ });
+
+ it('still requires the runtime template when it must package examples', () => {
+ const result = run(['--examples', 'all']);
+ expect(result.error).toBeUndefined();
+ expect(result.status).toBe(2);
+ expect(result.stderr).toContain('no android runtime template');
+ });
+});
diff --git a/tools/verify-native-boot.mjs b/tools/verify-native-boot.mjs
index 01230c896..4752e6df4 100644
--- a/tools/verify-native-boot.mjs
+++ b/tools/verify-native-boot.mjs
@@ -761,7 +761,7 @@ const driver = opts.platform === 'ios' ? iosDriver(opts) : androidDriver(opts);
// The template is what a game is packaged INTO, and its default is a directory a
// plain checkout does not have. Unchecked, every export failed with an empty
// reason: 47 examples, one after another, six minutes to say nothing.
-if (!existsSync(opts.template)) {
+if (opts.examples && !existsSync(opts.template)) {
console.error(`✗ no ${driver.name} runtime template at ${path.relative(ROOT, opts.template)}`);
console.error(' take one from a release (as native-smoke does) or build it:'
+ ` node build-tools/cli.js native --target ${driver.name}`);