DEFERRABLE=1
OPTIONAL=1
-# Extra implementation specific options to pass to runtest.py
-logo_TEST_OPTS = --start-timeout 60 --test-timeout 120
-mal_TEST_OPTS = --start-timeout 60 --test-timeout 120
-miniMAL_TEST_OPTS = --start-timeout 60 --test-timeout 120
-plpgsql_TEST_OPTS = --start-timeout 60 --test-timeout 180
-plsql_TEST_OPTS = --start-timeout 120 --test-timeout 120
-perl6_TEST_OPTS = --test-timeout=60
-
# Run target/rule within docker image for the implementation
DOCKERIZE =
+
#
-# Settings
+# Implementation specific settings
#
IMPLS = ada awk bash basic c d chuck clojure coffee common-lisp cpp crystal cs dart \
# TODO: still need to implement dist
dist_EXCLUDES += guile io julia matlab swift
+
+# Extra options to pass to runtest.py
+logo_TEST_OPTS = --start-timeout 60 --test-timeout 120
+mal_TEST_OPTS = --start-timeout 60 --test-timeout 120
+miniMAL_TEST_OPTS = --start-timeout 60 --test-timeout 120
+plpgsql_TEST_OPTS = --start-timeout 60 --test-timeout 180
+plsql_TEST_OPTS = --start-timeout 120 --test-timeout 120
+perl6_TEST_OPTS = --test-timeout=60
+vimscript_TEST_OPTS = --test-timeout 30
+ifeq ($(MAL_IMPL),vimscript)
+mal_TEST_OPTS = --start-timeout 60 --test-timeout 180
+else ifeq ($(MAL_IMPL),powershell)
+mal_TEST_OPTS = --start-timeout 60 --test-timeout 180
+endif
+
+
#
-# Utility functions
+# Implementation specific utility functions
#
haxe_STEP_TO_PROG_neko = haxe/$($(1)).n
scheme_STEP_TO_PROG_cyclone = scheme/$($(1))
scheme_STEP_TO_PROG_foment = scheme/$($(1)).scm
-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
-# test files will include step 2 tests through tests for the step
-# being tested.
-STEP_TEST_FILES = $(strip $(wildcard \
- $(foreach s,$(if $(strip $(REGRESS)),$(regress_$(2)),$(2)),\
- $(1)/tests/$($(s))$(EXTENSION) tests/$($(s))$(EXTENSION))))
-
# Map of step (e.g. "step8") to executable file for that step
ada_STEP_TO_PROG = ada/$($(1))
awk_STEP_TO_PROG = awk/$($(1)).awk
elm_STEP_TO_PROG = elm/$($(1)).js
+#
+# General settings and utility functions
+#
+
# Needed some argument munging
COMMA = ,
noop =
SPACE = $(noop) $(noop)
export FACTOR_ROOTS := .
+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
+# test files will include step 2 tests through tests for the step
+# being tested.
+STEP_TEST_FILES = $(strip $(wildcard \
+ $(foreach s,$(if $(strip $(REGRESS)),$(regress_$(2)),$(2)),\
+ $(1)/tests/$($(s))$(EXTENSION) tests/$($(s))$(EXTENSION))))
+
# 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))
# 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)
-mal_TEST_OPTS = --start-timeout 60 --test-timeout 180
-else ifeq ($(MAL_IMPL),powershell)
-mal_TEST_OPTS = --start-timeout 60 --test-timeout 180
-endif
-
# Derived lists
STEPS = $(sort $(filter step%,$(.VARIABLES)))
DO_IMPLS = $(filter-out $(SKIP_IMPLS),$(IMPLS))
$(foreach impl,$(DO_IMPLS),\
$(foreach step,$(STEPS),repl^$(impl)^$(step)))))
+
#
# Build rules
#
+# Enable secondary expansion for all rules
+.SECONDEXPANSION:
+
# Build a program in an implementation directory
# Make sure we always try and build first because the dependencies are
# encoded in the implementation Makefile not here
$(call get_build_command,$(impl)) -C $(impl) $(subst $(impl)/,,$(@))))
# Allow IMPL, and IMPL^STEP
-.SECONDEXPANSION:
$(DO_IMPLS): $$(foreach s,$$(STEPS),$$(call $$(@)_STEP_TO_PROG,$$(s)))
-.SECONDEXPANSION:
$(foreach i,$(DO_IMPLS),$(foreach s,$(STEPS),$(i)^$(s))): $$(call $$(word 1,$$(subst ^, ,$$(@)))_STEP_TO_PROG,$$(word 2,$$(subst ^, ,$$(@))))
# Test rules
#
-.SECONDEXPANSION:
$(ALL_TESTS): $$(call $$(word 2,$$(subst ^, ,$$(@)))_STEP_TO_PROG,$$(word 3,$$(subst ^, ,$$(@))))
@$(foreach impl,$(word 2,$(subst ^, ,$(@))),\
$(foreach step,$(word 3,$(subst ^, ,$(@))),\
test: $(ALL_TESTS)
tests: $(ALL_TESTS)
-.SECONDEXPANSION:
$(IMPL_TESTS): $$(filter $$@^%,$$(ALL_TESTS))
-.SECONDEXPANSION:
$(STEP_TESTS): $$(foreach step,$$(subst test^,,$$@),$$(filter %^$$(step),$$(ALL_TESTS)))
dist: $(IMPL_DIST)
-.SECONDEXPANSION:
$(IMPL_DIST):
@echo "----------------------------------------------"; \
$(foreach impl,$(word 2,$(subst ^, ,$(@))),\
docker-build: $(DOCKER_BUILD)
-.SECONDEXPANSION:
$(DOCKER_BUILD):
echo "----------------------------------------------"; \
$(foreach impl,$(word 2,$(subst ^, ,$(@))),\
perf: $(IMPL_PERF)
-.SECONDEXPANSION:
$(IMPL_PERF):
@echo "----------------------------------------------"; \
$(foreach impl,$(word 2,$(subst ^, ,$(@))),\
# REPL invocation rules
#
-.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 get_run_prefix,$(impl),$(step)) ../$(impl)/run'; \
- $(call get_run_prefix,$(impl),$(step)) ../$(impl)/run;))
+ echo 'Running: $(call get_run_prefix,$(impl),$(step)) ../$(impl)/run $(RUN_ARGS)'; \
+ $(call get_run_prefix,$(impl),$(step)) ../$(impl)/run $(RUN_ARGS);))
# Allow repl^IMPL^STEP and repl^IMPL (which starts REPL of stepA)
-.SECONDEXPANSION:
$(IMPL_REPL): $$@^stepA
#
# Utility functions
#
-.SECONDEXPANSION:
print-%:
@echo "$($(*))"
define recur_template
.PHONY: $(1)
$(1): $(2)
-.SECONDEXPANSION:
$(2):
@echo "----------------------------------------------"; \
$$(foreach impl,$$(word 2,$$(subst ^, ,$$(@))),\