aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/strings.yml22
-rw-r--r--.github/workflows/translations.yml1
-rwxr-xr-x[-rw-r--r--]tools/find-unused-strings.sh22
-rwxr-xr-xtools/generate-legacy-icons.sh11
-rwxr-xr-xtools/optimize-assets.sh9
-rwxr-xr-xtools/stale-translations.sh4
6 files changed, 56 insertions, 13 deletions
diff --git a/.github/workflows/strings.yml b/.github/workflows/strings.yml
new file mode 100644
index 0000000000..614c5c12d0
--- /dev/null
+++ b/.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
diff --git a/.github/workflows/translations.yml b/.github/workflows/translations.yml
index 07037c7f94..92bb1fdf5d 100644
--- a/.github/workflows/translations.yml
+++ b/.github/workflows/translations.yml
@@ -5,6 +5,7 @@ on:
schedule:
cron:
- '0 14 * * 1,3,6'
+ workflow_dispatch:
jobs:
tx-update:
diff --git a/tools/find-unused-strings.sh b/tools/find-unused-strings.sh
index 43e39fbe25..3e26dc9283 100644..100755
--- a/tools/find-unused-strings.sh
+++ b/tools/find-unused-strings.sh
@@ -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" \ No newline at end of file
diff --git a/tools/generate-legacy-icons.sh b/tools/generate-legacy-icons.sh
index 8dad11470e..3661a75bb8 100755
--- a/tools/generate-legacy-icons.sh
+++ b/tools/generate-legacy-icons.sh
@@ -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
diff --git a/tools/optimize-assets.sh b/tools/optimize-assets.sh
index 598052b70c..70fa2375a5 100755
--- a/tools/optimize-assets.sh
+++ b/tools/optimize-assets.sh
@@ -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 {}
diff --git a/tools/stale-translations.sh b/tools/stale-translations.sh
index 791b857a36..3a9362a252 100755
--- a/tools/stale-translations.sh
+++ b/tools/stale-translations.sh
@@ -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" \ No newline at end of file
+rm -rf "$TMP_DIR" \ No newline at end of file