1
1
mirror of https://github.com/kanaka/mal.git synced 2024-09-21 18:48:12 +03:00

Merge pull request #131 from dubek/repl-invocation

Makefile: add REPL invocation rules
This commit is contained in:
Joel Martin 2015-12-14 12:39:48 -06:00
commit 78410fdff6
2 changed files with 53 additions and 0 deletions

View File

@ -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),$(+));))

View File

@ -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