summaryrefslogtreecommitdiff
path: root/apps/plugins/puzzles/resync.sh
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/puzzles/resync.sh')
-rwxr-xr-xapps/plugins/puzzles/resync.sh45
1 files changed, 42 insertions, 3 deletions
diff --git a/apps/plugins/puzzles/resync.sh b/apps/plugins/puzzles/resync.sh
index 76679971a4..3431a6f695 100755
--- a/apps/plugins/puzzles/resync.sh
+++ b/apps/plugins/puzzles/resync.sh
@@ -19,19 +19,58 @@ then
19fi 19fi
20 20
21echo "=== POTENTIALLY DANGEROUS OPERATION ===" 21echo "=== POTENTIALLY DANGEROUS OPERATION ==="
22echo "Are you sure you want to remove all files in src/?" 22echo "Are you sure you want to remove all files in src/ and help/?"
23echo -n "If so, type \"yes\" in all caps: " 23echo -n "If so, type \"yes\" in all caps: "
24read ans 24read ans
25if [ "YES" == $ans ] 25if [ "YES" == $ans ]
26then 26then
27 pushd "$(dirname "$0")" > /dev/null 27 pushd "$(dirname "$0")" > /dev/null
28 ROOT="$PWD"
28 29
29 echo "[1/5] Removing current src/ directory" 30 echo "[1/5] Removing current src/ directory"
30 rm -rf src 31 rm -rf src
31 echo "[2/5] Copying new sources" 32 echo "[2/5] Copying new sources"
32 mkdir src 33 mkdir -p src/unfinished
33 cp -r "$1"/{*.c,*.h,*.R,*.but,LICENCE,README} src 34 cp -r "$1"/{*.h,puzzles.but,LICENCE,README,CMakeLists.txt,unfinished} src
35
36 # Parse out definitions of core, core_obj, and common from
37 # CMakeLists. Extract the .c filenames, except malloc.c, and store
38 # in SOURCES.core.
39 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
40 echo "src/printing.c" >> SOURCES.core
41
42 # Parse out puzzle definitions to build SOURCES.games, but
43 # preserve the ability to disable puzzles based on memory size.
44 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
45
46 SRC="$(cat SOURCES.games SOURCES.core | sed 's/src\///' | tr '\n' ' ' | head -c-1) loopy.c pearl.c solo.c"
47 echo "Detected sources:" $SRC
48 pushd "$1" > /dev/null
49 cp -r $SRC "$ROOT"/src
50 popd > /dev/null
51
52 cat src/unfinished/CMakeLists.txt | awk '/puzzle\(/{p=1} p{print} /\)/{p=0}' | grep -Eo "\(.*$" | tr -dc "a-z\n" | awk '{print "src/unfinished/"$0".c"}' | grep -v "group" | grep -v "separate" >> SOURCES.games
53
54 cat <<EOF >> SOURCES.games
55
56/* no c200v2 */
57#if PLUGIN_BUFFER_SIZE > 0x14000
58src/loopy.c
59src/pearl.c
60src/solo.c
61#endif
62EOF
63
64 cat <<EOF > SOURCES
65/* Auto-generated by resync.sh */
66EOF
67 cat SOURCES.rockbox | cpp | grep -vE "^#" >> SOURCES
68 echo -e "\n/* puzzles core sources */" >> SOURCES
69 cat SOURCES.core >> SOURCES
70 rm SOURCES.core
71
34 echo "[3/5] Regenerating help" 72 echo "[3/5] Regenerating help"
73 rm -rf help
35 ./genhelp.sh 74 ./genhelp.sh
36 75
37 echo "[4/5] Staging for commit" 76 echo "[4/5] Staging for commit"