-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
89 lines (71 loc) · 2.29 KB
/
Copy pathMakefile
File metadata and controls
89 lines (71 loc) · 2.29 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
CXX := g++
CXXFLAGS := -std=c++17 -Wall -Wextra -pedantic
SRC_DIR := src
TEST_DIR := test
BUILD_DIR := build
TARGET := $(BUILD_DIR)/zenpp
SOURCES := $(SRC_DIR)/main.cpp $(SRC_DIR)/lexer.cpp $(SRC_DIR)/parser.cpp
DEFAULT_TEST ?= $(TEST_DIR)/test.zpp
RUN_ARG := $(word 2,$(MAKECMDGOALS))
.PHONY: help build run repl test test-all bench embed-stdlib build-web run-web test-web clean
help:
@echo "Available targets:"
@echo " make build - Build $(TARGET)"
@echo " make run - Start REPL"
@echo " make run path/to.x.zpp - Run a .zpp file"
@echo " make repl - Start REPL"
@echo " make test - Validate test.zpp against output.txt"
@echo " make bench - Run interpreter benchmarks"
@echo " make test-all - Run all_features_test.zpp"
@echo " make build-web - Build web/zenpp.js + web/zenpp.wasm (emscripten)"
@echo " make run-web - Serve web/ on localhost:8080"
@echo " make test-web - Run web smoke + runtime wasm test"
@echo " make clean - Remove build artifacts"
build: $(TARGET)
$(TARGET): $(SOURCES)
@mkdir -p $(BUILD_DIR)
$(CXX) $(CXXFLAGS) $(SOURCES) -o $(TARGET)
run: build
@if [ -n "$(RUN_ARG)" ]; then \
$(TARGET) "$(RUN_ARG)"; \
else \
$(TARGET); \
fi
repl: build
$(TARGET)
test: build
@bash $(TEST_DIR)/validate_test.sh
test-all: build
$(TARGET) $(TEST_DIR)/all_features_test.zpp
bench: build
@bash $(TEST_DIR)/bench.sh $(TARGET)
embed-stdlib:
@echo 'R"STDLIB(' > src/stdlib_embed.inc
@cat stdlib/math.zpp >> src/stdlib_embed.inc
@echo "" >> src/stdlib_embed.inc
@cat stdlib/ds.zpp >> src/stdlib_embed.inc
@echo ')STDLIB"' >> src/stdlib_embed.inc
build-web: embed-stdlib
@mkdir -p website
emcc -std=c++17 -O2 \
src/main.cpp src/lexer.cpp src/parser.cpp \
--no-entry \
-s MODULARIZE=1 \
-s EXPORT_NAME=Zenpp \
-s EXPORTED_FUNCTIONS='["_zenpp_eval","_free"]' \
-s EXPORTED_RUNTIME_METHODS='["cwrap","UTF8ToString"]' \
-s DISABLE_EXCEPTION_CATCHING=0 \
-o website/zenpp.js
run-web:
@cd website && python3 -m http.server 8080
test-web: build-web
@bash $(TEST_DIR)/web_smoke.sh
@node $(TEST_DIR)/web_runtime_test.js
clean:
rm -rf $(BUILD_DIR)
ifneq ($(filter run,$(MAKECMDGOALS)),)
ifneq ($(RUN_ARG),)
$(RUN_ARG):
@:
endif
endif