-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
57 lines (50 loc) · 1.17 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
47
48
49
50
51
52
53
54
55
56
57
program := ash
.PHONY = all
all: build
.PHONY = build
build:
@echo "Building..."
@(cd src && go build -o ../bin/$(program) .)
@echo "Build ready: bin/$(program)"
.PHONY = run
run: build
@echo "Running bin/$(program)..."
@bin/$(program)
.PHONY = clean
clean:
@echo "Cleaning up..."
@rm -rf bin
@echo "Done."
.PHONY = test
test:
@echo "Running tests..."
@mod=$(filter-out $@,$(MAKECMDGOALS)); \
if echo $$mod | grep -q ":"; then \
mod_name=$$(echo $$mod | cut -d ':' -f 1); \
test_name=$$(echo $$mod | cut -d ':' -f 2); \
cd src && go test ./$$mod_name -run $$test_name; \
elif [ $$mod ]; then \
cd src && go test ./$$mod; \
else \
(cd src && go test ./ast) && \
(cd src && go test ./code) && \
(cd src && go test ./compiler) && \
(cd src && go test ./evaluator) && \
(cd src && go test ./lexer) && \
(cd src && go test ./object) && \
(cd src && go test ./parser) && \
(cd src && go test ./vm); \
fi
@echo "Done."
.PHONY = bench
bench:
@echo "Running benchmarks..."
@(cd src && go build -o ../bin/bench ./benchmark)
@engine=$(filter-out $@,$(MAKECMDGOALS)); \
if [ $$engine ]; then \
bin/bench -engine=$$engine; \
else \
bin/bench; \
fi
%:
@: