git @ Cat's Eye Technologies Flobnar / 399b1f4
Update to "standard" build/run/test system w/ hastec HTML5 demo. Chris Pressey 2 years ago
9 changed file(s) with 74 addition(s) and 25 deletion(s). Raw diff Collapse all Expand all
0 *.hi
01 *.o
1 *.hi
2 flobnar
2 *.jsmod
3 bin/*.exe
4 demo/flobnar.js
+0
-5
.hgignore less more
0 syntax: glob
1
2 *.o
3 *.hi
4 flobnar
+0
-2
.hgtags less more
0 1be0dac045fab383fe071919f1fb0174228350f7 rel_0_1_2011_1214
1 79b1ba067b9384bff14c5154642668cbb06ee71b rel_0_1_2014_0819
0 #!/bin/sh
1
2 THIS=`realpath $0`
3 DIR=`dirname $THIS`
4 NAME=`basename $THIS`
5 SRC=$DIR/../src
6 if [ -x $DIR/$NAME.exe ] ; then
7 exec $DIR/$NAME.exe $*
8 elif command -v runhaskell 2>&1 >/dev/null ; then
9 exec runhaskell -i$SRC $SRC/Main.hs $*
10 elif command -v runhugs 2>&1 >/dev/null ; then
11 exec runhugs -i$SRC $SRC/Main.hs $*
12 else
13 echo "Cannot run $NAME; neither $NAME.exe, nor runhaskell, nor runhugs found."
14 exit 1
15 fi
11
22 PROG=flobnar
33
4 if [ x`which ghc` = x -a x`which runhugs` = x ]; then
5 echo "Neither ghc nor runhugs found on search path."
6 exit 1
4 if command -v ghc >/dev/null 2>&1; then
5 echo "building $PROG.exe with ghc"
6 (cd src && ghc --make Main.hs -o ../bin/$PROG.exe)
7 else
8 echo "ghc not found, not building $PROG.exe"
79 fi
810
9 mkdir -p bin
10
11 if [ x`which ghc` = x -o ! x$USE_HUGS = x ]; then
12 # create script to run with Hugs
13 cat >bin/$PROG <<'EOF'
14 #!/bin/sh
15 THIS=`realpath $0`
16 DIR=`dirname $THIS`/../src
17 runhugs $DIR/Main.hs $*
18 EOF
19 chmod 755 bin/$PROG
11 if command -v hastec >/dev/null 2>&1; then
12 echo "building $PROG.js with hastec"
13 (cd src && hastec --make HasteMain.hs -o ../demo/$PROG.js)
2014 else
21 cd src && ghc --make Main.hs -o ../bin/$PROG
15 echo "hastec not found, not building $PROG.js"
2216 fi
0 document.getElementById('installation').innerHTML = (
1 '<textarea id="prog" rows="10" cols="80"></textarea>' +
2 '<div><button id="run-button">Run</button></div>' +
3 '<pre id="result"></pre>'
4 );
0 <!DOCTYPE html>
1 <head>
2 <meta charset="utf-8">
3 <title>Flobnar</title>
4 </head>
5 <body>
6
7 <h1>Flobnar</h1>
8
9 <p>(Flobnar.hs compiled to .js by <code>hastec</code>, running in HTML5 document)</p>
10
11 <div id="installation"></div>
12
13 <script src="flobnar-hastec-launcher.js"></script>
14 <script src="flobnar.js"></script>
15 </body>
0 module Main where
1
2 import Haste
3 import Haste.DOM
4 import Haste.Events
5
6 import Flobnar
7
8 main = withElems ["prog", "result", "run-button"] driver
9
10 escapeHTML "" = ""
11 escapeHTML ('<' : rest) = "&lt;" ++ escapeHTML rest
12 escapeHTML ('>' : rest) = "&gt;" ++ escapeHTML rest
13 escapeHTML ('&' : rest) = "&amp;" ++ escapeHTML rest
14 escapeHTML (c : rest) = (c : escapeHTML rest)
15
16 driver [progElem, resultElem, runButtonElem] = do
17 onEvent runButtonElem Click $ \_ -> execute
18 where
19 execute = do
20 Just prog <- getValue progElem
21 setProp resultElem "innerHTML" (escapeHTML $ showRun prog)
00 #!/bin/sh
11
2 ./build.sh && falderal -b README.markdown
2 #APPLIANCES="tests/appliances/flobnar.md"
3 falderal -b $APPLIANCES README.markdown