2 BINDIR
=$
(dirname $
(readlink
-f "$0"))
5 echo "usage: $0 [-or] gamefilesdir objdir"
6 echo "injects all gamescripts into game28.dta"
7 echo "and all roomscripts into the resp. crm file"
8 echo "if -r is given, the files will be recompiled first"
9 echo "if -o is given, the optimizer will be run first (activates -r)"
13 OPTIMIZER
="$BINDIR"/agsoptimize
15 echo "optimizing $1..."
16 tmp
=ags.optimizer.tmp.$$
17 for opt
in -cmp -pushpop -sourceline -lnl -ll -cmp2 -axmar -mrswap ; do
18 $OPTIMIZER $opt < "$1" > $tmp
19 test "$?" = 0 && mv $tmp "$1"
23 $BINDIR/agssemble
"$1"
27 "$BINDIR"/agsinject
"$1" "$2" "$3"
31 $have_jobflow && printf "%s\n" "$1">&3 || do_optimize_real
"$1"
34 $have_jobflow && printf "%s\n" "$1">&3 || do_recompile_real
"$1"
37 $have_jobflow && printf "%s:%s:%s\n" "$1" "$2" "$3">&3 \
38 || do_inject_real
"$1" "$2" "$3"
41 test "$1" = --jfoptimize && {
45 test "$1" = --jfrecompile && {
46 do_recompile_real
"$2"
49 test "$1" = --jfinject && {
50 arg1
=$
(printf "%s\n" "$2"|cut
-d : -f 1)
51 arg2
=$
(printf "%s\n" "$2"|cut
-d : -f 2)
52 arg3
=$
(printf "%s\n" "$2"|cut
-d : -f 3)
53 do_inject_real
"$arg1" "$arg2" "$arg3"
58 type jobflow
>/dev
/null
2>&1 && have_jobflow
=true
64 while getopts o name
; do
66 o
) optimize
=true
; recompile
=true
;;
71 shift $
(($OPTIND - 1))
76 test -z "$OBJDIR" && usage
78 test -d "$OBJDIR" ||
{
79 echo "error: objdir $OBJDIR not a directory" >&2
83 test -e "$GAMEFILESDIR"/game28.dta ||
{
84 echo "error: "$GAMEFILESDIR"/game28.dta not found"
90 for i
in globalscript dialogscript
; do
91 $optimize && test -e "$OBJDIR"/"$i".s
&& do_optimize
"$OBJDIR"/"$i".s
92 $recompile && test -e "$OBJDIR"/"$i".s
&& do_recompile
"$OBJDIR"/"$i".s
94 test -e "$OBJDIR"/"$i".o ||
{ echo "skipping $i" ; continue ; }
95 do_inject
$cnt "$OBJDIR"/"$i".o
"$GAMEFILESDIR"/game28.dta
99 for i
in 0 `seq 9999` ; do
101 $optimize && test -e "$OBJDIR"/"$i".s
&& do_optimize
"$OBJDIR"/"$i".s
102 $recompile && test -e "$OBJDIR"/"$i".s
&& do_recompile
"$OBJDIR"/"$i".s
104 test -e "$OBJDIR"/"$i".o ||
break
105 do_inject
$cnt "$OBJDIR"/"$i".o
"$GAMEFILESDIR"/game28.dta
109 for i
in `seq 9999` ; do
111 $optimize && test -e "$OBJDIR"/"$i".s
&& do_optimize
"$OBJDIR"/"$i".s
112 $recompile && test -e "$OBJDIR"/"$i".s
&& do_recompile
"$OBJDIR"/"$i".s
114 test -e "$OBJDIR"/"$i".o
&& \
115 do_inject
0 "$OBJDIR"/"$i".o
"$GAMEFILESDIR"/"$i".crm
122 node
="$(mktemp -u)" ||
exit 1
123 mkfifo -m0600 "$node" ||
exit 1
124 eval "exec $fd<> $node"
130 jobflow
-threads=$JOBS -eof=EOF
-exec sh
$0 "$1" {} <&3 &
139 if ! $have_jobflow ; then
142 echo "executing in parallel with jobflow"
145 save_optimize
=$optimize
146 save_recompile
=$recompile
151 if $save_optimize ; then
153 jobflow_iterate
--jfoptimize
156 if $save_recompile ; then
158 jobflow_iterate
--jfrecompile
161 if $save_inject ; then
163 # fixme: injections into game28.dta need to be sequential
164 # only room injections can be done in parallel
166 jobflow_iterate
--jfinject