summaryrefslogtreecommitdiff
path: root/apps/plugins/puzzles/genhelp.sh
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/puzzles/genhelp.sh')
-rwxr-xr-xapps/plugins/puzzles/genhelp.sh27
1 files changed, 23 insertions, 4 deletions
diff --git a/apps/plugins/puzzles/genhelp.sh b/apps/plugins/puzzles/genhelp.sh
index 3df7706b5d..588eff4c97 100755
--- a/apps/plugins/puzzles/genhelp.sh
+++ b/apps/plugins/puzzles/genhelp.sh
@@ -1,8 +1,8 @@
1#!/bin/bash 1#!/bin/bash
2# usage: ./genhelp.sh 2# usage: ./genhelp.sh
3# 3#
4# Expects halibut to be installed in $PATH: 4# Expects a modified version of `halibut' to be installed in $PATH:
5# https://www.fwei.tk/git/halibut 5# https://github.com/built1n/halibut
6# 6#
7# Also requires host CC and lz4 library to be available 7# Also requires host CC and lz4 library to be available
8 8
@@ -36,6 +36,9 @@ BEGIN {
36 if($3 ~ "Rectangles") 36 if($3 ~ "Rectangles")
37 file = "help/rect.c"; 37 file = "help/rect.c";
38 38
39 if($3 ~ "Train")
40 file = "help/tracks.c";
41
39 print "/* auto-generated by genhelp.sh (intermediate file) */" > file; 42 print "/* auto-generated by genhelp.sh (intermediate file) */" > file;
40 print "/* DO NOT EDIT! */" > file; 43 print "/* DO NOT EDIT! */" > file;
41 print "const char help_text[] = " > file; 44 print "const char help_text[] = " > file;
@@ -87,8 +90,24 @@ do
87 mv $f.tmp $f 90 mv $f.tmp $f
88done 91done
89 92
90# generate quick help from all the .R files 93# Generate quick help by parsing the CMakeLists.txt file to isolate
91cat src/*.R | awk 'print_next { print_next = 0; print; } /!begin/ && />/ && /gamedesc.txt/ { print_next = 1; }' | awk -F ":" '{print "const char quick_help_text[] = \""$5"\";" >> "help/"$1".c" }' 94# the "Objective" text for each puzzle.
95cat <<EOF > parsed_cmakelists.txt
96function(puzzle NAME)
97 cmake_parse_arguments(OPT
98 "" "DISPLAYNAME;DESCRIPTION;OBJECTIVE;WINDOWS_EXE_NAME" "" \${ARGN})
99
100 message("\${NAME}:\${OPT_OBJECTIVE}")
101endfunction()
102EOF
103
104# This parses out the puzzle(...) definitions from CMakeLists.
105
106# TODO: Perhaps ask Simon to include special header/footer comments to
107# make this less brittle?
108cat src/CMakeLists.txt | awk '/puzzle\(/{p=1} p{print} /\)/{p=0}' >> parsed_cmakelists.txt
109cmake -P parsed_cmakelists.txt 2>&1 | awk -F ":" '{print "const char quick_help_text[] = \""$2"\";" >> "help/"$1".c" }'
92 110
111rm parsed_cmakelists.txt
93rm puzzles.txt 112rm puzzles.txt
94rm compress 113rm compress