-
Notifications
You must be signed in to change notification settings - Fork 23
/
makefile
217 lines (153 loc) · 3.53 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
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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
ROOT=$(shell pwd)
all::
clean::
dist_clean:: clean
cd weights && make dist_clean
EMMC_OPTIM_FLAGS=\
-D NDEBUG \
-O3 \
-s DISABLE_EXCEPTION_CATCHING=0
EMMC_DEBUG_FLAGS=\
#-g
EMMC_THREADS_FLAGS=
#-D HAVE_PTHREAD
#-s USE_PTHREADS=1
EMMC_MEMORY_FLAGS=\
-s ALLOW_MEMORY_GROWTH=1
#-s TOTAL_MEMORY=268435456
EMCC=emcc \
-std=gnu++14 \
-stdlib=libc++ \
--bind \
$(EMMC_OPTIM_FLAGS) \
$(EMMC_DEBUG_FLAGS) \
$(EMMC_THREADS_FLAGS) \
$(EMMC_MEMORY_FLAGS)
##
## .CC => .O (javascript)
##
SOURCES=$(shell find src -name "*.cc" | grep -v _test.cc | sed -e's/^.*\///')
OBJECTS=$(SOURCES:%.cc=obj/%.o)
EMCC_LC0=$(EMCC) -I src
obj/%.o:: src/utils/%.cc
@mkdir -p obj
$(EMCC_LC0) $< -o $@
obj/%.o: src/chess/%.cc
@mkdir -p obj
$(EMCC_LC0) $< -o $@
obj/%.o: src/proto/%.cc
@mkdir -p obj
$(EMCC_LC0) $< -o $@
obj/%.o: src/syzygy/%.cc
@mkdir -p obj
$(EMCC_LC0) $< -o $@
obj/%.o: src/mcts/%.cc
@mkdir -p obj
$(EMCC_LC0) $< -o $@
obj/%.o: src/neural/%.cc
@mkdir -p obj
$(EMCC_LC0) $< -o $@
obj/%.o: src/neural/blas/%.cc
@mkdir -p obj
$(EMCC_LC0) $< -o $@
obj/%.o: src/benchmark/%.cc
@mkdir -p obj
$(EMCC_LC0) $< -o $@
obj/%.o: src/%.cc
@mkdir -p obj
$(EMCC_LC0) $< -o $@
clean::
rm -f $(OBJECTS)
##
## BLAS (debug)
##
#
#WEIGHTS_FILE=weights/weights_9155.txt.gz
#TEST_FILE=weights/test_9155.txt.gz
#
#weights.txt: $(WEIGHTS_FILE)
# gunzip -c $< > $@
#
#www/weights.txt.gz : $(WEIGHTS_FILE)
# cp $< $@
#
#www/test.txt.gz : $(TEST_FILE)
# cp $< $@
#
#clean::
# rm -f weights.txt
#
#dist_clean::
# rm -f www/weights.txt.gz www/test.txt.gz
#
#$(TARGETS): $(OBJECTS) weights.txt $(MAIN_JS)
# $(EMCC) --preload-file weights.txt --pre-js $(MAIN_JS) -o www/lc0.js $(OBJECTS)
##
## Bundled networks
##
WEIGHTS_LIST=weights/bundled.txt
WEIGHTS_FILES=$(shell cat $(WEIGHTS_LIST))
COPIED_WEIGHTS_FILES=$(WEIGHTS_FILES:%=www/%)
all:: www/networks.txt $(COPIED_WEIGHTS_FILES)
$(WEIGHTS_FILES:%=weights/%):
cd weights && make
www/%: weights/% $(WEIGHTS_LIST)
cp $< $@
www/networks.txt: $(WEIGHTS_LIST)
cp $< $@
dist_clean::
rm -f www/networks.txt $(COPIED_WEIGHTS_FILES)
##
## chessboardjs
##
CHESSBOARD_FILES=\
chessboard-0.3.0.css \
chessboard-0.3.0.js \
chessboard-0.3.0.min.css \
chessboard-0.3.0.min.js \
img/chesspieces
CHESSBOARD_WWW_FILES=$(CHESSBOARD_FILES:%=www/%)
CHESSBOARD_RELEASE=libs/chessboardjs/releases/0.3.0
chessboard: $(CHESSBOARD_WWW_FILES)
$(CHESSBOARD_WWW_FILES):
cp $(CHESSBOARD_RELEASE)/js/chessboard-0.3.0.js www/chessboard-0.3.0.js
cp $(CHESSBOARD_RELEASE)/js/chessboard-0.3.0.min.js www/chessboard-0.3.0.min.js
cp $(CHESSBOARD_RELEASE)/css/chessboard-0.3.0.css www/chessboard-0.3.0.css
cp $(CHESSBOARD_RELEASE)/css/chessboard-0.3.0.min.css www/chessboard-0.3.0.min.css
rm -rf www/img/chesspieces
mkdir -p www/img
cp -r $(CHESSBOARD_RELEASE)/img/chesspieces www/img/chesspieces
clean_chessboard:
rm -rf www/img/chesspieces
rmdir -p www/img 2>/dev/null || true
rm -f $(CHESSBOARD_WWW_FILES)
all:: chessboard
dist_clean:: clean_chessboard
##
## protobuf
##
all:: www/pb.proto
www/pb.proto: libs/lczero-common/proto/net.proto
cp $< $@
dist_clean::
rm -f www/pb.proto
##
## LINK
##
TARGETS=\
www/lc0.js \
www/lc0.wasm
ADDITIONAL_OBJECTS=\
www/lc0.wast \
www/lc0.data \
www/lc0.html
MAIN_JS=main.js
all:: $(TARGETS)
dist_clean::
rm -f $(TARGETS) $(ADDITIONAL_OBJECTS)
$(TARGETS): $(OBJECTS) $(MAIN_JS)
$(EMCC) --pre-js $(MAIN_JS) -o www/lc0.js $(OBJECTS)
run_server:
cd $(ROOT)/www && python -m SimpleHTTPServer 8000
run_test:
'/Applications/Google Chrome.app/Contents/MacOS/Google Chrome' http://localhost:8000/engine.html