[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:
@@ -36,6 +36,12 @@ function problems(): string[] {
|
||||
if (!existsSync(at)) found.push(`res/xml/${f} is missing`);
|
||||
else if (readFileSync(at, 'utf8') !== readFileSync(join(RES_FROM, f), 'utf8')) found.push(`res/xml/${f} differs from android/res/xml/${f}`);
|
||||
}
|
||||
// The launcher icon is Rosea's, not the Tauri logo `init` put there (scripts/icons.ts).
|
||||
const ours = join(SRC_TAURI, 'icons', 'android', 'mipmap-mdpi', 'ic_launcher.png');
|
||||
const there = join(MAIN, 'res', 'mipmap-mdpi', 'ic_launcher.png');
|
||||
if (!existsSync(ours) || !existsSync(there) || !readFileSync(ours).equals(readFileSync(there))) {
|
||||
found.push("the launcher icon is not Rosea's (run 'tsx scripts/icons.ts')");
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user