[ci, tools] working find-unused-strings, android strings CI (#3036)

Signed-off-by: crueter <crueter@eden-emu.dev>
Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3036
This commit is contained in:
crueter 2025-11-17 15:52:30 +01:00
parent 4f389338bd
commit eb2d9ea574
No known key found for this signature in database
GPG key ID: 425ACD2D4830EBC6
6 changed files with 56 additions and 13 deletions

22
tools/find-unused-strings.sh Normal file → Executable file
View file

@ -1,7 +1,23 @@
#!/bin/sh -e
# SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
# SPDX-License-Identifier: GPL-3.0-or-later
cat src/android/app/src/main/res/values/strings.xml \
| grep 'string name="' | awk -F'"' '$0=$2' \
| xargs -I {} sh -c 'grep -qirnw R.string.'{}' src/android/app/src || echo '{}
ANDROID=src/android/app/src/main
STRINGS=$ANDROID/res/values/strings.xml
SRC=$(mktemp)
# We start out by getting the list of source strings...
grep -e "string name" $STRINGS | cut -d'"' -f2 > "$SRC"
# ... then search for each string as R.string. or @string/
while IFS= read -r str; do
grep -qre "R.string.$str\|@string/$str" "$ANDROID" && continue
echo "-- Removing unused string $str"
sed "/string name=\"$str\"/d" "$STRINGS" > "$STRINGS.new"
mv "$STRINGS.new" "$STRINGS"
done < "$SRC"
rm -rf "$TMP_DIR"