Browse Source

[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
pull/3037/head
crueter 1 month ago
parent
commit
eb2d9ea574
No known key found for this signature in database GPG Key ID: 425ACD2D4830EBC6
  1. 22
      .github/workflows/strings.yml
  2. 1
      .github/workflows/translations.yml
  3. 22
      tools/find-unused-strings.sh
  4. 11
      tools/generate-legacy-icons.sh
  5. 9
      tools/optimize-assets.sh
  6. 4
      tools/stale-translations.sh

22
.github/workflows/strings.yml

@ -0,0 +1,22 @@
name: Check Strings
on:
push:
branches: [ master ]
jobs:
check-strings:
runs-on: source
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Find Unused Strings
run: ./tools/find-unused-strings.sh
- name: Find Stale Translations
run: ./tools/stale-translations.sh
- name: Diff
run: git --no-pager diff --exit-code HEAD

1
.github/workflows/translations.yml

@ -5,6 +5,7 @@ on:
schedule: schedule:
cron: cron:
- '0 14 * * 1,3,6' - '0 14 * * 1,3,6'
workflow_dispatch:
jobs: jobs:
tx-update: tx-update:

22
tools/find-unused-strings.sh

@ -1,7 +1,23 @@
#!/bin/sh -e #!/bin/sh -e
# SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project # SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
# SPDX-License-Identifier: GPL-3.0-or-later # 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"

11
tools/generate-legacy-icons.sh

@ -10,11 +10,11 @@ ROOTDIR=$PWD
cd src/android/app/src/main cd src/android/app/src/main
pushd res/drawable
cd res/drawable
# convert vector to svg--needed to generate launcher png # convert vector to svg--needed to generate launcher png
cp ic_yuzu_icon.xml tmp cp ic_yuzu_icon.xml tmp
python3 $ROOTDIR/tools/VectorDrawable2Svg.py tmp
python3 "$ROOTDIR"/tools/VectorDrawable2Svg.py tmp
inkscape -w 768 -h 768 tmp.svg -o ic_tmp.png inkscape -w 768 -h 768 tmp.svg -o ic_tmp.png
magick ic_icon_bg_orig.png -resize 512x512 bg_tmp.png magick ic_icon_bg_orig.png -resize 512x512 bg_tmp.png
@ -23,7 +23,8 @@ magick bg_tmp.png -strip -type TrueColor -depth 8 -colorspace sRGB -color-matrix
magick -verbose bg_tmp_rgb.png ic_tmp.png -gravity center -composite -colorspace sRGB ic_launcher.png magick -verbose bg_tmp_rgb.png ic_tmp.png -gravity center -composite -colorspace sRGB ic_launcher.png
echo echo
rm *tmp*
popd
rm ./*tmp*
# Add legacy here when legacy gets merged
cd "$ROOTDIR"
# TODO: add legacy icons

9
tools/optimize-assets.sh

@ -1,7 +1,10 @@
#!/bin/sh -e #!/bin/sh -e
# SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project # SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
which optipng || exit which optipng || exit
NPROC=$(nproc)
[ -z "$NPROC" ] && NPROC=8
find . -type f -iname '*.png' | xargs -P $NPROC -I {} optipng -o7 {}
NPROC=$(nproc 2>/dev/null || getconf _NPROCESSORS_ONLN 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 4)
# shellcheck disable=SC2038
find . -type f -iname '*.png' | xargs -P "$NPROC" -I {} optipng -o7 {}

4
tools/stale-translations.sh

@ -29,6 +29,6 @@ while IFS= read -r locale; do
{ grep -e "string name=\"$unused\"" "$STRINGS" >/dev/null; } || \ { grep -e "string name=\"$unused\"" "$STRINGS" >/dev/null; } || \
{ echo "-- Removing unused translation $unused" && sed "/string name=\"$unused\"/d" "$locale" > "$locale.new" && mv "$locale.new" "$locale"; } { echo "-- Removing unused translation $unused" && sed "/string name=\"$unused\"/d" "$locale" > "$locale.new" && mv "$locale.new" "$locale"; }
done < "$COMBINED" done < "$COMBINED"
done < "$LOCALES"
echo "-- done"
done < "$LOCALES"
rm -rf "$TMP_DIR"
Loading…
Cancel
Save