This repository has been archived by the owner on Feb 13, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 119
/
Makefile
349 lines (289 loc) · 17.4 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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
SHELL := /bin/bash
# All modules of the platform are dynamically linked, so rust's `libstd` is copied into the dist directory first.
# Dependencies for the platform are somewhat complicated; the Configurator must be built and run first because it
# generates the conf files that are compiled into `tickgrinder_util` and `mm`. Then, `tickgrinder_util` must be
# built because pretty much everything else depends on it. After that, the `private` module must be built since
# it contains code used in many of the platform's modules such as the tick processor and the optimizer.
#
# However, the FXCM shim must be built in order for the private module to work with the FXCM native broker, so
# it is built first. That shim depends on the FXCM native broker libraries contained in a git submodule;
# those are automatically copied into `dist/lib` during the build process.
#
# All dependency libraries are copied into the `dist/lib` directory after compilation. In addition, for all
# modules execpt for the configurator (since it is a dependency of util), the pre-built crate dependencies are
# re-used from the `util` module's `target/release/deps`; this is why `extern crate` imports are used in the
# platform's modules without any crates listed as dependencies in their `Cargo.toml` files.
release:
make init
make node_init
# copy libstd to the dist/lib directory if it's not already there
if [[ ! -f dist/lib/$$(find $$(rustc --print sysroot)/lib | grep -E "libstd-.*\.so" | head -1) ]]; then \
cp $$(find $$(rustc --print sysroot)/lib | grep -E "libstd-.*\.so" | head -1) dist/lib; \
fi;
# Run the configurator if no settings exist from a previous run
if [[ ! -f configurator/settings.json ]]; then cd configurator && cargo run; fi;
# build the platform's utility library and copy into dist/lib
cd util && CARGO_INCREMENTAL=1 cargo build --release
cp util/target/release/libtickgrinder_util.so dist/lib
# Build and install the small libboost rand wrapper
cd private/src/strategies/fuzzer/extern && ./build.sh
cp private/src/strategies/fuzzer/extern/librand_bindings.so dist/lib
# build the broker shims
cd broker_shims/simbroker && CARGO_INCREMENTAL=1 cargo build --release
cp broker_shims/simbroker/target/release/libsimbroker.so dist/lib
cd broker_shims/FXCM/native/native && ./build.sh
cp broker_shims/FXCM/native/native/dist/* dist/lib
cd broker_shims/FXCM/native && CARGO_INCREMENTAL=1 cargo build --release
cp broker_shims/FXCM/native/target/release/libfxcm.so dist/lib
# build the private library containing user-specific code
cd private && CARGO_INCREMENTAL=1 cargo build --release
cp private/target/release/libprivate.so dist/lib
# build all modules and copy their binaries into the dist directory
cd backtester && CARGO_INCREMENTAL=1 cargo build --release
cp backtester/target/release/backtester dist
cd spawner && CARGO_INCREMENTAL=1 cargo build --release
cp spawner/target/release/spawner dist
cd tick_parser && CARGO_INCREMENTAL=1 cargo build --release
cp tick_parser/target/release/tick_processor dist
# build the FXCM data downloaders
cd data_downloaders/fxcm_native && CARGO_INCREMENTAL=1 cargo build --release
cp data_downloaders/fxcm_native/target/release/fxcm_native dist/fxcm_native_downloader
cd data_downloaders/fxcm_flatfile && CARGO_INCREMENTAL=1 cargo build --release
cp data_downloaders/fxcm_flatfile/target/release/fxcm_flatfile dist/fxcm_flatfile_downloader
cd optimizer && CARGO_INCREMENTAL=1 cargo build --release
cp optimizer/target/release/optimizer dist
cd logger && CARGO_INCREMENTAL=1 cargo build --release
cp logger/target/release/logger dist
make node_compile
dev:
# rm dist/mm -r
# cd dist && ln -s ../mm/ ./mm
# build the simbroker in superlog mode
cd broker_shims/simbroker && RUSTFLAGS="-L ../../util/target/release/deps -L ../../dist/lib -C prefer-dynamic" CARGO_INCREMENTAL=1 cargo build --features="superlog"
cp broker_shims/simbroker/target/debug/libsimbroker.so dist/lib
dev_release:
rm dist/mm -r
cd dist && ln -s ../mm/ ./mm
# build the simbroker in superlog mode
cd broker_shims/simbroker && RUSTFLAGS="-L ../../util/target/release/deps -L ../../dist/lib -C prefer-dynamic" CARGO_INCREMENTAL=1 cargo build --release --features="superlog"
cp broker_shims/simbroker/target/release/libsimbroker.so dist/lib
debug:
make init
make node_init
# copy libstd to the dist/lib directory if it's not already there
# TODO: Fix so that this supports all dylib extensions for different platforms
if [[ ! -f dist/lib/$$(find $$(rustc --print sysroot)/lib | grep -E "libstd-.*\.so" | head -1) ]]; then \
cp $$(find $$(rustc --print sysroot)/lib | grep -E "libstd-.*\.dylib" | head -1) dist/lib; \
fi;
# build the configurator
cd configurator && RUSTFLAGS="-L ../util/target/debug/deps -L ../dist/lib -C prefer-dynamic" CARGO_INCREMENTAL=1 cargo build
# Run the configurator if no settings exist from a previous run
if [[ ! -f configurator/settings.json ]]; then cd configurator && cargo run; fi;
# build the platform's utility library and copy into dist/lib
cd util && CARGO_INCREMENTAL=1 cargo build
cp util/target/debug/libtickgrinder_util.so dist/lib
# Build and install the small libboost rand wrapper
cd private/src/strategies/fuzzer/extern && ./build.sh
cp private/src/strategies/fuzzer/extern/librand_bindings.so dist/lib
# build the broker shims
cd broker_shims/simbroker && RUSTFLAGS="-L ../../util/target/debug/deps -L ../../dist/lib -C prefer-dynamic" CARGO_INCREMENTAL=1 cargo build
cp broker_shims/simbroker/target/debug/libsimbroker.so dist/lib
cd broker_shims/FXCM/native/native && ./build.sh
cp broker_shims/FXCM/native/native/dist/* dist/lib
cd broker_shims/FXCM/native && RUSTFLAGS="-L ../../../util/target/debug/deps -L ../../../dist/lib -C prefer-dynamic" CARGO_INCREMENTAL=1 cargo build
cp broker_shims/FXCM/native/target/debug/libfxcm.so dist/lib
# build the private library containing user-specific code as well as the small C++ wrapper
cd private && RUSTFLAGS="-L ../util/target/debug/deps -L ../dist/lib -C prefer-dynamic" CARGO_INCREMENTAL=1 cargo build
cp private/target/debug/libprivate.so dist/lib
# build all modules and copy their binaries into the dist directory
cd backtester && RUSTFLAGS="-L ../util/target/debug/deps -L ../dist/lib -C prefer-dynamic" CARGO_INCREMENTAL=1 cargo build
cp backtester/target/debug/backtester dist
cd spawner && RUSTFLAGS="-L ../util/target/debug/deps -L ../dist/lib -C prefer-dynamic" CARGO_INCREMENTAL=1 cargo build
cp spawner/target/debug/spawner dist
cd tick_parser && RUSTFLAGS="-L ../util/target/debug/deps -L ../dist/lib -C prefer-dynamic" CARGO_INCREMENTAL=1 cargo build
cp tick_parser/target/debug/tick_processor dist
# build the FXCM native data downloader
cd data_downloaders/fxcm_native && RUSTFLAGS="-L ../../util/target/debug/deps -L ../../dist/lib -C prefer-dynamic" CARGO_INCREMENTAL=1 cargo build
cp data_downloaders/fxcm_native/target/debug/fxcm_native dist/fxcm_native_downloader
cd data_downloaders/fxcm_flatfile && RUSTFLAGS="-L ../../util/target/debug/deps -L ../../dist/lib -C prefer-dynamic" CARGO_INCREMENTAL=1 cargo build
cp data_downloaders/fxcm_flatfile/target/debug/fxcm_flatfile dist/fxcm_flatfile_downloader
cd optimizer && RUSTFLAGS="-L ../util/target/debug/deps -L ../dist/lib -C prefer-dynamic" CARGO_INCREMENTAL=1 cargo build
cp optimizer/target/debug/optimizer dist
cd logger && RUSTFLAGS="-L ../util/target/debug/deps -L ../dist/lib -C prefer-dynamic" CARGO_INCREMENTAL=1 cargo build
cp logger/target/debug/logger dist
cd mm && npm install
cp ./mm dist -r
make node_compile
strip:
cd dist && strip backtester spawner optimizer tick_processor
cd dist/lib && strip *
clean:
rm -rf optimizer/target
rm -rf logger/target
rm -rf spawner/target
rm -rf tick_parser/target
rm -rf util/target
rm -rf backtester/target
rm -rf private/target
rm -rf broker_shims/simbroker/target
rm -rf broker_shims/FXCM/native/native/dist
rm -rf broker_shims/FXCM/native/target
rm -rf data_downloaders/fxcm_native/target
rm -rf configurator/target
rm -rf util/js/node_modules
rm -rf mm/node_modules
rm -rf mm-react/node_modules
rm -rf data_downloaders/iex/node_modules
rm -rf data_downloaders/poloniex/node_modules
test:
# copy libstd to the dist/lib directory if it's not already there
if [[ ! -f dist/lib/$$(find $$(rustc --print sysroot)/lib | grep -E "libstd-.*\.so" | head -1) ]]; then \
cp $$(find $$(rustc --print sysroot)/lib | grep -E "libstd-.*\.so" | head -1) dist/lib; \
fi;
cd configurator && LD_LIBRARY_PATH="../../dist/lib" RUSTFLAGS="-L ../../util/target/debug/deps -L ../../dist/lib -C prefer-dynamic" cargo test --no-fail-fast
# build the platform's utility library and copy into dist/lib
cd util && CARGO_INCREMENTAL=1 cargo build && cargo test --no-fail-fast
cp util/target/debug/libtickgrinder_util.so dist/lib
# Build and install the small libboost rand wrapper
cd private/src/strategies/fuzzer/extern && ./build.sh
cp private/src/strategies/fuzzer/extern/librand_bindings.so dist/lib
# build and test the broker shims
cd broker_shims/simbroker && LD_LIBRARY_PATH=../../util/target/debug/deps:../../dist/lib \
RUSTFLAGS="-L ../../util/target/debug/deps -L ../../dist/lib -C prefer-dynamic" cargo test && \
RUSTFLAGS="-L ../../util/target/debug/deps -L ../../dist/lib -C prefer-dynamic" CARGO_INCREMENTAL=1 cargo build
cp broker_shims/simbroker/target/debug/libsimbroker.so dist/lib
cd broker_shims/FXCM/native/native && ./build.sh
cp broker_shims/FXCM/native/native/dist/* dist/lib
cd broker_shims/FXCM/native && RUSTFLAGS="-L ../../../util/target/debug/deps -L ../../../dist/lib -C prefer-dynamic" CARGO_INCREMENTAL=1 cargo build && \
LD_LIBRARY_PATH=native/dist:../../../util/target/debug/deps \
RUSTFLAGS="-L ../../../util/target/debug/deps -L ../../../dist/lib -C prefer-dynamic" cargo test -- --nocapture
cp broker_shims/FXCM/native/target/debug/libfxcm.so dist/lib
# build private
cd private && RUSTFLAGS="-L ../util/target/debug/deps -L ../dist/lib -C prefer-dynamic" CARGO_INCREMENTAL=1 cargo build
cd private && LD_LIBRARY_PATH="../dist/lib" RUSTFLAGS="-L ../util/target/debug/deps -L ../dist/lib -C prefer-dynamic" cargo test --no-fail-fast
# run the flow type checker on the JavaScript modules that have the Flow type checker enabled
cd util/js && npm run flow
cd data_downloaders/iex && npm run flow
cd data_downloaders/poloniex && npm run flow
cd optimizer && LD_LIBRARY_PATH="../dist/lib" RUSTFLAGS="-L ../util/target/debug/deps -L ../dist/lib -C prefer-dynamic" cargo test --no-fail-fast
cd logger && LD_LIBRARY_PATH="../dist/lib" RUSTFLAGS="-L ../util/target/debug/deps -L ../dist/lib -C prefer-dynamic" cargo test --no-fail-fast
cd spawner && LD_LIBRARY_PATH="../dist/lib" RUSTFLAGS="-L ../util/target/debug/deps -L ../dist/lib -C prefer-dynamic" cargo test --no-fail-fast
cd tick_parser && LD_LIBRARY_PATH="../dist/lib" RUSTFLAGS="-L ../util/target/debug/deps -L ../dist/lib -C prefer-dynamic" cargo test --no-fail-fast
cd backtester && LD_LIBRARY_PATH="../dist/lib" RUSTFLAGS="-L ../util/target/debug/deps -L ../dist/lib -C prefer-dynamic" cargo test --no-fail-fast
cd mm && npm install
cp private/target/debug/libprivate.so dist/lib
cd data_downloaders/fxcm_native && LD_LIBRARY_PATH="../../dist/lib" RUSTFLAGS="-L ../../util/target/debug/deps -L ../../dist/lib -C prefer-dynamic" cargo test --no-fail-fast
cd data_downloaders/fxcm_flatfile && LD_LIBRARY_PATH="../../dist/lib" RUSTFLAGS="-L ../../util/target/debug/deps -L ../../dist/lib -C prefer-dynamic" cargo test --no-fail-fast
# TODO: Collect the results into a nice format
bench:
make init
# copy libstd to the dist/lib directory if it's not already there
if [[ ! -f dist/lib/$$(find $$(rustc --print sysroot)/lib | grep -E "libstd-.*\.so" | head -1) ]]; then \
cp $$(find $$(rustc --print sysroot)/lib | grep -E "libstd-.*\.so" | head -1) dist/lib; \
fi;
# build the platform's utility library and copy into dist/lib
cd util && CARGO_INCREMENTAL=1 cargo build --release && cargo bench
cp util/target/release/libtickgrinder_util.so dist/lib
# Build and install the small libboost rand wrapper
cd private/src/strategies/fuzzer/extern && ./build.sh
cp private/src/strategies/fuzzer/extern/librand_bindings.so dist/lib
# build the broker shims
cd broker_shims/simbroker && CARGO_INCREMENTAL=1 cargo build --release && cargo bench
cp broker_shims/simbroker/target/release/libsimbroker.so dist/lib
cd broker_shims/FXCM/native/native && ./build.sh
cp broker_shims/FXCM/native/native/dist/* dist/lib
cd broker_shims/FXCM/native && CARGO_INCREMENTAL=1 cargo build --release
cp broker_shims/FXCM/native/target/release/libfxcm.so dist/lib
# build private
cd private && LD_LIBRARY_PATH="../dist/lib" cargo bench
cd optimizer && LD_LIBRARY_PATH="../dist/lib" cargo bench
cd logger && LD_LIBRARY_PATH="../dist/lib" cargo bench
cd spawner && LD_LIBRARY_PATH="../dist/lib" cargo bench
cd tick_parser && LD_LIBRARY_PATH="../dist/lib" cargo bench
cd backtester && LD_LIBRARY_PATH="../dist/lib" cargo bench
cd mm && npm install
cd configurator && LD_LIBRARY_PATH="../dist/lib" cargo bench
# TODO: Collect the results into a nice format
update:
cd optimizer && cargo update
cd logger && cargo update
cd spawner && cargo update
cd tick_parser && cargo update
cd util && cargo update
cd backtester && cargo update
cd private && cargo update
cd mm && npm update
cd broker_shims/FXCM/native && cargo update
cd configurator && cargo update
doc:
cd configurator && cargo rustdoc --open -- --no-defaults --passes collapse-docs --passes unindent-comments --passes strip-priv-imports
cd optimizer && cargo rustdoc --open -- --no-defaults --passes collapse-docs --passes unindent-comments --passes strip-priv-imports -L ../util/target/release/deps -L ../dist/lib
cd logger && cargo rustdoc --open -- --no-defaults --passes collapse-docs --passes unindent-comments --passes strip-priv-imports -L ../util/target/release/deps -L ../dist/lib
cd spawner && cargo rustdoc --open -- --no-defaults --passes collapse-docs --passes unindent-comments --passes strip-priv-imports -L ../util/target/release/deps -L ../dist/lib
cd tick_parser && cargo rustdoc --open -- --no-defaults --passes collapse-docs --passes unindent-comments --passes strip-priv-imports -L ../util/target/release/deps -L ../dist/lib
cd util && cargo rustdoc --open -- --no-defaults --passes collapse-docs --passes unindent-comments --passes strip-priv-imports -L ../util/target/release/deps -L ../dist/lib
cd backtester && cargo rustdoc --open -- --no-defaults --passes collapse-docs --passes unindent-comments --passes strip-priv-imports -L ../util/target/release/deps -L ../dist/lib
cd private && cargo rustdoc --open -- --no-defaults --passes collapse-docs --passes unindent-comments --passes strip-priv-imports -L ../util/target/release/deps -L ../dist/lib
cd mm && npm install
# TODO: Collect the results into a nice format
# kill off any straggler processes
kill:
if [[ $$(ps -aux | grep '[t]arget/debug') ]]; then \
kill $$(ps -aux | grep '[t]arget/debug' | awk '{print $$2}'); \
fi
if [[ $$(ps -aux | grep '[m]anager.js') ]]; then \
kill $$(ps -aux | grep '[m]anager.js' | awk '{print $$2}'); \
fi
configure:
cd configurator && cargo run
cp configurator/conf.rs util/src
cp configurator/conf.js util/js/src
cp configurator/conf.js mm-react/src
cp configurator/conf.js data_downloaders/iex/src
cp configurator/conf.js data_downloaders/poloniex/src
config:
make configure
init:
rm -rf dist
mkdir dist
mkdir dist/lib
node_init:
if [[ ! $$(which dva) ]]; then npm install -g dva-cli; fi
if [[ ! -f ./mm-react/node_modules/installed ]]; then \
npm install -g eslint-plugin-flowtype && npm install -g babel-cli && npm install -g babel-eslint && npm install -g flow-remove-types && \
cd mm-react && npm install react && npm install react-dom && npm install babel-plugin-import --save && npm install && \
npm install dva-loading --save && touch ./node_modules/installed; \
fi
if [[ ! -f ./data_downloaders/poloniex/node_modules/installed ]]; then \
cd data_downloaders/poloniex && npm install && touch node_modules/installed; \
fi
if [[ ! -f ./data_downloaders/iex/node_modules/installed ]]; then \
cd data_downloaders/iex && npm install && touch node_modules/installed; \
fi
# fetch a built copy of the ckeditor if it doesn't exist. If ameo.link is dead and gone, you can build your own version
if [[ ! -d ./mm-react/public/ckeditor ]]; then \
curl https://ameo.link/u/422.tgz -o mm-react/public/ckeditor.tgz && \
cd mm-react/public && \
tar -xzf ckeditor.tgz && \
rm ckeditor.tgz && \
cd ckeditor; \
fi
# copy the JavaScript utility library to the modules that make use of it
if [[ ! -f ./util/js/node_modules/installed ]]; then \
cd util/js && npm install && touch ./node_modules/installed; \
fi
cd util/js && npm run-script strip
rm -rf data_downloaders/poloniex/node_modules/tickgrinder_util
cp -r util/js/stripped data_downloaders/poloniex/node_modules/tickgrinder_util
cp -r util/js/node_modules data_downloaders/poloniex/node_modules/tickgrinder_util/node_modules
cp util/js/package.json data_downloaders/poloniex/node_modules/tickgrinder_util
rm -rf data_downloaders/iex/node_modules/tickgrinder_util
cp -r util/js/stripped data_downloaders/iex/node_modules/tickgrinder_util
cp -r util/js/node_modules data_downloaders/iex/node_modules/tickgrinder_util/node_modules
cp util/js/package.json data_downloaders/iex/node_modules/tickgrinder_util
node_compile:
# transpile the Poloniex + IEX data downloaders
cd data_downloaders/iex && npm run transpile
cd data_downloaders/poloniex && npm run transpile
# compile the MM
cd mm-react && npm run build