From 2c2a20f522d558445400853c44a348611fd12f71 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Sun, 16 Oct 2016 20:34:32 +0200 Subject: Docker --- Dockerfile | 14 ++++++++++++++ README.md | 29 ++++++++++++++++++++--------- compile.c | 7 +++---- iclean.icl | 14 +++++++------- 4 files changed, 44 insertions(+), 20 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ffc1058 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM camilstaps/clean:itasks + +RUN apt-get update -qq && apt-get install -qq libreadline-dev + +RUN touch /home/.iclean_history + +RUN mkdir -p /usr/src/iclean +COPY . /usr/src/iclean +WORKDIR /usr/src/iclean + +RUN make -B + +ENTRYPOINT "./iclean" +CMD [] diff --git a/README.md b/README.md index 82c68bc..9fcde4c 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,12 @@ # iClean Interactive Clean -This module allows you to execute [Clean][clean] commands interactively, similar to GHCi or the Python shell. Functionality is very limited. In particular there is **no memory**, so you're restricted to one-liners. +This module allows you to evaluate [Clean][] expressions interactively, similar +to GHCi or the Python shell. Functionality is very limited. In particular there +is **no memory**, so you're restricted to one-liners. -Copyright © 2015 Camil Staps. This project is licensed under the MIT license. For more details, see the LICENSE file. +Copyright © 2016 Camil Staps. This project is licensed under the MIT +license. For more details, see the LICENSE file. ## Example session @@ -15,18 +18,26 @@ Copyright © 2015 Camil Staps. This project is licensed under the MIT licens λ. [Ctrl-D] $ -## Installation +## Usage +Use `docker pull camilstaps/iclean` to pull the latest iClean version. - make iclean - -## Running -Use either `./iclean` or `make run`. You can of course add the executable `iclean` to your path. +Run iClean with `docker run --rm -it camilstaps/iclean`. If you want history, +add `-v ~/.iclean_history:/home/.iclean_history` and `touch ~/.iclean_history` +on the host. Make it an alias: -Disabling displaying `65536` and the execution times after a session (which is a Clean default) can be done by adding `-nr` and `-nt` to the command line arguments, respectively. You may want to make this an alias. +``` +alias iclean="docker run --rm -it -v ~/.iclean_history:/home/.iclean_history camilstaps/iclean" +``` + +## Without Docker +Use `make iclean` to build. + +Use either `./iclean` or `make run`. You can of course add the executable +`iclean` to your path. ## Todo * Implement memory (e.g. to first declare a function / constant and then use it) * Allow extra imports -[clean]:http://clean.cs.ru.nl/Clean +[Clean]:http://clean.cs.ru.nl/Clean diff --git a/compile.c b/compile.c index 1411d94..03fe833 100644 --- a/compile.c +++ b/compile.c @@ -67,11 +67,11 @@ int64_t compile(CleanString path, CleanString module) { } // Build command: - // cd "" && clm -ms -o + // cd "" && clm -ms -nw -b -nt -o char cmd[182]; - snprintf(cmd, 182, "cd \"%s\" && clm -I $CLEAN_HOME/lib/StdLib -I " + snprintf(cmd, 181, "cd \"%s\" && clm -ms -nw -I $CLEAN_HOME/lib/StdLib -I " "$CLEAN_HOME/lib/Generics -I $CLEAN_HOME/lib/Dynamics -dynamics " - "-I $CLEAN_HOME/lib/Gast -ms -nw -b -nt %s -o %s", + "-I $CLEAN_HOME/lib/Gast -b -nt %s -o %s", pathchars, modulechars, modulechars); free(pathchars); @@ -115,4 +115,3 @@ int64_t run(CleanString executable) { free(execchars); return r; } - diff --git a/iclean.icl b/iclean.icl index 92c9020..4daba82 100644 --- a/iclean.icl +++ b/iclean.icl @@ -34,12 +34,13 @@ import ExtraString // SETTINGS temp_path :== "/tmp/" temp_module :== "iclean" -readline_history :== "/home/camil/.iclean_history" -template :== [ "import StdEnv" - , "import StdMaybe" - , "import StdDynamic" - , "import genLibTest" - ] +readline_history :== "/home/.iclean_history" +template :== map ((+++) "import ") + [ "StdEnv" + , "StdMaybe" + , "StdDynamic" + , "genLibTest" + ] // END SETTINGS temp_file :== temp_path +++ temp_module +++ ".icl" @@ -112,4 +113,3 @@ run :: !String !*World -> (!Int, !*World) run _ _ = code { ccall run "S:I:A" } - -- cgit v1.2.3