From 20e8dea04375f63bb53a13f4455bd834a45672b8 Mon Sep 17 00:00:00 2001 From: Joel Martin Date: Tue, 17 May 2016 21:37:26 -0700 Subject: [PATCH] Refactor to use run scripts, remove *_RUNSTEP - Add */run script for every implementation. - Refactor Clojure build to allow individual jar files for each step. - Update FFI version for es6 and miniMAL to work with newer node versions. The run scripts for the following could use some additional refactoring: - java: build individual step jar, use java -jar instead of mvn to run - plpgsql: maybe combine plpgsql/run and plpgsql/wrap.sh - vhdl: combine vhdl/run and vhdl/run_vhdl.sh - vimscript: combine vimscript/run and vimscript/run_vimscript.sh --- Makefile | 127 +++++++++++-------------------- ada/run | 2 + awk/run | 2 + bash/run | 2 + c/run | 2 + clojure/Makefile | 6 +- clojure/project.clj | 52 ++++++++----- clojure/run | 2 + clojure/src/step0_repl.clj | 3 +- clojure/src/step1_read_print.clj | 3 +- clojure/src/step2_eval.clj | 3 +- clojure/src/step3_env.clj | 3 +- clojure/src/step4_if_fn_do.clj | 3 +- clojure/src/step5_tco.clj | 3 +- clojure/src/step6_file.clj | 3 +- clojure/src/step7_quote.clj | 3 +- clojure/src/step8_macros.clj | 3 +- clojure/src/step9_try.clj | 3 +- coffee/run | 2 + cpp/run | 2 + crystal/run | 2 + cs/run | 2 + d/run | 2 + elisp/run | 2 + elixir/run | 3 + erlang/run | 2 + es6/package.json | 2 +- es6/run | 2 + factor/run | 2 + forth/run | 2 + fsharp/run | 2 + go/run | 2 + groovy/run | 2 + guile/run | 2 + haskell/run | 2 + haxe/run | 8 ++ js/run | 2 + julia/run | 2 + kotlin/run | 2 + lua/run | 2 + make/run | 2 + mal/run | 5 ++ miniMAL/package.json | 2 +- miniMAL/run | 3 + nim/run | 2 + objc/run | 2 + objpascal/run | 2 + ocaml/run | 2 + perl/run | 2 + php/run | 2 + plpgsql/run | 2 + process/guide.md | 18 ++++- ps/run | 2 + python/run | 2 + r/run | 2 + racket/run | 2 + rpython/run | 2 + ruby/run | 2 + rust/run | 2 + swift/run | 2 + swift3/run | 2 + tcl/run | 2 + vb/run | 2 + vhdl/run | 2 + vimscript/run | 3 + 65 files changed, 233 insertions(+), 114 deletions(-) create mode 100755 ada/run create mode 100755 awk/run create mode 100755 bash/run create mode 100755 c/run create mode 100755 clojure/run create mode 100755 coffee/run create mode 100755 cpp/run create mode 100755 crystal/run create mode 100755 cs/run create mode 100755 d/run create mode 100755 elisp/run create mode 100755 elixir/run create mode 100755 erlang/run create mode 100755 es6/run create mode 100755 factor/run create mode 100755 forth/run create mode 100755 fsharp/run create mode 100755 go/run create mode 100755 groovy/run create mode 100755 guile/run create mode 100755 haskell/run create mode 100755 haxe/run create mode 100755 js/run create mode 100755 julia/run create mode 100755 kotlin/run create mode 100755 lua/run create mode 100755 make/run create mode 100755 mal/run create mode 100755 miniMAL/run create mode 100755 nim/run create mode 100755 objc/run create mode 100755 objpascal/run create mode 100755 ocaml/run create mode 100755 perl/run create mode 100755 php/run create mode 100755 plpgsql/run create mode 100755 ps/run create mode 100755 python/run create mode 100755 r/run create mode 100755 racket/run create mode 100755 rpython/run create mode 100755 ruby/run create mode 100755 rust/run create mode 100755 swift/run create mode 100755 swift3/run create mode 100755 tcl/run create mode 100755 vb/run create mode 100755 vhdl/run create mode 100755 vimscript/run diff --git a/Makefile b/Makefile index 0fb7bb3ab7..f8b81b3834 100644 --- a/Makefile +++ b/Makefile @@ -125,12 +125,7 @@ haxe_STEP_TO_PROG_python = haxe/$($(1)).py haxe_STEP_TO_PROG_cpp = haxe/cpp/$($(1)) haxe_STEP_TO_PROG_js = haxe/$($(1)).js -haxe_RUNSTEP_neko = neko ../$(2) $(3) -haxe_RUNSTEP_python = python3 ../$(2) $(3) -haxe_RUNSTEP_cpp = ../$(2) $(3) -haxe_RUNSTEP_js = node ../$(2) $(3) - -opt_DEFERRABLE = $(if $(strip $(DEFERRABLE)),$(if $(filter t true T True TRUE 1 y yes Yes YES,$(DEFERRABLE)),--deferrable,--no-deferrable),--no-deferrable) +opt_DEFERRABLE = $(if $(strip $(DEFERRABLE)),$(if $(filter t true T True TRUE 1 y yes Yes YES,$(DEFERRABLE)),--deferrable,--no-deferrable),--no-deferrable) opt_OPTIONAL = $(if $(strip $(OPTIONAL)),$(if $(filter t true T True TRUE 1 y yes Yes YES,$(OPTIONAL)),--optional,--no-optional),--no-optional) # Return list of test files for a given step. If REGRESS is set then @@ -146,7 +141,7 @@ awk_STEP_TO_PROG = awk/$($(1)).awk bash_STEP_TO_PROG = bash/$($(1)).sh c_STEP_TO_PROG = c/$($(1)) d_STEP_TO_PROG = d/$($(1)) -clojure_STEP_TO_PROG = clojure/src/$($(1)).clj +clojure_STEP_TO_PROG = clojure/target/$($(1)).jar coffee_STEP_TO_PROG = coffee/$($(1)).coffee cpp_STEP_TO_PROG = cpp/$($(1)) crystal_STEP_TO_PROG = crystal/$($(1)) @@ -202,76 +197,44 @@ noop = SPACE = $(noop) $(noop) export FACTOR_ROOTS := . -# Macro for running a step: -# $(1): step (e.g. "stepA") -# $(2): program for step (e.g. result of *_STEP_TO_PROG -# $(3): program arguments -ada_RUNSTEP = ../$(2) $(3) -awk_RUNSTEP = awk -O -f ../$(2) $(3) -bash_RUNSTEP = bash ../$(2) $(3) -c_RUNSTEP = ../$(2) $(3) -d_RUNSTEP = ../$(2) $(3) -clojure_RUNSTEP = lein with-profile +$(1) trampoline run $(3) -coffee_RUNSTEP = coffee ../$(2) $(3) -cpp_RUNSTEP = ../$(2) $(3) -crystal_RUNSTEP = ../$(2) $(3) -cs_RUNSTEP = mono ../$(2) --raw $(3) -elisp_RUNSTEP = emacs -Q --batch --load ../$(2) $(3) -elixir_RUNSTEP = mix $(notdir $(basename $(2))) $(3) -erlang_RUNSTEP = ../$(2) $(3) -es6_RUNSTEP = node ../$(2) $(3) -factor_RUNSTEP = factor ../$(2) $(3) -forth_RUNSTEP = gforth ../$(2) $(3) -fsharp_RUNSTEP = mono ../$(2) --raw $(3) -go_RUNSTEP = ../$(2) $(3) -groovy_RUNSTEP = groovy ../$(2) $(3) -# needs TERM=dumb to work with readline -guile_RUNSTEP = guile --no-auto-compile -L ../guile ../$(2) $(3) -haskell_RUNSTEP = ../$(2) $(3) -haxe_RUNSTEP = python3 ../$(2) $(3) -haxe_RUNSTEP = $(haxe_RUNSTEP_$(HAXE_MODE)) -io_RUNSTEP = env STEP=$($(1)) ./run $(3) -java_RUNSTEP = env STEP=$($(1)) ./run $(3) -julia_RUNSTEP = ../$(2) $(3) -js_RUNSTEP = node ../$(2) $(3) -kotlin_RUNSTEP = java -jar ../$(2) $(3) -lua_RUNSTEP = ../$(2) $(3) -make_RUNSTEP = make --no-print-directory -f ../$(2) $(3) -mal_RUNSTEP = $(call $(MAL_IMPL)_RUNSTEP,stepA,$(call $(MAL_IMPL)_STEP_TO_PROG,stepA),../$(2),") #" -ocaml_RUNSTEP = ../$(2) $(3) -matlab_RUNSTEP = env USE_MATLAB=$(USE_MATLAB) STEP=$($(1)) ./run $(3) -miniMAL_RUNSTEP = miniMAL ../$(2) $(3) -nim_RUNSTEP = ../$(2) $(3) -objc_RUNSTEP = ../$(2) $(3) -objpascal_RUNSTEP = ../$(2) $(3) -perl_RUNSTEP = perl ../$(2) $(3) -php_RUNSTEP = php ../$(2) $(3) -plpgsql_RUNSTEP = ./wrap.sh ../$(2) $(3) -ps_RUNSTEP = gs -q -I./ -dNODISPLAY -- ../$(2) $(3) -python_RUNSTEP = $(PYTHON) ../$(2) $(3) -r_RUNSTEP = Rscript ../$(2) $(3) -racket_RUNSTEP = ../$(2) $(3) -rpython_RUNSTEP = ../$(2) $(3) -ruby_RUNSTEP = ruby ../$(2) $(3) -rust_RUNSTEP = ../$(2) $(3) -scala_RUNSTEP = env STEP=$($(1)) ./run $(3) -swift_RUNSTEP = ../$(2) $(3) -swift3_RUNSTEP = ../$(2) $(3) -tcl_RUNSTEP = tclsh ../$(2) --raw $(3) -vb_RUNSTEP = mono ../$(2) --raw $(3) -vhdl_RUNSTEP = ./run_vhdl.sh ../$(2) $(3) -vimscript_RUNSTEP = ./run_vimscript.sh ../$(2) $(3) - - # DOCKERIZE utility functions lc = $(subst A,a,$(subst B,b,$(subst C,c,$(subst D,d,$(subst E,e,$(subst F,f,$(subst G,g,$(subst H,h,$(subst I,i,$(subst J,j,$(subst K,k,$(subst L,l,$(subst M,m,$(subst N,n,$(subst O,o,$(subst P,p,$(subst Q,q,$(subst R,r,$(subst S,s,$(subst T,t,$(subst U,u,$(subst V,v,$(subst W,w,$(subst X,x,$(subst Y,y,$(subst Z,z,$1)))))))))))))))))))))))))) impl_to_image = kanaka/mal-test-$(call lc,$(1)) actual_impl = $(if $(filter mal,$(1)),$(MAL_IMPL),$(1)) +# Takes impl +# Returns nothing if DOCKERIZE is not set, otherwise returns the +# docker prefix necessary to run make within the docker environment +# for this impl get_build_prefix = $(if $(strip $(DOCKERIZE)),docker run -it --rm -u $(shell id -u) -v $(dir $(abspath $(lastword $(MAKEFILE_LIST)))):/mal -w /mal/$(1) $(if $(filter factor,$(1)),-e FACTOR_ROOTS=$(FACTOR_ROOTS),) $(call impl_to_image,$(1)) ,) -get_run_prefix = $(if $(strip $(DOCKERIZE)),docker run -it --rm -u $(shell id -u) -v $(dir $(abspath $(lastword $(MAKEFILE_LIST)))):/mal -w /mal/$(call actual_impl,$(1)) $(if $(filter factor,$(1)),-e FACTOR_ROOTS=$(FACTOR_ROOTS),) $(call impl_to_image,$(call actual_impl,$(1))) ,) +# Takes impl and step arguments +# Returns a command prefix (docker command and environment variables) +# necessary to launch the given impl and step +get_run_prefix = $(strip $(if $(strip $(DOCKERIZE)),\ + docker run -e STEP=$($2) \ + -it --rm -u $(shell id -u) \ + -v $(dir $(abspath $(lastword $(MAKEFILE_LIST)))):/mal \ + -w /mal/$(call actual_impl,$(1)) \ + $(if $(filter haxe,$(1)),-e HAXE_MODE=$(HAXE_MODE),) \ + $(if $(filter factor,$(1)),-e FACTOR_ROOTS=$(FACTOR_ROOTS),) \ + $(foreach env,$(3),-e $(env)) \ + $(call impl_to_image,$(call actual_impl,$(1))) \ + ,\ + env STEP=$($2) \ + $(if $(filter haxe,$(1)),HAXE_MODE=$(HAXE_MODE),) \ + $(if $(filter factor,$(1)),FACTOR_ROOTS=$(FACTOR_ROOTS),) \ + $(3))) + +# Takes impl and step +# Returns the runtest command prefix (with runtest options) for testing the given step +get_runtest_cmd = $(call get_run_prefix,$(1),$(2),$(if $(filter cs fsharp tcl vb,$(1)),RAW=1,)) \ + ../runtest.py $(TEST_OPTS) $(opt_DEFERRABLE) $(opt_OPTIONAL) $(call $(1)_TEST_OPTS) + +# Takes impl and step +# Returns the runtest command prefix (with runtest options) for testing the given step +get_argvtest_cmd = $(call get_run_prefix,$(1),$(2)) ../run_argv_test.sh vimscript_TEST_OPTS = --test-timeout 30 ifeq ($(MAL_IMPL),vimscript) @@ -330,14 +293,14 @@ $(ALL_TESTS): $$(call $$(word 2,$$(subst ^, ,$$(@)))_STEP_TO_PROG,$$(word 3,$$(s cd $(if $(filter mal,$(impl)),$(MAL_IMPL),$(impl)) && \ $(foreach test,$(call STEP_TEST_FILES,$(impl),$(step)),\ echo '----------------------------------------------' && \ - echo 'Testing $@, step file: $+, test file: $(test)' && \ - echo 'Running: $(call get_run_prefix,$(impl))../runtest.py $(TEST_OPTS) $(opt_DEFERRABLE) $(opt_OPTIONAL) $(call $(impl)_TEST_OPTS) ../$(test) -- $(call $(impl)_RUNSTEP,$(step),$(+))' && \ - $(call get_run_prefix,$(impl))../runtest.py $(TEST_OPTS) $(opt_DEFERRABLE) $(opt_OPTIONAL) $(call $(impl)_TEST_OPTS) ../$(test) -- $(call $(impl)_RUNSTEP,$(step),$(+)) && \ + echo 'Testing $@; step file: $+, test file: $(test)' && \ + echo 'Running: $(call get_runtest_cmd,$(impl),$(step)) $(call $(impl)_TEST_OPTS) ../$(test) -- ../$(impl)/run' && \ + $(call get_runtest_cmd,$(impl),$(step)) $(call $(impl)_TEST_OPTS) ../$(test) -- ../$(impl)/run && \ $(if $(filter tests/step6_file.mal,$(test)),\ echo '----------------------------------------------' && \ echo 'Testing ARGV of $@; step file: $+' && \ - echo 'Running: $(call get_run_prefix,$(impl))../run_argv_test.sh $(call $(impl)_RUNSTEP,$(step),$(+))' && \ - $(call get_run_prefix,$(impl))../run_argv_test.sh $(call $(impl)_RUNSTEP,$(step),$(+)) && ,\ + echo 'Running: $(call get_argvtest_cmd,$(impl),$(step)) ../$(impl)/run ' && \ + $(call get_argvtest_cmd,$(impl),$(step)) ../$(impl)/run && ,\ true && ))\ true)) @@ -392,12 +355,12 @@ $(IMPL_PERF): $(foreach impl,$(word 2,$(subst ^, ,$(@))),\ cd $(if $(filter mal,$(impl)),$(MAL_IMPL),$(impl)); \ echo "Performance test for $(impl):"; \ - echo 'Running: $(call get_run_prefix,$(impl))$(call $(impl)_RUNSTEP,stepA,$(call $(impl)_STEP_TO_PROG,stepA),../tests/perf1.mal)'; \ - $(call get_run_prefix,$(impl))$(call $(impl)_RUNSTEP,stepA,$(call $(impl)_STEP_TO_PROG,stepA),../tests/perf1.mal); \ - echo 'Running: $(call $(impl)_RUNSTEP,stepA,$(call $(impl)_STEP_TO_PROG,stepA),../tests/perf2.mal)'; \ - $(call get_run_prefix,$(impl))$(call $(impl)_RUNSTEP,stepA,$(call $(impl)_STEP_TO_PROG,stepA),../tests/perf2.mal); \ - echo 'Running: $(call $(impl)_RUNSTEP,stepA,$(call $(impl)_STEP_TO_PROG,stepA),../tests/perf3.mal)'; \ - $(call get_run_prefix,$(impl))$(call $(impl)_RUNSTEP,stepA,$(call $(impl)_STEP_TO_PROG,stepA),../tests/perf3.mal)) + echo 'Running: $(call get_run_prefix,$(impl),stepA) ../$(impl)/run ../tests/perf1.mal'; \ + $(call get_run_prefix,$(impl),stepA) ../$(impl)/run ../tests/perf1.mal; \ + echo 'Running: $(call get_run_prefix,$(impl),stepA) ../$(impl)/run ../tests/perf2.mal'; \ + $(call get_run_prefix,$(impl),stepA) ../$(impl)/run ../tests/perf2.mal; \ + echo 'Running: $(call get_run_prefix,$(impl),stepA) ../$(impl)/run ../tests/perf3.mal'; \ + $(call get_run_prefix,$(impl),stepA) ../$(impl)/run ../tests/perf3.mal) # @@ -410,8 +373,8 @@ $(ALL_REPL): $$(call $$(word 2,$$(subst ^, ,$$(@)))_STEP_TO_PROG,$$(word 3,$$(su $(foreach step,$(word 3,$(subst ^, ,$(@))),\ cd $(if $(filter mal,$(impl)),$(MAL_IMPL),$(impl)); \ echo 'REPL implementation $(impl), step file: $+'; \ - echo 'Running: $(call get_run_prefix,$(impl))$(call $(impl)_RUNSTEP,$(step),$(+))'; \ - $(call get_run_prefix,$(impl))$(call $(impl)_RUNSTEP,$(step),$(+));)) + echo 'Running: $(call get_run_prefix,$(impl),$(step)) ../$(impl)/run'; \ + $(call get_run_prefix,$(impl),$(step)) ../$(impl)/run;)) # Allow repl^IMPL^STEP and repl^IMPL (which starts REPL of stepA) .SECONDEXPANSION: diff --git a/ada/run b/ada/run new file mode 100755 index 0000000000..8ba68a5484 --- /dev/null +++ b/ada/run @@ -0,0 +1,2 @@ +#!/bin/bash +exec $(dirname $0)/${STEP:-stepA_mal} "${@}" diff --git a/awk/run b/awk/run new file mode 100755 index 0000000000..72be264a5c --- /dev/null +++ b/awk/run @@ -0,0 +1,2 @@ +#!/bin/bash +exec awk -O -f $(dirname $0)/${STEP:-stepA_mal}.awk "${@}" diff --git a/bash/run b/bash/run new file mode 100755 index 0000000000..536c542f13 --- /dev/null +++ b/bash/run @@ -0,0 +1,2 @@ +#!/bin/bash +exec bash $(dirname $0)/${STEP:-stepA_mal}.sh "${@}" diff --git a/c/run b/c/run new file mode 100755 index 0000000000..8ba68a5484 --- /dev/null +++ b/c/run @@ -0,0 +1,2 @@ +#!/bin/bash +exec $(dirname $0)/${STEP:-stepA_mal} "${@}" diff --git a/clojure/Makefile b/clojure/Makefile index 5405497fae..17fcc593e6 100644 --- a/clojure/Makefile +++ b/clojure/Makefile @@ -1,5 +1,6 @@ SOURCES_BASE = src/readline.clj src/reader.clj src/printer.clj SOURCES_LISP = src/env.clj src/core.clj src/stepA_mal.clj +SRCS = $(SOURCES_BASE) src/env.clj src/core.clj SOURCES = $(SOURCES_BASE) $(SOURCES_LISP) all: deps @@ -10,7 +11,7 @@ deps: lein deps mal.jar: $(SOURCES) - lein with-profile +jar uberjar + lein with-profile stepA uberjar cp target/mal-0.0.1-SNAPSHOT-standalone.jar $@ SHELL := bash @@ -18,6 +19,9 @@ mal: mal.jar cat <(echo -e '#!/bin/sh\nexec java -jar "$$0" "$$@"') mal.jar > $@ chmod +x mal +target/%.jar: src/%.clj $(SRCS) + lein with-profile $(word 1,$(subst _, ,$*)) uberjar + clean: rm -rf target/ mal.jar mal diff --git a/clojure/project.clj b/clojure/project.clj index 7500c11131..acfe822661 100644 --- a/clojure/project.clj +++ b/clojure/project.clj @@ -7,21 +7,39 @@ ;; To run a step with correct readline behavior: ;; lein trampoline with-profile stepX run - ;; To load step in repl: - ;; lein with-profile +stepX repl - :profiles {:step0 {:main step0-repl} - :step1 {:main step1-read-print} - :step2 {:main step2-eval} - :step3 {:main step3-env} - :step4 {:main step4-if-fn-do} - :step5 {:main step5-tco} - :step6 {:main step6-file} - :step7 {:main step7-quote} - :step8 {:main step8-macros} - :step9 {:main step9-try} - :stepA {:main stepA-mal} - :jar {:main stepA-mal - :aot [stepA-mal]}} - - :main stepA-mal) + ;; To generate a executable uberjar (in target/) for a step: + ;; lein with-profile stepX repl + :profiles {:step0 {:main step0-repl + :uberjar-name "step0_repl.jar" + :aot [step0-repl]} + :step1 {:main step1-read-print + :uberjar-name "step1_read_print.jar" + :aot [step1-read-print]} + :step2 {:main step2-eval + :uberjar-name "step2_eval.jar" + :aot [step2-eval]} + :step3 {:main step3-env + :uberjar-name "step3_env.jar" + :aot [step3-env]} + :step4 {:main step4-if-fn-do + :uberjar-name "step4_if_fn_do.jar" + :aot [step4-if-fn-do]} + :step5 {:main step5-tco + :uberjar-name "step5_tco.jar" + :aot [step5-tco]} + :step6 {:main step6-file + :uberjar-name "step6_file.jar" + :aot [step6-file]} + :step7 {:main step7-quote + :uberjar-name "step7_quote.jar" + :aot [step7-quote]} + :step8 {:main step8-macros + :uberjar-name "step8_macros.jar" + :aot [step8-macros]} + :step9 {:main step9-try + :uberjar-name "step9_try.jar" + :aot [step9-try]} + :stepA {:main stepA-mal + :uberjar-name "stepA_mal.jar" + :aot [stepA-mal]}}) diff --git a/clojure/run b/clojure/run new file mode 100755 index 0000000000..94325d438c --- /dev/null +++ b/clojure/run @@ -0,0 +1,2 @@ +#!/bin/bash +exec java -jar $(dirname $0)/target/${STEP:-stepA_mal}.jar "${@}" diff --git a/clojure/src/step0_repl.clj b/clojure/src/step0_repl.clj index 405037a87f..284db3903e 100644 --- a/clojure/src/step0_repl.clj +++ b/clojure/src/step0_repl.clj @@ -1,5 +1,6 @@ (ns step0-repl - (:require [readline])) + (:require [readline]) + (:gen-class)) ;; read diff --git a/clojure/src/step1_read_print.clj b/clojure/src/step1_read_print.clj index 21b297d33d..9fe1ae978c 100644 --- a/clojure/src/step1_read_print.clj +++ b/clojure/src/step1_read_print.clj @@ -2,7 +2,8 @@ (:require [clojure.repl] [readline] [reader] - [printer])) + [printer]) + (:gen-class)) ;; read (defn READ [& [strng]] diff --git a/clojure/src/step2_eval.clj b/clojure/src/step2_eval.clj index eae2432436..e1c02e948a 100644 --- a/clojure/src/step2_eval.clj +++ b/clojure/src/step2_eval.clj @@ -2,7 +2,8 @@ (:require [clojure.repl] [readline] [reader] - [printer])) + [printer]) + (:gen-class)) ;; read (defn READ [& [strng]] diff --git a/clojure/src/step3_env.clj b/clojure/src/step3_env.clj index 084b008fe1..64f9b09dee 100644 --- a/clojure/src/step3_env.clj +++ b/clojure/src/step3_env.clj @@ -3,7 +3,8 @@ [readline] [reader] [printer] - [env])) + [env]) + (:gen-class)) ;; read (defn READ [& [strng]] diff --git a/clojure/src/step4_if_fn_do.clj b/clojure/src/step4_if_fn_do.clj index a12d7617af..71a5718fbc 100644 --- a/clojure/src/step4_if_fn_do.clj +++ b/clojure/src/step4_if_fn_do.clj @@ -4,7 +4,8 @@ [reader] [printer] [env] - [core])) + [core]) + (:gen-class)) ;; read (defn READ [& [strng]] diff --git a/clojure/src/step5_tco.clj b/clojure/src/step5_tco.clj index 443f1e127d..3de1fbd12e 100644 --- a/clojure/src/step5_tco.clj +++ b/clojure/src/step5_tco.clj @@ -4,7 +4,8 @@ [reader] [printer] [env] - [core])) + [core]) + (:gen-class)) ;; read (defn READ [& [strng]] diff --git a/clojure/src/step6_file.clj b/clojure/src/step6_file.clj index ab5842cd3a..7add5ce8b3 100644 --- a/clojure/src/step6_file.clj +++ b/clojure/src/step6_file.clj @@ -4,7 +4,8 @@ [reader] [printer] [env] - [core])) + [core]) + (:gen-class)) ;; read (defn READ [& [strng]] diff --git a/clojure/src/step7_quote.clj b/clojure/src/step7_quote.clj index 21eefbcfbc..79b4588dfe 100644 --- a/clojure/src/step7_quote.clj +++ b/clojure/src/step7_quote.clj @@ -4,7 +4,8 @@ [reader] [printer] [env] - [core])) + [core]) + (:gen-class)) ;; read (defn READ [& [strng]] diff --git a/clojure/src/step8_macros.clj b/clojure/src/step8_macros.clj index 5046f267a6..86b6dac43f 100644 --- a/clojure/src/step8_macros.clj +++ b/clojure/src/step8_macros.clj @@ -5,7 +5,8 @@ [reader] [printer] [env] - [core])) + [core]) + (:gen-class)) ;; read (defn READ [& [strng]] diff --git a/clojure/src/step9_try.clj b/clojure/src/step9_try.clj index a368e2a61e..cf3c227ac5 100644 --- a/clojure/src/step9_try.clj +++ b/clojure/src/step9_try.clj @@ -5,7 +5,8 @@ [reader] [printer] [env] - [core])) + [core]) + (:gen-class)) ;; read (defn READ [& [strng]] diff --git a/coffee/run b/coffee/run new file mode 100755 index 0000000000..b7841f7779 --- /dev/null +++ b/coffee/run @@ -0,0 +1,2 @@ +#!/bin/bash +exec coffee $(dirname $0)/${STEP:-stepA_mal}.coffee "${@}" diff --git a/cpp/run b/cpp/run new file mode 100755 index 0000000000..8ba68a5484 --- /dev/null +++ b/cpp/run @@ -0,0 +1,2 @@ +#!/bin/bash +exec $(dirname $0)/${STEP:-stepA_mal} "${@}" diff --git a/crystal/run b/crystal/run new file mode 100755 index 0000000000..8ba68a5484 --- /dev/null +++ b/crystal/run @@ -0,0 +1,2 @@ +#!/bin/bash +exec $(dirname $0)/${STEP:-stepA_mal} "${@}" diff --git a/cs/run b/cs/run new file mode 100755 index 0000000000..fa517a6ec7 --- /dev/null +++ b/cs/run @@ -0,0 +1,2 @@ +#!/bin/bash +exec mono $(dirname $0)/${STEP:-stepA_mal}.exe ${RAW:+--raw} "${@}" diff --git a/d/run b/d/run new file mode 100755 index 0000000000..8ba68a5484 --- /dev/null +++ b/d/run @@ -0,0 +1,2 @@ +#!/bin/bash +exec $(dirname $0)/${STEP:-stepA_mal} "${@}" diff --git a/elisp/run b/elisp/run new file mode 100755 index 0000000000..84a936e50c --- /dev/null +++ b/elisp/run @@ -0,0 +1,2 @@ +#!/bin/bash +exec emacs -Q --batch --load $(dirname $0)/${STEP:-stepA_mal}.el "${@}" diff --git a/elixir/run b/elixir/run new file mode 100755 index 0000000000..db29600d6f --- /dev/null +++ b/elixir/run @@ -0,0 +1,3 @@ +#!/bin/bash +cd $(dirname $0) +exec mix ${STEP:-stepA_mal} "${@}" diff --git a/erlang/run b/erlang/run new file mode 100755 index 0000000000..8ba68a5484 --- /dev/null +++ b/erlang/run @@ -0,0 +1,2 @@ +#!/bin/bash +exec $(dirname $0)/${STEP:-stepA_mal} "${@}" diff --git a/es6/package.json b/es6/package.json index 08641923d4..fb844da087 100644 --- a/es6/package.json +++ b/es6/package.json @@ -3,7 +3,7 @@ "version": "0.0.1", "description": "Make a Lisp (mal) language implemented in ES6 (ECMAScript 6 / ECMAScript 2015)", "dependencies": { - "ffi": "1.3.x", + "ffi": "2.0.x", "node-uglifier": "0.4.3" } } diff --git a/es6/run b/es6/run new file mode 100755 index 0000000000..24d7d2b86b --- /dev/null +++ b/es6/run @@ -0,0 +1,2 @@ +#!/bin/bash +exec node $(dirname $0)/build/${STEP:-stepA_mal}.js "${@}" diff --git a/factor/run b/factor/run new file mode 100755 index 0000000000..4757514db8 --- /dev/null +++ b/factor/run @@ -0,0 +1,2 @@ +#!/bin/bash +exec factor $(dirname $0)/${STEP:-stepA_mal}/${STEP:-stepA_mal}.factor "${@}" diff --git a/forth/run b/forth/run new file mode 100755 index 0000000000..c7479ea8a9 --- /dev/null +++ b/forth/run @@ -0,0 +1,2 @@ +#!/bin/bash +exec gforth $(dirname $0)/${STEP:-stepA_mal}.fs "${@}" diff --git a/fsharp/run b/fsharp/run new file mode 100755 index 0000000000..fa517a6ec7 --- /dev/null +++ b/fsharp/run @@ -0,0 +1,2 @@ +#!/bin/bash +exec mono $(dirname $0)/${STEP:-stepA_mal}.exe ${RAW:+--raw} "${@}" diff --git a/go/run b/go/run new file mode 100755 index 0000000000..8ba68a5484 --- /dev/null +++ b/go/run @@ -0,0 +1,2 @@ +#!/bin/bash +exec $(dirname $0)/${STEP:-stepA_mal} "${@}" diff --git a/groovy/run b/groovy/run new file mode 100755 index 0000000000..80a452e6c8 --- /dev/null +++ b/groovy/run @@ -0,0 +1,2 @@ +#!/bin/bash +exec groovy $(dirname $0)/${STEP:-stepA_mal}.groovy "${@}" diff --git a/guile/run b/guile/run new file mode 100755 index 0000000000..7f1f2ba330 --- /dev/null +++ b/guile/run @@ -0,0 +1,2 @@ +#!/bin/bash +exec guile --no-auto-compile -L $(dirname $0) $(dirname $0)/${STEP:-stepA_mal}.scm "${@}" diff --git a/haskell/run b/haskell/run new file mode 100755 index 0000000000..8ba68a5484 --- /dev/null +++ b/haskell/run @@ -0,0 +1,2 @@ +#!/bin/bash +exec $(dirname $0)/${STEP:-stepA_mal} "${@}" diff --git a/haxe/run b/haxe/run new file mode 100755 index 0000000000..4adaf760e9 --- /dev/null +++ b/haxe/run @@ -0,0 +1,8 @@ +#!/bin/bash +case ${HAXE_MODE:-neko} in + neko) exec neko $(dirname $0)/${STEP:-stepA_mal}.n "${@}" ;; + python) exec python3 $(dirname $0)/${STEP:-stepA_mal}.py "${@}" ;; + js) exec node $(dirname $0)/${STEP:-stepA_mal}.js "${@}" ;; + cpp) exec $(dirname $0)/cpp/${STEP:-stepA_mal} "${@}" ;; + *) echo "Invalid HAXE_MODE: ${HAXE_MODE}"; exit 2 ;; +esac diff --git a/js/run b/js/run new file mode 100755 index 0000000000..6605303a29 --- /dev/null +++ b/js/run @@ -0,0 +1,2 @@ +#!/bin/bash +exec node $(dirname $0)/${STEP:-stepA_mal}.js "${@}" diff --git a/julia/run b/julia/run new file mode 100755 index 0000000000..2acaf1b202 --- /dev/null +++ b/julia/run @@ -0,0 +1,2 @@ +#!/bin/bash +exec julia $(dirname $0)/${STEP:-stepA_mal}.jl "${@}" diff --git a/kotlin/run b/kotlin/run new file mode 100755 index 0000000000..8840277bd1 --- /dev/null +++ b/kotlin/run @@ -0,0 +1,2 @@ +#!/bin/bash +exec java -jar $(dirname $0)/${STEP:-stepA_mal}.jar "${@}" diff --git a/lua/run b/lua/run new file mode 100755 index 0000000000..f73e5b6f8f --- /dev/null +++ b/lua/run @@ -0,0 +1,2 @@ +#!/bin/bash +exec lua $(dirname $0)/${STEP:-stepA_mal}.lua "${@}" diff --git a/make/run b/make/run new file mode 100755 index 0000000000..f897b62de8 --- /dev/null +++ b/make/run @@ -0,0 +1,2 @@ +#!/bin/bash +exec make --no-print-directory -f $(dirname $0)/${STEP:-stepA_mal}.mk "${@}" diff --git a/mal/run b/mal/run new file mode 100755 index 0000000000..a6f4bfe8d1 --- /dev/null +++ b/mal/run @@ -0,0 +1,5 @@ +#!/bin/bash +cd $(dirname $0) +MAL_FILE=./../mal/${STEP:-stepA_mal}.mal +export STEP=stepA_mal # force MAL_IMPL to use stepA +exec ./../${MAL_IMPL:-js}/run ${MAL_FILE} "${@}" diff --git a/miniMAL/package.json b/miniMAL/package.json index c89a6710dc..3f403d0594 100644 --- a/miniMAL/package.json +++ b/miniMAL/package.json @@ -4,6 +4,6 @@ "description": "Make a Lisp (mal) language implemented in miniMAL", "dependencies": { "minimal-lisp": "0.0.6", - "ffi": "1.3.x" + "ffi": "2.0.x" } } diff --git a/miniMAL/run b/miniMAL/run new file mode 100755 index 0000000000..db4875f09f --- /dev/null +++ b/miniMAL/run @@ -0,0 +1,3 @@ +#!/bin/bash +cd $(dirname $0) +exec miniMAL ./${STEP:-stepA_mal}.json "${@}" diff --git a/nim/run b/nim/run new file mode 100755 index 0000000000..8ba68a5484 --- /dev/null +++ b/nim/run @@ -0,0 +1,2 @@ +#!/bin/bash +exec $(dirname $0)/${STEP:-stepA_mal} "${@}" diff --git a/objc/run b/objc/run new file mode 100755 index 0000000000..8ba68a5484 --- /dev/null +++ b/objc/run @@ -0,0 +1,2 @@ +#!/bin/bash +exec $(dirname $0)/${STEP:-stepA_mal} "${@}" diff --git a/objpascal/run b/objpascal/run new file mode 100755 index 0000000000..8ba68a5484 --- /dev/null +++ b/objpascal/run @@ -0,0 +1,2 @@ +#!/bin/bash +exec $(dirname $0)/${STEP:-stepA_mal} "${@}" diff --git a/ocaml/run b/ocaml/run new file mode 100755 index 0000000000..8ba68a5484 --- /dev/null +++ b/ocaml/run @@ -0,0 +1,2 @@ +#!/bin/bash +exec $(dirname $0)/${STEP:-stepA_mal} "${@}" diff --git a/perl/run b/perl/run new file mode 100755 index 0000000000..05a286f8af --- /dev/null +++ b/perl/run @@ -0,0 +1,2 @@ +#!/bin/bash +exec perl $(dirname $0)/${STEP:-stepA_mal}.pl "${@}" diff --git a/php/run b/php/run new file mode 100755 index 0000000000..1b090b61ba --- /dev/null +++ b/php/run @@ -0,0 +1,2 @@ +#!/bin/bash +exec php $(dirname $0)/${STEP:-stepA_mal}.php "${@}" diff --git a/plpgsql/run b/plpgsql/run new file mode 100755 index 0000000000..8613ff915a --- /dev/null +++ b/plpgsql/run @@ -0,0 +1,2 @@ +#!/bin/bash +exec $(dirname $0)/wrap.sh $(dirname $0)/${STEP:-stepA_mal}.sql "${@}" diff --git a/process/guide.md b/process/guide.md index 5a694375be..ad866963eb 100644 --- a/process/guide.md +++ b/process/guide.md @@ -105,8 +105,22 @@ mkdir quux IMPLS = ... quux ... ... quux_STEP_TO_PROG = mylang/$($(1)).qx -... -quux_RUNSTEP = ../$(2) $(3) +``` + +* Add a "run" script to you implementation directory that listens to + the "STEP" environment variable for the implementation step to run + and defaults to "stepA_mal". The following are examples of "run" + scripts for a compiled language and an interpreted language (where + the interpreter is named "quux"): + +``` +#!/bin/bash +exec $(dirname $0)/${STEP:-stepA_mal} "${@}" +``` + +``` +#!/bin/bash +exec quux $(dirname $0)/${STEP:-stepA_mal}.qx "${@}" ``` This allows you to run tests against your implementation like this: diff --git a/ps/run b/ps/run new file mode 100755 index 0000000000..221d2db29b --- /dev/null +++ b/ps/run @@ -0,0 +1,2 @@ +#!/bin/bash +exec gs -q -I$(dirname $0) -dNODISPLAY -- $(dirname $0)/${STEP:-stepA_mal}.ps "${@}" diff --git a/python/run b/python/run new file mode 100755 index 0000000000..09220ec06a --- /dev/null +++ b/python/run @@ -0,0 +1,2 @@ +#!/bin/bash +exec python $(dirname $0)/${STEP:-stepA_mal}.py "${@}" diff --git a/r/run b/r/run new file mode 100755 index 0000000000..711ef09092 --- /dev/null +++ b/r/run @@ -0,0 +1,2 @@ +#!/bin/bash +exec Rscript $(dirname $0)/${STEP:-stepA_mal}.r "${@}" diff --git a/racket/run b/racket/run new file mode 100755 index 0000000000..923de9df0d --- /dev/null +++ b/racket/run @@ -0,0 +1,2 @@ +#!/bin/bash +exec racket $(dirname $0)/${STEP:-stepA_mal}.rkt "${@}" diff --git a/rpython/run b/rpython/run new file mode 100755 index 0000000000..8ba68a5484 --- /dev/null +++ b/rpython/run @@ -0,0 +1,2 @@ +#!/bin/bash +exec $(dirname $0)/${STEP:-stepA_mal} "${@}" diff --git a/ruby/run b/ruby/run new file mode 100755 index 0000000000..000320bf5f --- /dev/null +++ b/ruby/run @@ -0,0 +1,2 @@ +#!/bin/bash +exec ruby $(dirname $0)/${STEP:-stepA_mal}.rb "${@}" diff --git a/rust/run b/rust/run new file mode 100755 index 0000000000..06764851ce --- /dev/null +++ b/rust/run @@ -0,0 +1,2 @@ +#!/bin/bash +exec $(dirname $0)/target/release/${STEP:-stepA_mal} "${@}" diff --git a/swift/run b/swift/run new file mode 100755 index 0000000000..8ba68a5484 --- /dev/null +++ b/swift/run @@ -0,0 +1,2 @@ +#!/bin/bash +exec $(dirname $0)/${STEP:-stepA_mal} "${@}" diff --git a/swift3/run b/swift3/run new file mode 100755 index 0000000000..8ba68a5484 --- /dev/null +++ b/swift3/run @@ -0,0 +1,2 @@ +#!/bin/bash +exec $(dirname $0)/${STEP:-stepA_mal} "${@}" diff --git a/tcl/run b/tcl/run new file mode 100755 index 0000000000..e73c2a63fe --- /dev/null +++ b/tcl/run @@ -0,0 +1,2 @@ +#!/bin/bash +exec tclsh $(dirname $0)/${STEP:-stepA_mal}.tcl ${RAW:+--raw} "${@}" diff --git a/vb/run b/vb/run new file mode 100755 index 0000000000..fa517a6ec7 --- /dev/null +++ b/vb/run @@ -0,0 +1,2 @@ +#!/bin/bash +exec mono $(dirname $0)/${STEP:-stepA_mal}.exe ${RAW:+--raw} "${@}" diff --git a/vhdl/run b/vhdl/run new file mode 100755 index 0000000000..12de079d1f --- /dev/null +++ b/vhdl/run @@ -0,0 +1,2 @@ +#!/bin/bash +exec $(dirname $0)/run_vhdl.sh $(dirname $0)/${STEP:-stepA_mal} "${@}" diff --git a/vimscript/run b/vimscript/run new file mode 100755 index 0000000000..48e666b057 --- /dev/null +++ b/vimscript/run @@ -0,0 +1,3 @@ +#!/bin/bash +cd $(dirname $0) +exec ./run_vimscript.sh ./${STEP:-stepA_mal}.vim "${@}"