-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
46 lines (40 loc) · 1.5 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
RUSTFLAGS = -C opt-level=3 -C target-cpu=native -C panic=abort
tests: nullary-tests unary-tests
nullary-tests: $(addprefix out/nullary/, $(addsuffix .s, $(basename $(notdir $(wildcard src/nullary/*.rs)))))
@echo "using RUSTFLAGS=$(RUSTFLAGS)"
@failures=0; successes=0; \
for file in $^; do \
if [ 2 -ne $$(wc -l <$$file) ]; then \
echo "[0;31mtest $$file failed[0m - test output:"; \
cat $$file; \
failures=$$((failures + 1)); \
else \
echo "[0;32mtest $$file passed[0m"; \
successes=$$((successes + 1)); \
fi \
done; \
echo "nullary tests run - [0;32m$$successes successes[0m, [0;31m$$failures failures[0m";
unary-tests: $(addprefix out/unary/, $(addsuffix .s, $(basename $(notdir $(wildcard src/unary/*.rs)))))
@echo "using RUSTFLAGS=$(RUSTFLAGS)"
@failures=0; successes=0; \
for file in $^; do \
if [ 3 -ne $$(wc -l <$$file) ]; then \
echo "[0;31mtest $$file failed[0m - test output:"; \
cat $$file; \
failures=$$((failures + 1)); \
else \
echo "[0;32mtest $$file passed[0m"; \
successes=$$((successes + 1)); \
fi \
done; \
echo "unary tests run - [0;32m$$successes successes[0m, [0;31m$$failures failures[0m";
out/nullary/%.s: src/nullary/%.rs
@mkdir -p out/nullary
rustc $< --crate-type=lib --emit=asm $(RUSTFLAGS) -o $@
@sed -n -i -e '/^$(notdir $(basename $@))/,/retq/p' $@
out/unary/%.s: src/unary/%.rs
@mkdir -p out/unary
rustc $< --crate-type=lib --emit=asm $(RUSTFLAGS) -o $@
@sed -n -i -e '/^$(notdir $(basename $@))/,/retq/p' $@
clean:
rm -r out