[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:
22
.github/workflows/strings.yml
vendored
Normal file
22
.github/workflows/strings.yml
vendored
Normal file
@@ -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
vendored
1
.github/workflows/translations.yml
vendored
@@ -5,6 +5,7 @@ on:
|
||||
schedule:
|
||||
cron:
|
||||
- '0 14 * * 1,3,6'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
tx-update:
|
||||
|
||||
22
tools/find-unused-strings.sh
Normal file → Executable file
22
tools/find-unused-strings.sh
Normal file → Executable 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"
|
||||
@@ -10,11 +10,11 @@ ROOTDIR=$PWD
|
||||
|
||||
cd src/android/app/src/main
|
||||
|
||||
pushd res/drawable
|
||||
cd res/drawable
|
||||
# convert vector to svg--needed to generate launcher png
|
||||
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
|
||||
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
|
||||
echo
|
||||
|
||||
rm *tmp*
|
||||
popd
|
||||
rm ./*tmp*
|
||||
|
||||
# Add legacy here when legacy gets merged
|
||||
cd "$ROOTDIR"
|
||||
|
||||
# TODO: add legacy icons
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
#!/bin/sh -e
|
||||
|
||||
# SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
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 {}
|
||||
|
||||
@@ -29,6 +29,6 @@ while IFS= read -r locale; do
|
||||
{ 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"; }
|
||||
done < "$COMBINED"
|
||||
done < "$LOCALES"
|
||||
|
||||
echo "-- done"
|
||||
done < "$LOCALES"
|
||||
rm -rf "$TMP_DIR"
|
||||
Reference in New Issue
Block a user