From 552a271c6fea8d36390858ca6d12c4c98f663002 Mon Sep 17 00:00:00 2001 From: Franklin Wei Date: Sat, 3 Jun 2017 13:45:07 -0400 Subject: puzzles: remove redundant help content It used to be that each puzzle had a complete copy of the entire puzzles manual and the "quick help" text for every single puzzle. This was obviously a waste, so now each puzzle only has the sections of the manual that apply to it, saving about 100KB or so per puzzle. This also has the added benefit of shrinking binary size enough to allow full help support on the c200v2, which has been enabled. Change-Id: I76c799635de058e4a48e0c18b79537857af7cf85 --- apps/plugins/puzzles/genhelp.sh | 70 ++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 35 deletions(-) (limited to 'apps/plugins/puzzles/genhelp.sh') diff --git a/apps/plugins/puzzles/genhelp.sh b/apps/plugins/puzzles/genhelp.sh index f243a1d5f6..293c58bd2b 100755 --- a/apps/plugins/puzzles/genhelp.sh +++ b/apps/plugins/puzzles/genhelp.sh @@ -1,5 +1,5 @@ #!/bin/bash -# usage: ./genhelp.sh > helpcontent.sh +# usage: ./genhelp.sh # # expects halibut to be installed in $PATH: # http://www.chiark.greenend.org.uk/~sgtatham/halibut @@ -16,37 +16,37 @@ cat puzzles.txt.tmp | awk 'BEGIN { a=1; } /Appendix A/ { a = 0; } a==1' > puzzle rm puzzles.txt.tmp -cat <= 0 && $0 !~ /Chapter/ && substr($0, 1, 1) == "#") n += 1;}' - -cat <= 0 && $0 !~ /Chapter/ && substr($0, 1, 1) == "#") n += 1;}' | head -n 1` - -# generate content -cat puzzles.txt | tail -c +$start | awk '{gsub(/\\/,"\\\\"); if($0 !~ /Chapter/ && substr($0, 1, 1) == "#") begin = "\\n"; else begin = ""; last = substr($0, length($0), 1); if(length($0) == 0 || last == "|" || last == "-" || (term == "\\n" && last == "3")) term="\\n"; else term = " "; print "\"" begin $0 term "\"";}' - -cat <= 0 && $0 !~ /Chapter/ && substr($0, 1, 1) == "#") n += 1;}' | awk 'BEGIN { max = 0; last = 0; } { if($0 - last > max) max = $0 - last; last = $0; } END { print max }'` - -# remember number of chapters -num=`cat puzzles.txt | awk 'BEGIN { x = -1; n = 0; } /#Chapter/ { if($0 !~ / 1:/ && $0 !~ / 2:/) { if( x == -1 ) { x = n; } print n - x","; }} {n += length($0) + 1; if(x >= 0 && $0 !~ /Chapter/ && substr($0, 1, 1) == "#") n += 1;}' | wc -l` - -echo "const int help_maxlen = "$maxlen";" -echo "const int help_numchapters = "$num";" +# now split into different files +mkdir -p help + +cat puzzles.txt | awk 'BEGIN { file = "none"; } + /#Chapter/ { + if($0 !~ / 1:/ && $0 !~ / 2:/) + { + if(file != "none") + print ";" > file; + file = "help/"tolower($3$4)".c"; + if($3 ~ "Rectangles") + file = "help/rect.c"; + print "/* auto-generated by genhelp.sh */" > file; + print "/* DO NOT EDIT! */" > file; + print "const char help_text[] = " > file; } + } + file != "none" { + gsub(/\\/,"\\\\"); + if($0 !~ /Chapter/ && substr($0, 1, 1) == "#") + begin = "\\n"; + else begin = ""; + last = substr($0, length($0), 1); + if(length($0) == 0 || last == "|" || last == "-" || (term == "\\n" && last == "3")) + term="\\n"; + else term = " "; + print "\"" begin $0 term "\"" > file; + } + END { + print ";" > file; + } +' + +# generate quick help from gamedesc.txt +cat src/gamedesc.txt | awk -F ":" '{print "const char quick_help_text[] = \""$5"\";" >> "help/"$1".c" }' -- cgit v1.2.3