VB.Net, C#: fix cmd line arg handling with --raw
[jackhill/mal.git] / Makefile
1 #
2 # Command line settings
3 #
4
5 MAL_IMPL = js
6
7 PYTHON = python
8
9 #
10 # Settings
11 #
12
13 IMPLS = bash c clojure coffee cs go java js make mal perl php ps \
14 python r ruby rust vb
15
16 step0 = step0_repl
17 step1 = step1_read_print
18 step2 = step2_eval
19 step3 = step3_env
20 step4 = step4_if_fn_do
21 step5 = step5_tco
22 step6 = step6_file
23 step7 = step7_quote
24 step8 = step8_macros
25 step9 = step9_try
26 stepA = stepA_interop
27
28 EXCLUDE_TESTS += test^bash^step5 # no stack exhaustion or completion
29 EXCLUDE_TESTS += test^c^step5 # segfault
30 EXCLUDE_TESTS += test^cs^step5 # fatal stack overflow fault
31 EXCLUDE_TESTS += test^make^step5 # no TCO capability/step
32 EXCLUDE_TESTS += test^mal^step5 # no TCO capability/step
33 EXCLUDE_TESTS += test^go^step5 # test completes, even at 100,000
34 EXCLUDE_TESTS += test^php^step5 # test completes, even at 100,000
35 EXCLUDE_TESTS += test^ruby^step5 # test completes, even at 100,000
36 EXCLUDE_TESTS += test^rust^step5 # no catching stack overflows
37
38 # interop tests now implemented yet
39 EXCLUDE_TESTS += test^cs^stepA test^java^stepA test^mal^stepA \
40 test^mal^step0 test^php^stepA test^ps^stepA \
41 test^python^stepA test^ruby^stepA
42
43 EXCLUDE_PERFS = perf^mal # TODO: fix this
44
45 #
46 # Utility functions
47 #
48
49 STEP_TEST_FILES = $(strip $(wildcard $(1)/tests/$($(2)).mal) $(wildcard tests/$($(2)).mal))
50
51 bash_STEP_TO_PROG = bash/$($(1)).sh
52 c_STEP_TO_PROG = c/$($(1))
53 clojure_STEP_TO_PROG = clojure/src/$($(1)).clj
54 coffee_STEP_TO_PROG = coffee/$($(1)).coffee
55 cs_STEP_TO_PROG = cs/$($(1)).exe
56 go_STEP_TO_PROG = go/$($(1))
57 java_STEP_TO_PROG = java/src/main/java/mal/$($(1)).java
58 js_STEP_TO_PROG = js/$($(1)).js
59 make_STEP_TO_PROG = make/$($(1)).mk
60 mal_STEP_TO_PROG = mal/$($(1)).mal
61 perl_STEP_TO_PROG = perl/$($(1)).pl
62 php_STEP_TO_PROG = php/$($(1)).php
63 ps_STEP_TO_PROG = ps/$($(1)).ps
64 python_STEP_TO_PROG = python/$($(1)).py
65 r_STEP_TO_PROG = r/$($(1)).r
66 ruby_STEP_TO_PROG = ruby/$($(1)).rb
67 rust_STEP_TO_PROG = rust/target/$($(1))
68 vb_STEP_TO_PROG = vb/$($(1)).exe
69
70
71 bash_RUNSTEP = bash ../$(2) $(3)
72 c_RUNSTEP = ../$(2) $(3)
73 clojure_RUNSTEP = lein with-profile +$(1) trampoline run $(3)
74 coffee_RUNSTEP = coffee ../$(2) $(3)
75 cs_RUNSTEP = mono ../$(2) --raw $(3)
76 go_RUNSTEP = ../$(2) $(3)
77 java_RUNSTEP = mvn -quiet exec:java -Dexec.mainClass="mal.$($(1))" -Dexec.args="--raw$(if $(3), $(3),)"
78 js_RUNSTEP = node ../$(2) $(3)
79 make_RUNSTEP = make -f ../$(2) $(3)
80 mal_RUNSTEP = $(call $(MAL_IMPL)_RUNSTEP,$(1),$(call $(MAL_IMPL)_STEP_TO_PROG,stepA),../$(2),") #"
81 perl_RUNSTEP = perl ../$(2) $(3)
82 php_RUNSTEP = php ../$(2) $(3)
83 ps_RUNSTEP = $(4)gs -q -I./ -dNODISPLAY -- ../$(2) $(3)$(4)
84 python_RUNSTEP = $(PYTHON) ../$(2) $(3)
85 r_RUNSTEP = Rscript ../$(2) $(3)
86 ruby_RUNSTEP = ruby ../$(2) $(3)
87 rust_RUNSTEP = ../$(2) $(3)
88 vb_RUNSTEP = mono ../$(2) --raw $(3)
89
90 # Extra options to pass to runtest.py
91 cs_TEST_OPTS = --redirect
92 mal_TEST_OPTS = --redirect --start-timeout 60 --test-timeout 120
93 vb_TEST_OPTS = --redirect
94
95
96 # Derived lists
97 STEPS = $(sort $(filter step%,$(.VARIABLES)))
98 IMPL_TESTS = $(foreach impl,$(IMPLS),test^$(impl))
99 STEP_TESTS = $(foreach step,$(STEPS),test^$(step))
100 ALL_TESTS = $(filter-out $(EXCLUDE_TESTS),\
101 $(strip $(sort \
102 $(foreach impl,$(IMPLS),\
103 $(foreach step,$(STEPS),test^$(impl)^$(step))))))
104
105 IMPL_STATS = $(foreach impl,$(IMPLS),stats^$(impl))
106 IMPL_STATS_LISP = $(foreach impl,$(IMPLS),stats-lisp^$(impl))
107
108 IMPL_PERF = $(filter-out $(EXCLUDE_PERFS),$(foreach impl,$(IMPLS),perf^$(impl)))
109
110 #
111 # Build rules
112 #
113
114 # Build a program in 'c' directory
115 c/%:
116 $(MAKE) -C $(dir $(@)) $(notdir $(@))
117
118 # Allow test, test^STEP, test^IMPL, and test^IMPL^STEP
119 .SECONDEXPANSION:
120 $(IMPL_TESTS): $$(filter $$@^%,$$(ALL_TESTS))
121
122 .SECONDEXPANSION:
123 $(STEP_TESTS): $$(foreach step,$$(subst test^,,$$@),$$(filter %^$$(step),$$(ALL_TESTS)))
124
125 .SECONDEXPANSION:
126 $(ALL_TESTS): $$(call $$(word 2,$$(subst ^, ,$$(@)))_STEP_TO_PROG,$$(word 3,$$(subst ^, ,$$(@))))
127 @$(foreach impl,$(word 2,$(subst ^, ,$(@))),\
128 $(foreach step,$(word 3,$(subst ^, ,$(@))),\
129 cd $(if $(filter mal,$(impl)),$(MAL_IMPL),$(impl)); \
130 $(foreach test,$(call STEP_TEST_FILES,$(impl),$(step)),\
131 echo '----------------------------------------------'; \
132 echo 'Testing $@, step file: $+, test file: $(test)'; \
133 echo 'Running: ../runtest.py $(call $(impl)_TEST_OPTS) ../$(test) -- $(call $(impl)_RUNSTEP,$(step),$(+))'; \
134 ../runtest.py $(call $(impl)_TEST_OPTS) ../$(test) -- $(call $(impl)_RUNSTEP,$(step),$(+)))))
135
136 test: $(ALL_TESTS)
137 tests: $(ALL_TESTS)
138
139
140 # Stats rules
141
142 stats: $(IMPL_STATS)
143 stats-lisp: $(IMPL_STATS_LISP)
144
145 .SECONDEXPANSION:
146 $(IMPL_STATS):
147 @echo "----------------------------------------------"; \
148 $(foreach impl,$(word 2,$(subst ^, ,$(@))),\
149 echo "Stats for $(impl):"; \
150 $(MAKE) --no-print-directory -C $(impl) stats)
151
152 .SECONDEXPANSION:
153 $(IMPL_STATS_LISP):
154 @echo "----------------------------------------------"; \
155 $(foreach impl,$(word 2,$(subst ^, ,$(@))),\
156 echo "Stats (lisp only) for $(impl):"; \
157 $(MAKE) --no-print-directory -C $(impl) stats-lisp)
158
159
160 # Performance test rules
161
162 perf: $(IMPL_PERF)
163
164 .SECONDEXPANSION:
165 $(IMPL_PERF):
166 @echo "----------------------------------------------"; \
167 $(foreach impl,$(word 2,$(subst ^, ,$(@))),\
168 cd $(if $(filter mal,$(impl)),$(MAL_IMPL),$(impl)); \
169 echo "Performance test for $(impl):"; \
170 echo 'Running: $(call $(impl)_RUNSTEP,stepA,$(call $(impl)_STEP_TO_PROG,stepA),../tests/perf1.mal)'; \
171 $(call $(impl)_RUNSTEP,stepA,$(call $(impl)_STEP_TO_PROG,stepA),../tests/perf1.mal); \
172 echo 'Running: $(call $(impl)_RUNSTEP,stepA,$(call $(impl)_STEP_TO_PROG,stepA),../tests/perf2.mal)'; \
173 $(call $(impl)_RUNSTEP,stepA,$(call $(impl)_STEP_TO_PROG,stepA),../tests/perf2.mal))
174