forked from anyaevostinar/SymbulationEmp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
194 lines (148 loc) · 7.95 KB
/
Copy pathMakefile
File metadata and controls
194 lines (148 loc) · 7.95 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# Project-specific settings
TEST_DIR := source/catch
EMP_DIR := Empirical/include
SGP_DIR := signalgp-lite/include
CEREAL_DIR := signalgp-lite/third-party/cereal/include
TAG_NUM_BITS = 32
# Flags to use regardless of compiler
VENDORIZE_EMP_FLAGS := -DUIT_VENDORIZE_EMP -DUIT_SUPPRESS_MACRO_INSEEP_WARNINGS
COMPILE_TIME_ARGS := -DTAG_NUM_BITS=$(TAG_NUM_BITS)
CFLAGS_all := -Wall -Wno-unused-function -std=c++20 $(COMPILE_TIME_ARGS) -I$(EMP_DIR)/ -I$(SGP_DIR)/ -I$(CEREAL_DIR)/ ${VENDORIZE_EMP_FLAGS}
# Native compiler information
CXX_nat := g++
CFLAGS_nat := -O3 -DNDEBUG -pthread $(CFLAGS_all)
CFLAGS_nat_debug := -g -DEMP_TRACK_MEM -pthread $(CFLAGS_all)
CFLAGS_nat_coverage := --coverage -pthread $(CFLAGS_all)
# Emscripten compiler information
CXX_web := emcc
OFLAGS_web_all := -s "EXPORTED_RUNTIME_METHODS=['ccall', 'cwrap', 'stringToUTF8', 'UTF8ToString']" -s TOTAL_MEMORY=268435456 --js-library $(EMP_DIR)/emp/web/library_emp.js -s EXPORTED_FUNCTIONS="['_main', '_empCppCallback', '_empDoCppCallback']" -s DISABLE_EXCEPTION_CATCHING=1 -s NO_EXIT_RUNTIME=1 -s ASSERTIONS=1 #--embed-file configs
OFLAGS_web := -Oz -DNDEBUG
OFLAGS_web_debug := -g4 -Oz -pedantic -Wno-dollar-in-identifier-extension
CFLAGS_web := $(CFLAGS_all) $(OFLAGS_web) $(OFLAGS_web_all)
CFLAGS_web_debug := $(CFLAGS_all) $(OFLAGS_web_debug) $(OFLAGS_web_all)
# Compiling different modes
default: default-mode
@echo Built default version using 'make default-mode'. To use other modes, use the following:
@echo Efficient mode: make efficient-mode
@echo Lysis mode: make lysis-mode
@echo PGG mode: make pgg-mode
@echo SGP mode: make sgp-mode
@echo To build the web version use: make web
native: default-mode
web: symbulation.js
all: default-mode efficient-mode lysis-mode pgg-mode sgp-mode symbulation.js
default-mode: source/native/symbulation_default.cc
$(CXX_nat) $(CFLAGS_nat) source/native/symbulation_default.cc -o symbulation_default
efficient-mode: source/native/symbulation_efficient.cc
$(CXX_nat) $(CFLAGS_nat) source/native/symbulation_efficient.cc -o symbulation_efficient
lysis-mode: source/native/symbulation_lysis.cc
$(CXX_nat) $(CFLAGS_nat) source/native/symbulation_lysis.cc -o symbulation_lysis
pgg-mode: source/native/symbulation_pgg.cc
$(CXX_nat) $(CFLAGS_nat) source/native/symbulation_pgg.cc -o symbulation_pgg
sgp-mode: source/native/symbulation_sgp.cc
$(CXX_nat) $(CFLAGS_nat) source/native/symbulation_sgp.cc -o symbulation_sgp
symbulation.js: source/web/symbulation-web.cc
$(CXX_web) $(CFLAGS_web) source/web/symbulation-web.cc -o web/symbulation.js
# Debugging
debug:
@echo Please specify the mode to debug using the following:
@echo Default mode: make debug-default
@echo Efficient mode: make debug-efficient
@echo Lysis mode: make debug-lysis
@echo PGG mode: make debug-pgg
@echo SGP mode: make debug-sgp
debug-default: CFLAGS_nat := $(CFLAGS_nat_debug)
debug-default: default-mode
default-debug: debug-default
debug-efficient: CFLAGS_nat := $(CFLAGS_nat_debug)
debug-efficient: efficient-mode
efficient-debug: debug-efficient
debug-lysis: CFLAGS_nat := $(CFLAGS_nat_debug)
debug-lysis: lysis-mode
lysis-debug: debug-lysis
debug-pgg: CFLAGS_nat := $(CFLAGS_nat_debug)
debug-pgg: pgg-mode
pgg-debug: debug-pgg
debug-sgp: CFLAGS_nat := $(CFLAGS_nat_debug)
debug-sgp: sgp-mode
sgp-debug: debug-sgp
debug-web: CFLAGS_web := $(CFLAGS_web_debug)
debug-web: symbulation.js
web-debug: debug-web
# Debugging information
print-%: ; @echo '$(subst ','\'',$*=$($*))'
# Testing
test:
$(CXX_nat) $(CFLAGS_nat) $(TEST_DIR)/main.cc -o symbulation.test
./symbulation.test ~[integration]
@echo To run only the tests for each mode, use the following:
@echo Default mode testing: make test-default
@echo Efficient mode testing: make test-efficient
@echo Lysis mode testing: make test-lysis
@echo PGG mode testing: make test-pgg
@echo SGP mode testing: make test-sgp
test-debug:
$(CXX_nat) $(CFLAGS_nat_debug) $(TEST_DIR)/main.cc -o symbulation.test
./symbulation.test ~[integration]
@echo To debug and test for each mode, use the following:
@echo Default mode: make test-debug-default
@echo Efficient mode: make test-debug-efficient
@echo Lysis mode: make test-debug-lysis
@echo PGG mode: make test-debug-pgg
@echo SGP mode: make test-debug-sgp
test-default:
$(CXX_nat) $(CFLAGS_nat) $(TEST_DIR)/main.cc -o symbulation.test
./symbulation.test [default] || { gdb ./$@.out --ex="catch throw" --ex="set confirm off" --ex="run" --ex="backtrace" --ex="quit"; exit 1; }
test-debug-default:
$(CXX_nat) $(CFLAGS_nat_debug) $(TEST_DIR)/main.cc -o symbulation.test
./symbulation.test [default] || { gdb ./$@.out --ex="catch throw" --ex="set confirm off" --ex="run" --ex="backtrace" --ex="quit"; exit 1; }
test-efficient:
$(CXX_nat) $(CFLAGS_nat) $(TEST_DIR)/main.cc -o symbulation.test
./symbulation.test [efficient] || { gdb ./$@.out --ex="catch throw" --ex="set confirm off" --ex="run" --ex="backtrace" --ex="quit"; exit 1; }
test-debug-efficient:
$(CXX_nat) $(CFLAGS_nat_debug) $(TEST_DIR)/main.cc -o symbulation.test
./symbulation.test [efficient] || { gdb ./$@.out --ex="catch throw" --ex="set confirm off" --ex="run" --ex="backtrace" --ex="quit"; exit 1; }
test-lysis:
$(CXX_nat) $(CFLAGS_nat) $(TEST_DIR)/main.cc -o symbulation.test
./symbulation.test [lysis] || { gdb ./$@.out --ex="catch throw" --ex="set confirm off" --ex="run" --ex="backtrace" --ex="quit"; exit 1; }
test-debug-lysis:
$(CXX_nat) $(CFLAGS_nat_debug) $(TEST_DIR)/main.cc -o symbulation.test
./symbulation.test [lysis] || { gdb ./$@.out --ex="catch throw" --ex="set confirm off" --ex="run" --ex="backtrace" --ex="quit"; exit 1; }
test-pgg:
$(CXX_nat) $(CFLAGS_nat) $(TEST_DIR)/main.cc -o symbulation.test
./symbulation.test [pgg] || { gdb ./$@.out --ex="catch throw" --ex="set confirm off" --ex="run" --ex="backtrace" --ex="quit"; exit 1; }
test-debug-pgg:
$(CXX_nat) $(CFLAGS_nat_debug) $(TEST_DIR)/main.cc -o symbulation.test
./symbulation.test [pgg] || { gdb ./$@.out --ex="catch throw" --ex="set confirm off" --ex="run" --ex="backtrace" --ex="quit"; exit 1; }
./symbulation.test [pgg] || { gdb ./symbulation.test --ex="catch throw" --ex="set confirm off" --ex="run" --ex="backtrace" --ex="quit"; exit 1; }
test-sgp:
$(CXX_nat) $(CFLAGS_nat) $(TEST_DIR)/main.cc -o symbulation.test
./symbulation.test [sgp] || { gdb ./$@.out --ex="catch throw" --ex="set confirm off" --ex="run" --ex="backtrace" --ex="quit"; exit 1; }
test-sgp-all:
$(CXX_nat) $(CFLAGS_nat) $(TEST_DIR)/main.cc -o symbulation.test
./symbulation.test [sgp],[sgp-integration] || { gdb ./$@.out --ex="catch throw" --ex="set confirm off" --ex="run" --ex="backtrace" --ex="quit"; exit 1; }
test-debug-sgp:
$(CXX_nat) $(CFLAGS_nat_debug) $(TEST_DIR)/main.cc -o symbulation.test
./symbulation.test [sgp] || { gdb ./$@.out --ex="catch throw" --ex="set confirm off" --ex="run" --ex="backtrace" --ex="quit"; exit 1; }
test-debug-events:
$(CXX_nat) $(CFLAGS_nat_debug) $(TEST_DIR)/main.cc -o symbulation.test
./symbulation.test [events] || { gdb ./$@.out --ex="catch throw" --ex="set confirm off" --ex="run" --ex="backtrace" --ex="quit"; exit 1; }
test-executable:
$(CXX_nat) $(CFLAGS_nat) $(TEST_DIR)/main.cc -o symbulation.test
test-executable-debug:
$(CXX_nat) $(CFLAGS_nat_debug) $(TEST_DIR)/main.cc -o symbulation.test
test-all:
$(CXX_nat) $(CFLAGS_nat) $(TEST_DIR)/main.cc -o symbulation.test
./symbulation.test || { gdb ./$@.out --ex="catch throw" --ex="set confirm off" --ex="run" --ex="backtrace" --ex="quit"; exit 1; }
test-debug-all:
$(CXX_nat) $(CFLAGS_nat_debug) $(TEST_DIR)/main.cc -o symbulation.test
./symbulation.test || { gdb ./$@.out --ex="catch throw" --ex="set confirm off" --ex="run" --ex="backtrace" --ex="quit"; exit 1; }
# Extras
.PHONY: clean test serve
serve:
python3 -m http.server
clean:
rm -f symbulation* web/symbulation.js web/*.js.map web/*.js.map *~ source/*.o
coverage:
$(CXX_nat) $(CFLAGS_nat_coverage) $(TEST_DIR)/main.cc -o symbulation.test
./symbulation.test || { gdb ./symbulation.test --ex="catch throw" --ex="set confirm off" --ex="run" --ex="backtrace" --ex="quit"; exit 1; }