mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-09 21:22:39 -05:00
puzzles: clean up resync.sh script.
This script has grown into a bit of a maintenance nightmare over the years. I've cleaned up and better documented some of the nastier bits. Change-Id: I2bb95a89b1edc9a294d9e1112f5be1b877567356
This commit is contained in:
parent
488306e1eb
commit
334c725a45
1 changed files with 88 additions and 30 deletions
|
|
@ -5,8 +5,8 @@
|
||||||
# and copies just the source files we need from the puzzles source
|
# and copies just the source files we need from the puzzles source
|
||||||
# tree. Handles help generation as well. Stages changes in git.
|
# tree. Handles help generation as well. Stages changes in git.
|
||||||
#
|
#
|
||||||
# Expects a modified Halibut (https://www.fwei.tk/git/halibut) to be
|
# Expects a modified Halibut (https://github.com/built1n/halibut) to
|
||||||
# installed in $PATH. Also requires host CC and lz4 library to be
|
# be installed in $PATH. Also requires host CC and lz4 library to be
|
||||||
# available
|
# available
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -18,6 +18,9 @@ then
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "Resyncing to upstream sources $1"
|
||||||
|
echo "This script assumes you have gcc, lz4, and a custom halibut (https://github.com/built1n/halibut) installed!"
|
||||||
|
|
||||||
echo "=== POTENTIALLY DANGEROUS OPERATION ==="
|
echo "=== POTENTIALLY DANGEROUS OPERATION ==="
|
||||||
echo "Are you sure you want to remove all files in src/ and help/?"
|
echo "Are you sure you want to remove all files in src/ and help/?"
|
||||||
echo -n "If so, type \"yes\" in all caps: "
|
echo -n "If so, type \"yes\" in all caps: "
|
||||||
|
|
@ -27,57 +30,112 @@ then
|
||||||
pushd "$(dirname "$0")" > /dev/null
|
pushd "$(dirname "$0")" > /dev/null
|
||||||
ROOT="$PWD"
|
ROOT="$PWD"
|
||||||
|
|
||||||
echo "[1/5] Removing current src/ directory"
|
echo "[1/6] Removing current src/ directory"
|
||||||
rm -rf src
|
rm -rf src
|
||||||
echo "[2/5] Copying new sources"
|
|
||||||
|
echo "[2/6] Copying new sources"
|
||||||
mkdir -p src/unfinished
|
mkdir -p src/unfinished
|
||||||
cp -r "$1"/{*.h,puzzles.but,LICENCE,README,CMakeLists.txt,unfinished} src
|
cp -r "$1"/{*.h,puzzles.but,LICENCE,README,CMakeLists.txt,unfinished} src
|
||||||
|
|
||||||
# Parse out definitions of core, core_obj, and common from
|
echo "[3/6] Generating SOURCES, SOURCES.games"
|
||||||
# CMakeLists. Extract the .c filenames, except malloc.c, and store
|
|
||||||
# in SOURCES.core.
|
cat <<EOF | tee SOURCES SOURCES.games >/dev/null
|
||||||
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
|
/* !!! DO NOT MODIFY THIS FILE !!! */
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* This file is automatically generated by resync.sh. Any manual
|
||||||
|
* changes here will be overwritten by future resyncs.
|
||||||
|
*
|
||||||
|
* If you wish to change anything in this file, instead edit resync.sh
|
||||||
|
* to accomplish what you want. You have been warned.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* !!! DO NOT MODIFY THIS FILE !!! */
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Parse out definitions of core, core_obj, and common from the
|
||||||
|
# upstream CMakeLists.txt. Extract the .c filenames, except
|
||||||
|
# malloc.c and ps.c, and store in SOURCES.core.
|
||||||
|
EXCLUDE_CORE_REGEX="malloc|ps"
|
||||||
|
|
||||||
|
cat src/CMakeLists.txt |
|
||||||
|
awk '/add_library\(/{p=1} p{printf $0" "} /\)/{if(p) print; p=0}' | # parse out add_library(...)
|
||||||
|
grep -E "core|common" |
|
||||||
|
grep -Po "[a-z0-9\-]*?\.c" |
|
||||||
|
sort -n |
|
||||||
|
grep -vE "$EXCLUDE_CORE_REGEX" |
|
||||||
|
awk '{print "src/"$0}' |
|
||||||
|
uniq > SOURCES.core
|
||||||
|
|
||||||
|
# printing.c is pulled in via platforms/*.cmake. We don't have
|
||||||
|
# that, so must add it ourselves.
|
||||||
echo "src/printing.c" >> SOURCES.core
|
echo "src/printing.c" >> SOURCES.core
|
||||||
|
|
||||||
# Parse out puzzle definitions to build SOURCES.games, but
|
# Parse out puzzle definitions to build SOURCES.games, but exclude
|
||||||
# preserve the ability to disable puzzles based on memory size.
|
# nullgame, and also #ifdef also memory-intensive games on
|
||||||
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
|
# low-memory targets.
|
||||||
|
EXCLUDE_GAMES_ALWAYS="nullgame|group|separate"
|
||||||
|
|
||||||
SRC="$(cat SOURCES.games SOURCES.core | sed 's/src\///' | tr '\n' ' ' | head -c-1) loopy.c pearl.c solo.c"
|
cat src/CMakeLists.txt |
|
||||||
|
awk '/puzzle\(/{p=1} p{print} /\)/{p=0}' | # parse out puzzle(...)
|
||||||
|
grep -Eo "\(.*$" | # parse out only the first argument - this is brittle.
|
||||||
|
tr -dc "a-z\n" |
|
||||||
|
grep -vE "$EXCLUDE_GAMES_ALWAYS" | # exclude nullgame
|
||||||
|
awk '{print "src/"$0".c"}' > SOURCES.games
|
||||||
|
|
||||||
|
SRC="$(cat SOURCES.games SOURCES.core | sed 's/src\///' | tr '\n' ' ' | head -c-1)"
|
||||||
echo "Detected sources:" $SRC
|
echo "Detected sources:" $SRC
|
||||||
pushd "$1" > /dev/null
|
pushd "$1" > /dev/null
|
||||||
cp -r $SRC "$ROOT"/src
|
cp -r $SRC "$ROOT"/src
|
||||||
popd > /dev/null
|
popd > /dev/null
|
||||||
|
|
||||||
echo "#ifndef WIN32" >> SOURCES.games
|
EXCLUDE_GAMES_LOW_MEMORY="loopy|pearl|solo"
|
||||||
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
|
EXCLUDE_GAMES_WIN32="unfinished"
|
||||||
echo "#endif" >> SOURCES.games
|
|
||||||
|
|
||||||
cat <<EOF >> SOURCES.games
|
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 -Ev "$EXCLUDE_GAMES_ALWAYS" >> SOURCES.games
|
||||||
|
|
||||||
/* no c200v2 */
|
# Edit SOURCES.games in-place to conditionally compile games due
|
||||||
#if PLUGIN_BUFFER_SIZE > 0x14000
|
# to either low-memory (EXCLUDE_GAMES_LOW_MEMORY), or win32
|
||||||
src/loopy.c
|
# incompatibility (EXCLUDE_GAMES_WIN32).
|
||||||
src/pearl.c
|
awk -i inplace '{
|
||||||
src/solo.c
|
if ($0 ~ /'"$EXCLUDE_GAMES_WIN32"'/) {
|
||||||
#endif
|
print "#ifndef WIN32"; print $0; print "#endif";
|
||||||
|
}
|
||||||
|
else if ($0 ~ /'"$EXCLUDE_GAMES_LOW_MEMORY"'/) {
|
||||||
|
print "#if PLUGIN_BUFFER_SIZE > 0x14000"; print $0; print "#endif";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
print
|
||||||
|
}
|
||||||
|
}' SOURCES.games
|
||||||
|
|
||||||
|
cat <<EOF >> SOURCES
|
||||||
|
/* rockbox frontend sources, from SOURCES.rockbox */
|
||||||
|
EOF
|
||||||
|
cat SOURCES.rockbox | cpp | grep -vE "^#" | sed '/^$/d' >> SOURCES
|
||||||
|
|
||||||
|
cat <<EOF >> SOURCES
|
||||||
|
|
||||||
|
/* puzzles core sources, from src/CMakeLists.txt */
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
cat <<EOF > 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
|
cat SOURCES.core >> SOURCES
|
||||||
rm SOURCES.core
|
rm SOURCES.core
|
||||||
|
|
||||||
echo "[3/5] Regenerating help"
|
echo "[4/6] Generating help"
|
||||||
rm -rf help
|
rm -rf help
|
||||||
./genhelp.sh
|
./genhelp.sh
|
||||||
|
|
||||||
echo "[4/5] Staging for commit"
|
echo "[5/6] Staging for commit"
|
||||||
git add src help
|
git add src help
|
||||||
echo "[5/5] Successfully resynced with upstream"
|
echo "[6/6] Successfully resynced with upstream"
|
||||||
|
|
||||||
popd > /dev/null
|
popd > /dev/null
|
||||||
else
|
else
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue