From 903e8c5b32285e50907e6525388162bd459cbef8 Mon Sep 17 00:00:00 2001 From: Franklin Wei Date: Sun, 11 Aug 2024 23:31:33 -0400 Subject: puzzles: remove unnecessary files from the src/ directory. This updates the resync.sh script to be more intelligent about which files it copies from the upstream tree. It now attempts some rudimentary parsing of the puzzles CMakeLists.txt file to figure out which files are actually necessary, and copies only those. This adds a new SOURCES.rockbox source file list for the Rockbox-specific parts of the port. Change-Id: I461f87ac712e3b2982dcbb0be9d70d278384a4e7 --- apps/plugins/puzzles/resync.sh | 45 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) (limited to 'apps/plugins/puzzles/resync.sh') diff --git a/apps/plugins/puzzles/resync.sh b/apps/plugins/puzzles/resync.sh index 384fc79d1f..7c2df45c7e 100755 --- a/apps/plugins/puzzles/resync.sh +++ b/apps/plugins/puzzles/resync.sh @@ -25,12 +25,55 @@ read ans if [ "YES" == $ans ] then pushd "$(dirname "$0")" > /dev/null + ROOT="$PWD" echo "[1/5] Removing current src/ directory" rm -rf src echo "[2/5] Copying new sources" mkdir src - cp -r "$1"/{*.c,*.h,*.but,LICENCE,README,CMakeLists.txt} src + cp -r "$1"/{*.h,puzzles.but,LICENCE,README,CMakeLists.txt} src + + # Parse out definitions of core, core_obj, and common from + # CMakeLists. Extract the .c filenames, except malloc.c, and store + # in SOURCES.core. + cat src/CMakeLists.txt | awk '/add_library\(/{p=1} p{printf $0" "} /\)/{if(p) print; p=0}' | grep -E "core|common" | grep -Po "[a-z0-9\-]*?\.c" | sort -n | grep -vE 'malloc\.c|ps\.c' | awk '{print "src/"$0}' | uniq > SOURCES.core + echo "src/printing.c" >> SOURCES.core + + # Parse out puzzle definitions to build SOURCES.games, but + # preserve the ability to disable puzzles based on memory size. + cat src/CMakeLists.txt | awk '/puzzle\(/{p=1} p{print} /\)/{p=0}' | grep -Eo "\(.*$" | tr -dc "a-z\n" | grep -v nullgame | awk '$0!~/loopy|pearl|solo/' | awk '{print "src/"$0".c"}' > SOURCES.games + + SRC="$(cat SOURCES.games SOURCES.core | sed 's/src\///' | tr '\n' ' ' | head -c-1) loopy.c pearl.c solo.c" + echo "Detected sources:" $SRC + pushd "$1" > /dev/null + cp $SRC "$ROOT"/src + popd > /dev/null + + cat <> SOURCES.games + +/* Disabled for now. Fix puzzles.make and CATEGORIES to accomodate these. */ +/* The help system would also need to be patched to compile these. */ +/*src/unfinished/group.c*/ +/*src/unfinished/separate.c*/ +/*src/unfinished/slide.c*/ +/*src/unfinished/sokoban.c*/ + +/* no c200v2 */ +#if PLUGIN_BUFFER_SIZE > 0x14000 +src/loopy.c +src/pearl.c +src/solo.c +#endif +EOF + + cat < SOURCES +/* Auto-generated by resync.sh */ +EOF + cat SOURCES.rockbox | cpp | grep -vE "^#" >> SOURCES + echo -e "\n/* puzzles core sources */" >> SOURCES + cat SOURCES.core >> SOURCES + rm SOURCES.core + echo "[3/5] Regenerating help" rm -rf help ./genhelp.sh -- cgit v1.2.3