[tauri] TauriPlatforms: Read the built APK's own values, carry Rosea's launcher icon into gen/android, survive a dropped USB link

This commit is contained in:
2026-11-17 18:57:14 +01:00
parent a93ef09956
commit 9e3d389f82
7 changed files with 208 additions and 39 deletions
+15 -8
View File
@@ -4,24 +4,31 @@
* the source SVG and optimised art under art/final/ (CLAUDE.md §5.2). The icon is still a
* placeholder; the real one comes through the art pipeline (GAP_ANALYSIS G0.21).
*
* tsx scripts/icons.ts makes them when missing or older than the SVG
* tsx scripts/icons.ts makes them when missing or older than the SVG, and copies the
* Android launcher icons into gen/android when it exists
*
* The copy is unconditional on purpose: `tauri android init` writes Tauri's own logo into
* gen/android, newer than any icon made before it, so a date check kept Tauri's logo in the first
* APK (review finding). `scripts/android.ts check` compares the bytes.
*/
import { existsSync, statSync } from 'node:fs';
import { cpSync, existsSync, statSync } from 'node:fs';
import { join } from 'node:path';
import { PACKAGE, SRC_TAURI, tauri } from './tauri.js';
const SOURCE = join(PACKAGE, '..', 'rosea', 'public', 'icon.svg');
const MARK = join(SRC_TAURI, 'icons', 'icon.ico');
const ANDROID = join(SRC_TAURI, 'gen', 'android');
const ANDROID_MARK = join(ANDROID, 'app', 'src', 'main', 'res', 'mipmap-mdpi', 'ic_launcher.png');
const MADE = join(SRC_TAURI, 'icons');
export const ANDROID_ICONS = join(MADE, 'android');
export const ANDROID_RES = join(SRC_TAURI, 'gen', 'android', 'app', 'src', 'main', 'res');
const stale = (file: string): boolean => !existsSync(file) || statSync(file).mtimeMs < statSync(SOURCE).mtimeMs;
// `tauri icon` writes the Android launcher icons into gen/android only when that exists, so it
// runs again after `tauri android init` (which puts Tauri's own logo there).
if (stale(MARK) || (existsSync(ANDROID) && stale(ANDROID_MARK))) {
if (stale(join(MADE, 'icon.ico')) || stale(join(ANDROID_ICONS, 'mipmap-mdpi', 'ic_launcher.png'))) {
tauri('icon', SOURCE);
console.log('icons: made from apps/rosea/public/icon.svg');
} else {
console.log('icons: up to date');
}
if (existsSync(ANDROID_RES)) {
cpSync(ANDROID_ICONS, ANDROID_RES, { recursive: true });
console.log('icons: Android launcher icons copied into gen/android');
}