Commit 96104b0c authored by Andreas Klebinger's avatar Andreas Klebinger

banner: Refactor to use boot.sh for booting

This way the shake system can just run this script
instead of relying on the make system.

I also replaced the perl with ghc --interactive invocations.
The perl code was fine, but the shake system doesn't currently
require perl so removing the dependency seems worthwhile.
parent b28c494c
......@@ -3,37 +3,10 @@ include $(TOP)/mk/boilerplate.mk
-include opts.mk
include $(TOP)/mk/target.mk
CLEAN_FILES += $(wildcard banner.*stdin) $(wildcard banner.*stdout)
CLEAN_FILES += banner.stdin banner.stdout
banner.faststdin : banner.stdin.template
perl -0777pe '$$_=$$_ x 3500' banner.stdin.template > banner.faststdin
# Only works because we don't use parallel make
banner.stdin banner.stdout: boot.sh banner.stdin.template banner.stdout.template
bash boot.sh . . $(HC) $(mode)
banner.stdin : banner.stdin.template
perl -0777pe '$$_=$$_ x 35000' banner.stdin.template > banner.stdin
banner.slowstdin : banner.stdin.template
perl -0777pe '$$_=$$_ x 180000' banner.stdin.template > banner.slowstdin
banner.faststdout : banner.stdout.template
perl -0777pe '$$_=$$_ x 3500' banner.stdout.template > banner.faststdout
banner.stdout : banner.stdout.template
perl -0777pe '$$_=$$_ x 35000' banner.stdout.template > banner.stdout
banner.slowstdout : banner.stdout.template
perl -0777pe '$$_=$$_ x 180000' banner.stdout.template > banner.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 :: banner.$(INFIX)stdout banner.$(INFIX)stdin
boot :: banner.stdout banner.stdin
#!/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=3500
NORM_OPTS=35000
SLOW_OPTS=180000 # official shootout setting
case $mode in
"fast"*)
MODE_ARGS=$FAST_OPTS
;;
"slow"*)
MODE_ARGS=$SLOW_OPTS
;;
*)
MODE_ARGS=$NORM_OPTS
;;
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}/banner.stdout.template\" >>= \s -> writeFile \"${output}/banner.stdout\" (concat . replicate ${MODE_ARGS} $ s)"
$HC --interactive -e "readFile \"${src}/banner.stdin.template\" >>= \s -> writeFile \"${output}/banner.stdin\" (concat . replicate ${MODE_ARGS} $ 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