-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
160 lines (124 loc) · 5.1 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
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
# The user.mk is used for adaption to a computer configuration.
# You can specify STARCRAFTPATH, CPPCHECK, MAKEFLAGS, DEPLOYMODE, DONOTBUILD, KARLPARAMS.
-include user.mk
LIBRARIES = utils engine plan expert
EXECUTABLES = karl tests bwmapmodifier
BASEOUTPATH = ./out/
COVERAGEPATH = ./coverage/
LIBPATH = ./lib/
BOOST_PATH = ./includes/boost/
MYBWAPIDATAPATH = ./bwapi-data/
MAPSPATH = $(MYBWAPIDATAPATH)maps/
CPPCHECKDEFINES = -UBOOST_BORLAND_DEBUG -UBOOST_DEBUG_PYTHON -UBOOST_ALL_DYN_LINK -U__BORLANDC__ -U_RTLDLL -UBOOST_ABI_PREFIX -UBOOST_ABI_SUFFIX -UBOOST_ASSERT_CONFIG
LIBFILES = $(addprefix $(LIBPATH)lib, $(addsuffix .a, $(LIBRARIES)))
COVERAGELIBFILES = $(addprefix $(LIBPATH)libcoverage_, $(addsuffix .a, $(LIBRARIES)))
EXEFILES = $(addsuffix .exe, $(EXECUTABLES))
MODULES = $(LIBRARIES) $(EXECUTABLES)
MODULEFILES = $(LIBFILES) $(EXEFILES)
ifndef CPPCHECK
CPPCHECK = cppcheck
endif
ifndef STARCRAFTMAPSPATH
ifdef STARCRAFTPATH
STARCRAFTMAPSPATH = $(STARCRAFTPATH)Maps/bw-karl/
endif
endif
ifndef BWAPIDATAPATH
ifdef STARCRAFTPATH
BWAPIDATAPATH = $(STARCRAFTPATH)bwapi-data/
endif
endif
ifndef DEPLOYMODE
DEPLOYMODE = single
endif
ifndef KARLPARAMS
KARLPARAMS = --hud --speed=0 --secure --terrain --webgui --disable GiveUpExpert
endif
KARLEXE = karl.exe
TESTSEXE = tests.exe
ifndef DONOTBUILD
KARLEXE-DONOTBUILD = $(KARLEXE)
TESTSEXE-DONOTBUILD = $(TESTSEXE)
endif
all: $(MODULEFILES)
run: $(KARLEXE-DONOTBUILD) deploy-$(DEPLOYMODE)
$(KARLEXE) --parallel $(KARLPARAMS)
runseq: $(KARLEXE-DONOTBUILD) deploy-$(DEPLOYMODE)
$(KARLEXE) $(KARLPARAMS)
debug: $(KARLEXE-DONOTBUILD) deploy-$(DEPLOYMODE)
gdb --args $(KARLEXE) $(KARLPARAMS)
test-smart-turn: $(KARLEXE-DONOTBUILD) $(STARCRAFTMAPSPATH)test-smart-turn-around.scx deploy-test-smart-turn
$(KARLEXE) --parallel --hud --speed=100 --only TestSmartTurnAroundExpert
ifndef EXPERIMENT_UNITTYPE
EXPERIMENT_UNITTYPE="Terran Marine"
endif
ifndef EXPERIMENT_TYPE
EXPERIMENT_TYPE=sametype
endif
ifndef EXPERIMENT_REPETITIONS
EXPERIMENT_REPETITIONS=2
endif
ifdef EXPERIMENT_NODRAW
EXPERIMENT_NODRAW=--nodraw
endif
learning-fight-winnable: $(KARLEXE-DONOTBUILD) $(STARCRAFTMAPSPATH)learn-fight-winnable-1.scx $(STARCRAFTMAPSPATH)learn-fight-winnable-2.scx $(STARCRAFTMAPSPATH)learn-fight-winnable-3.scx $(STARCRAFTMAPSPATH)learn-fight-winnable-4.scx deploy-learning-fight-winnable
$(KARLEXE) --secure --webgui --hud --speed=0 --only LearningFightWinnableExperimentExpert --experiment $(EXPERIMENT_TYPE) --unittype $(EXPERIMENT_UNITTYPE) --mappath $(STARCRAFTMAPSPATH) --repetitions $(EXPERIMENT_REPETITIONS) $(EXPERIMENT_NODRAW)
test: $(TESTSEXE-DONOTBUILD)
@echo ' ##############################################################################'
@$(TESTSEXE) -p
showtest: $(TESTSEXE-DONOTBUILD)
@echo ' ##############################################################################'
$$(TESTSEXE) -l test_suite
testcov: coverage_tests.exe
$< -p
@for module in $(LIBRARIES) tests; do \
$(MAKE) $(MAKEFLAGS) -C ./sources/$$module/ gen-coverage ; \
done
DOXYGEN-exists: ; @command -v doxygen > /dev/null || ( echo "Doxygen is required to build the docs." && exit 1 )
DOT-exists: ; @command -v dot > /dev/null || ( echo "Dot (from graphviz package) is required to build class hierarchy graphs in the docs." && exit 1 )
doc: DOXYGEN-exists DOT-exists
@echo "Generating documentation in ./doxygen/html..."
@doxygen ./doxygen/Doxyfile
define LIB_template
lib/lib$(1).a: .FORCE | $(BASEOUTPATH)
@$$(MAKE) $$(MAKEFLAGS) -C ./sources/$(1)/ all
lib/libcoverage_$(1).a: .FORCE | $(BASEOUTPATH)
@$$(MAKE) $$(MAKEFLAGS) -C ./sources/$(1)/ coverage
endef
define EXE_template
$(1).exe: $(LIBFILES) .FORCE | $(BASEOUTPATH)
@$$(MAKE) $$(MAKEFLAGS) -C ./sources/$(1)/ all
coverage_$(1).exe: $(COVERAGELIBFILES) .FORCE | $(BASEOUTPATH) $(COVERAGEPATH)
@$$(MAKE) $$(MAKEFLAGS) -C ./sources/$(1)/ coverage
endef
$(foreach lib,$(LIBRARIES),$(eval $(call LIB_template,$(lib))))
$(foreach exe,$(EXECUTABLES),$(eval $(call EXE_template,$(exe))))
cleancov:
rm -rf $(COVERAGEPATH) $(BASEOUTPATH)coverage_*/ $(LIBPATH)libcoverage_*.a
clean: cleancov
rm -rf $(BASEOUTPATH)
rm -f $(MODULEFILES)
rm -rf doxygen/html
lines:
wc -l sources/*/*.*pp
$(BASEOUTPATH):
mkdir $(BASEOUTPATH)
$(COVERAGEPATH):
mkdir $(COVERAGEPATH)
$(STARCRAFTMAPSPATH):
mkdir $(STARCRAFTMAPSPATH)
CPPCHECK-exists: ; @command -v $(CPPCHECK) > /dev/null || ( echo "cppcheck is required." && exit 1 )
cppcheck: CPPCHECK-exists
$(CPPCHECK) -j4 -I./includes/ -i$(BOOST_PATH) --std=c++11 --enable=all --max-configs=1 --library=std $(CPPCHECKDEFINES) sources/*/*.cpp --xml 2> cppcheck-errors.xml
$(STARCRAFTMAPSPATH)%.scx: $(MAPSPATH)%.scx | $(STARCRAFTMAPSPATH)
cp $< $@
$(STARCRAFTMAPSPATH)learn-fight-winnable-%.scx: $(MAPSPATH)template-fight-winnable.scx | $(STARCRAFTMAPSPATH)
cp $< $@
ifdef STARCRAFTPATH
deploy-%: $(MYBWAPIDATAPATH)bwapi-%.ini
cp -f $< $(BWAPIDATAPATH)bwapi.ini
else
deploy-%: $(MYBWAPIDATAPATH)bwapi-%.ini
@echo "Unable to deploy since STARCRAFTPATH is unknown."
endif
.FORCE: