-
Notifications
You must be signed in to change notification settings - Fork 12
/
Makefile
81 lines (53 loc) · 1.82 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
GXX = g++
GXX_FLAGS = -Wall -Wextra -Wno-unused-parameter -pedantic -std=c++17 -O2 -flto
EMCC = emcc
EMCC_FLAGS = $(GXX_FLAGS) --bind -s FILESYSTEM=0
LIB_SOURCES = $(addprefix src/, enum_data.cpp minion_events.cpp hero_powers.cpp battle.cpp random.cpp)
SOURCES = $(LIB_SOURCES) src/repl.cpp
OBJECTS = $(SOURCES:.cpp=.o)
.PHONY: all web clean
all: hsbg
# Compiling
%.o: %.cpp src/*.hpp
$(GXX) $(GXX_FLAGS) $< -c -o $@
hsbg: $(OBJECTS)
$(GXX) $(GXX_FLAGS) $^ -o $@
debug: $(SOURCES)
$(GXX) -Wall -Wextra -Wno-unused-parameter -pedantic -std=c++11 -g $^ -o hsbg
# Compiling for web
web: web/hsbg.js
web/hsbg.js: $(SOURCES)
$(EMCC) $(EMCC_FLAGS) $(SOURCES) -o $@
# Generate enum data
hsdata/CardDefs.xml:
git submodule init
git submodule update
src/enums.hpp: src/enum_data.cpp
src/enum_data.cpp: scripts/generate_enum_data.py hsdata/CardDefs.xml
python $<
# Generate board data
scripts/generate_board_data: src/generate_board_data.o src/enums.hpp src/board.hpp
$(GXX) $(GXX_FLAGS) $(LIB_SOURCES:.cpp=.o) src/generate_board_data.o -o $@
BOARD_DATA = $(wildcard data/board*.txt)
.DELETE_ON_ERROR: src/board_data.cpp
src/board_data.cpp: scripts/generate_board_data $(BOARD_DATA)
scripts/generate_board_data $(BOARD_DATA) > $@
# log parser
log_parser: $(LIB_SOURCES:.cpp=.o) src/log_parser.o
$(GXX) $(GXX_FLAGS) $^ -o $@
# tournament
tournament: $(LIB_SOURCES:.cpp=.o) src/tournament.o
$(GXX) $(GXX_FLAGS) $^ -o $@
benchmark: $(LIB_SOURCES:.cpp=.o) src/benchmark.o
$(GXX) $(GXX_FLAGS) $^ -o $@
benchmark-profile: $(LIB_SOURCES) src/benchmark.cpp
$(GXX) $(GXX_FLAGS) -g -pg $^ -o $@
variance-benchmark: $(LIB_SOURCES:.cpp=.o) src/variance_benchmark.o
$(GXX) $(GXX_FLAGS) $^ -o $@
# Cleanup
clean:
rm -rf src/*.o
rm -rf web/hsbg.js
rm -rf web/*.wasm
distclean: clean
rm -rf src/enum_data.cpp src/enums.hpp src/board_data.cpp