From 854cf2a6badd8597b9d17c21d52e7cf5c6e0b767 Mon Sep 17 00:00:00 2001 From: Dov Murik Date: Mon, 14 Dec 2015 08:50:27 -0500 Subject: [PATCH] Makefile: add REPL invocation rules --- Makefile | 20 ++++++++++++++++++++ README.md | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/Makefile b/Makefile index 5e1efd8b..389c9d89 100644 --- a/Makefile +++ b/Makefile @@ -184,6 +184,11 @@ DOCKER_BUILD = $(foreach impl,$(DO_IMPLS),docker-build^$(impl)) IMPL_PERF = $(filter-out $(EXCLUDE_PERFS),$(foreach impl,$(DO_IMPLS),perf^$(impl))) +IMPL_REPL = $(foreach impl,$(DO_IMPLS),repl^$(impl)) +ALL_REPL = $(strip $(sort \ + $(foreach impl,$(DO_IMPLS),\ + $(foreach step,$(STEPS),repl^$(impl)^$(step))))) + # # Build rules # @@ -264,3 +269,18 @@ $(IMPL_PERF): $(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 $(impl)_RUNSTEP,stepA,$(call $(impl)_STEP_TO_PROG,stepA),../tests/perf3.mal)) + +# REPL invocation rules +# Allow repl^IMPL^STEP and repl^IMPL (which starts REPL of stepA) + +.SECONDEXPANSION: +$(IMPL_REPL): $$@^stepA + +.SECONDEXPANSION: +$(ALL_REPL): $$(call $$(word 2,$$(subst ^, ,$$(@)))_STEP_TO_PROG,$$(word 3,$$(subst ^, ,$$(@)))) + @$(foreach impl,$(word 2,$(subst ^, ,$(@))),\ + $(foreach step,$(word 3,$(subst ^, ,$(@))),\ + cd $(if $(filter mal,$(impl)),$(MAL_IMPL),$(impl)); \ + echo 'REPL implementation $(impl), step file: $+'; \ + echo 'Running: $(call $(impl)_RUNSTEP,$(step),$(+))'; \ + $(call $(impl)_RUNSTEP,$(step),$(+));)) diff --git a/README.md b/README.md index 2051cc95..dc9e46f8 100644 --- a/README.md +++ b/README.md @@ -651,6 +651,39 @@ make MAL_IMPL=ruby "test^mal^step2" make MAL_IMPL=python "test^mal^step2" ``` +### Starting the REPL + +* To start the REPL of an implementation in a specific step: + +``` +make "repl^IMPL^stepX" + +# e.g +make "repl^ruby^step3" +make "repl^ps^step4" +``` + +* If you omit the step, then `stepA` is used: + +``` +make "repl^IMPL" + +# e.g +make "repl^ruby" +make "repl^ps" +``` + +* To start the REPL of the self-hosted implementation, specify `mal` as the + REPL implementation and use the `MAL_IMPL` make variable to change the + underlying host language (default is JavaScript): +``` +make MAL_IMPL=IMPL "repl^mal^stepX" + +# e.g. +make "repl^mal^step2" # js is default +make MAL_IMPL=ruby "repl^mal^step2" +make MAL_IMPL=python "repl^mal" +``` ### Performance tests