Commit 62c4dac3 authored by Andreas Klebinger's avatar Andreas Klebinger

awards: Generate stdout using a boot.sh script and ghci

We used to use perl and run it directly from the make file.
This doesn't really work for the shake system. Instead we can now
invoke boot.sh for both systems which will generate the stdout files.

Also got rid of the perl dependency in the process and use ghci instead.
parent 96104b0c
......@@ -3,32 +3,15 @@ include $(TOP)/mk/boilerplate.mk
-include opts.mk
include $(TOP)/mk/target.mk
# When you change these, make sure to update the repetition factor in the perl
# expression below
# When you change these, make sure to update the boot.sh
# script as well
FAST_OPTS = 2000
NORM_OPTS = 20000
SLOW_OPTS = 100000
CLEAN_FILES += awards.stdout awards.slowstdout
# Keep the repetition factor (10 and 50) up to date with the OPTS above!
awards.stdout : awards.faststdout
perl -0777pe '$$_=$$_ x 10' awards.faststdout > awards.stdout
awards.stdout : awards.out_template
./boot.sh . . $(HC) $(mode)
awards.slowstdout : awards.faststdout
perl -0777pe '$$_=$$_ x 50' awards.faststdout > awards.slowstdout
# Since we only decide here what the INFIX is, it's required to first run `make
# boot` and only then `make` with the same $mode (otherwise `make` doesn't
# "see" the file and doesn't call `runstdtest` correctly)
ifeq "$(mode)" "slow"
INFIX = slow
else
ifeq "$(mode)" "fast"
INFIX = fast
else
INFIX =
endif
endif
boot :: awards.$(INFIX)stdout
boot :: awards.stdout
#!/bin/bash
# Arguments:
# $1 - src folder
# $2 - output folder
# $3 - path to ghc
# $4 - mode
set -e
src=${1:-.}
output=${2:-.}
HC=${3:-ghc}
mode=${4:-norm}
EXE=""
if [[ $(shell uname -s | grep -c 'MSYS\|MINGW') -eq 1 ]]
then
EXE=".exe"
fi
FAST_OPTS=2000
NORM_OPTS=20000
SLOW_OPTS=100000
case $mode in
"fast"*)
MODE_ARGS=$FAST_OPTS
REPS=1
;;
"slow"*)
MODE_ARGS=$SLOW_OPTS
REPS=50
;;
*)
MODE_ARGS=$NORM_OPTS
REPS=10
;;
esac
set -e
set -x
# We could use perl/python for this. But it's not much faster than ghci and adds additional dependencies.
# We could use bash directly. But it's incredibly slow on windows.
# So instead we just use ghci which is fast enough for this purpose.
$HC --interactive -e "readFile \"${src}/awards.out_template\" >>= \s -> writeFile \"${output}/awards.stdout\" (concat . replicate ${REPS} $ s)"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment