forked from blockparty-sh/Fulcrum
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFulcrum.pro
477 lines (445 loc) · 16.2 KB
/
Fulcrum.pro
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
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
#
# Fulcrum - A fast & nimble SPV Server for Bitcoin Cash
# Copyright (C) 2019-2020 Calin A. Culianu <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program (see LICENSE.txt). If not, see
# <https://www.gnu.org/licenses/>.
#
# print CLI overrides to stdout immediately
!isEmpty(LIBS) {
message("CLI overrides: LIBS=$$LIBS")
}
!isEmpty(INCLUDEPATH) {
message("CLI overrides: INCLUDEPATH=$$INCLUDEPATH")
}
# Make qtCompileTest available
load(configure)
QT -= gui
QT += network
CONFIG += c++17 console warn_on
CONFIG -= app_bundle
versionAtMost(QT_VERSION, 5.12.4) {
error("Fulcrum requires Qt 5.12.5 (or later) or Qt 5.13.1 (or later) to be successfully built without errors. Please use Qt 5.12.5+ or Qt 5.13.1+ to build this codebase.")
}
QMAKE_CXXFLAGS_RELEASE += -DNDEBUG
QMAKE_CFLAGS_RELEASE += -DNDEBUG
QMAKE_CXXFLAGS_DEBUG -= -DNDEBUG
QMAKE_CFLAGS_DEBUG -= -DNDEBUG
release {
CONFIG += optimize_full
clang|*-g++ {
QMAKE_CXXFLAGS_RELEASE += -fomit-frame-pointer
QMAKE_CFLAGS_RELEASE += -fomit-frame-pointer
}
}
macx {
# Note: This is required because we use advanced C++ features such as std::visit
# which requires newer Mojave+ C++ libs. On a recent compiler SDK, this will
# compile ok even on High Sierra with latest Xcode for High Sierra, so this requirement
# isn't too bad. It just affects what C++ runtime we link to on MacOS.
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.14
}
# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# I added some Qt-specific calls to stuff inside the bitcoin:: namespace.
# This enables those functions.
DEFINES += USE_QT_IN_BITCOIN
### It is recommended you use Qt Creator to build, and that you set
### your compiler to a clang variant for maximal benefit.
### NOTE: If on a BIG ENDIAN architecture that isn't Linux, be sure to set this:
# DEFINES += WORDS_BIGENDIAN
# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
# If defined, tests and benchmarks will be compiled-in to the app (accessed via --test and --bench CLI args).
#DEFINES += ENABLE_TESTS
win32-msvc {
error("MSVC is not supported for this project. Please compile with MinGW G++ 7.3.0 or above.")
}
win32 {
# Windows MSVC & mingw-g++ both have too many warnings due to bitcoin sources, so just disable warnings.
CONFIG += warn_off
}
linux {
QMAKE_CXXFLAGS += -std=c++1z
DEFINES += HAVE_ENDIAN_H HAVE_DECL_HTOBE16 HAVE_DECL_HTOLE16 HAVE_DECL_BE16TOH HAVE_DECL_LE16TOH HAVE_DECL_HTOBE32 \
HAVE_DECL_HTOLE32 HAVE_DECL_BE32TOH HAVE_DECL_LE32TOH HAVE_DECL_HTOBE64 HAVE_DECL_HTOLE64 HAVE_DECL_BE64TOH \
HAVE_DECL_LE64TOH
}
linux-g++ {
# Linux g++ has too many warnings due to bitcoin sources, so just disable warnings
CONFIG += warn_off
}
# - Try and detect rocksdb and if not, fall back to the staticlib.
# - User can suppress this behavior by specifying a "LIBS+=-lrocksdb..." on the
# CLI when they invoked qmake. In that case, they must set-up the LIBS+= and
# INCLUDEPATH+= fully when invoking qmake.
!contains(LIBS, -lrocksdb) {
# Test if rocksdb is installed and meets the minimum version requirement
qtCompileTest(rocksdb)
contains(CONFIG, config_rocksdb) {
message("rocksdb: using system lib")
} else {
# RocksDB Static Lib
# ------------------
#
# Build information --
#
# Currently this was built from github sources of the v6.14.6 rocksdb release:
# https://github.com/facebook/rocksdb.git
# Commit tag v6.14.6, commit hash (from Tue Dec 1 15:05:35 2020 -0800):
# ed4316166f67ec892603014634840d29f460f611
#
# OSX:
# Built on Apple clang version 11.0.0 (clang-1100.0.33.17), from Xcode 113.1.
# command: USE_RTTI=1 PORTABLE=1 DEBUG_LEVEL=0 make static_lib -j4 V=1
# Annoyingly, the produced .a file has debug symbols which we strip with: strip -S.
#
# Linux:
# Built on Ubuntu 18.10, g++ (Ubuntu 8.2.0-7ubuntu1) 8.2.0.
# command: USE_RTTI=1 PORTABLE=1 DEBUG_LEVEL=0 make static_lib -j4 V=1
# Annoyingly, the produced .a file has debug symbols which we strip with: strip -g.
#
# Windows:
# Built using the MinGW G++ 8.1.0 (compiler that ships with Qt 5.15+), from a cmd.exe prompt, via cmake.exe by
# following these steps:
# - Install a recent cmake into eg c:\cmake
# - Open up a Qt cmd.exe prompt that points to MinGW G++ 8.1.0 in the path (using the Start menu shortcut
# installed by Qt 5.15+ is easiest).
# - Put installed 'c:\cmake\bin' in the path so that 'cmake.exe' works from the cmd prompt, eg:
# set PATH=c:\cmake\bin;%PATH%
# - Checkout rocksdb (commit hash above), cd rocksdb
# - Now you will need to edit CMakeLists.txt:
# 1. Open CMakeLists.txt in a text editor
# 2. Search for '-fno-asynchronous-unwind-tables' and remove that compile option since it
# breaks building on MinGW against Qt, and replace it with -O3 for maximal speed.
# 3. In that same MINGW section where you removed the above, add: '-Wno-cast-function-type -Wno-error=cast-function-type'
# since MinGW 8.1 seems to not like the function pointer casts in port/win/env_win.cc.
# 4. Look for a section that contains 'if(NOT MINGW' and rename MINGW to XX_MINGW:
# if(NOT XX_MINGW)
# This ensures that port/win/win_thread.cc does get compiled and linked into the lib.
# - mkdir build, cd build
# - Run this command from within the rocksdb/build dir that you just created:
# cmake .. -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_SYSTEM_NAME=Windows -G"MinGW Makefiles" -DWITH_GFLAGS=0 -DWITH_JNI=0 -DCMAKE_BUILD_TYPE=Release -DUSE_RTTI=1 -DPORTABLE=1
# - Build with this command:
# mingw32-make -j4 V=1 rocksdb <-- will build static lib only
# The generated librocksdb.a will be in the build/ directory you are currently in, ready to be put into the
# Fulcrum directory staticlibs/rocksdb/bin/win64.
macx {
LIBS += -L$$PWD/staticlibs/rocksdb/bin/osx
}
linux {
# We support aarch64 (for RPis, etc) but the user needs to run a shell script to compile librocksdb.a
# themselves: contrib/build/rocksdb-staticlib.sh
contains(QMAKE_HOST.arch, aarch64) {
aarch64_rocksdb = staticlibs/rocksdb/bin/linux/aarch64
aarch64_rocksdb_path = $$PWD/$$aarch64_rocksdb
exists($$aarch64_rocksdb_path/librocksdb.a) {
LIBS += -L$$aarch64_rocksdb_path
message("Linux-ARM64 detected: Using librocksdb.a from $$aarch64_rocksdb")
} else {
message("Linux-ARM64 detected but missing librocksdb.a in $$aarch64_rocksdb")
error("Please run the shell script contrib/build/rocksdb-staticlib.sh to build it.")
}
} else {
LIBS += -L$$PWD/staticlibs/rocksdb/bin/linux
}
}
win32 {
win32-g++ {
LIBS += -L$$PWD/staticlibs/rocksdb/bin/win64
} else {
error("This project lacks a pre-compiled static librocksdb.a for this compiler! Either add one to staticlib/rocksdb/bin/win64/ or use MinGW G++ 8.1.0.")
}
}
INCLUDEPATH += $$PWD/staticlibs/rocksdb/include
message("rocksdb: using static lib")
# /RocksDB Static Lib
}
macx {
LIBS += -lrocksdb -lz -lbz2
}
linux {
LIBS += -lrocksdb -lz -lbz2
}
win32 {
LIBS += -lrocksdb
contains(CONFIG, config_rocksdb) {
LIBS += -lzstd -lbz2 -llz4 -lsnappy -lz
}
}
} else {
message("rocksdb: using CLI override")
}
# - Try and detect jemalloc and if not, don't use jemalloc.
# - User can override auto-detection by specifying "LIBS+=-ljemaloc..." on the
# CLI when they invoked qmake.
!contains(LIBS, -ljemalloc) {
# Test if jemalloc is installed
qtCompileTest(jemalloc)
contains(CONFIG, config_jemalloc) {
LIBS += -ljemalloc
DEFINES += HAVE_JEMALLOC_HEADERS
} else {
message("jemalloc: not found, will use system allocator")
}
} else {
DEFINES += HAVE_JEMALLOC_HEADERS
message("jemalloc: using CLI override")
}
linux {
LIBS += -ldl
}
win32 {
LIBS += -lshlwapi -lrpcrt4 -lpsapi
}
# Tell QMake all of the below is relative to src/.
VPATH += src/
INCLUDEPATH += src/
SOURCES += \
AbstractConnection.cpp \
App.cpp \
BTC.cpp \
BTC_Address.cpp \
BitcoinD.cpp \
BlockProc.cpp \
CityHash.cpp \
Common.cpp \
Controller.cpp \
Json/Json.cpp \
Json/Json_Parser.cpp \
Json/tests.cpp \
Logger.cpp \
main.cpp \
Mempool.cpp \
Merkle.cpp \
Mixins.cpp \
Mgr.cpp \
Options.cpp \
PeerMgr.cpp \
RecordFile.cpp \
ReusableBlock.cpp \
RollingBloomFilter.cpp \
RPC.cpp \
RPCMsgId.cpp \
ServerMisc.cpp \
Servers.cpp \
SrvMgr.cpp \
Storage.cpp \
SubsMgr.cpp \
ThreadPool.cpp \
TXO.cpp \
Util.cpp \
Version.cpp \
WebSocket.cpp \
register_MetaTypes.cpp
HEADERS += \
AbstractConnection.h \
App.h \
BTC.h \
BTC_Address.h \
BitcoinD.h \
BlockProc.h \
BlockProcTypes.h \
ByteView.h \
CityHash.h \
Common.h \
Compat.h \
Controller.h \
CostCache.h \
Json/Json.h \
Logger.h \
Mempool.h \
Merkle.h \
Mgr.h \
Mixins.h \
Options.h \
PeerMgr.h \
RecordFile.h \
ReusableBlock.h \
RollingBloomFilter.h \
RPC.h \
RPCMsgId.h \
ServerMisc.h \
Servers.h \
SrvMgr.h \
Storage.h \
SubsMgr.h \
ThreadPool.h \
ThreadSafeHashTable.h \
TXO.h \
TXO_Compact.h \
Util.h \
Version.h \
WebSocket.h
# Robin Hood unordered_flat_map implememntation (single header and MUCH more efficient than unordered_map!)
HEADERS += robin_hood/robin_hood.h
# Tessil hat-trie implememntation (header only, supports prefix search and fast serialization/deserialization!)
HEADERS += \
tsl/htrie_set.h \
tsl/htrie_map.h \
tsl/htrie_hash.h \
tsl/array-hash/array_set.h \
tsl/array-hash/array_map.h \
tsl/array-hash/array_growth_policy.h \
tsl/array-hash/array_hash.h
RESOURCES += \
resources.qrc
# Bitcoin related sources & headers
SOURCES += \
bitcoin/amount.cpp \
bitcoin/base58.cpp \
bitcoin/block.cpp \
bitcoin/support/cleanse.cpp \
bitcoin/cashaddr.cpp \
bitcoin/cashaddrenc.cpp \
bitcoin/crypto/aes.cpp \
bitcoin/crypto/chacha20.cpp \
bitcoin/crypto/ctaes/ctaes.c \
bitcoin/crypto/hmac_sha256.cpp \
bitcoin/crypto/hmac_sha512.cpp \
bitcoin/crypto/ripemd160.cpp \
bitcoin/crypto/sha1.cpp \
bitcoin/crypto/sha256.cpp \
bitcoin/crypto/sha256_sse4.cpp \
bitcoin/crypto/sha512.cpp \
bitcoin/feerate.cpp \
bitcoin/hash.cpp \
bitcoin/interpreter.cpp \
bitcoin/pubkey.cpp \
bitcoin/script.cpp \
bitcoin/script_error.cpp \
bitcoin/script_standard.cpp \
bitcoin/sigencoding.cpp \
bitcoin/test.cpp \
bitcoin/transaction.cpp \
bitcoin/uint256.cpp \
bitcoin/utilstrencodings.cpp
HEADERS += \
bitcoin/amount.h \
bitcoin/base58.h \
bitcoin/block.h \
bitcoin/cashaddr.h \
bitcoin/cashaddrenc.h \
bitcoin/compat.h \
bitcoin/compat/byteswap.h \
bitcoin/compat/endian.h \
bitcoin/crypto/byteswap.h \
bitcoin/crypto/endian.h \
bitcoin/crypto/aes.h \
bitcoin/crypto/chacha20.h \
bitcoin/crypto/common.h \
bitcoin/crypto/ctaes/ctaes.h \
bitcoin/crypto/hmac_sha256.h \
bitcoin/crypto/hmac_sha512.h \
bitcoin/crypto/ripemd160.h \
bitcoin/crypto/sha1.h \
bitcoin/crypto/sha256.h \
bitcoin/crypto/sha512.h \
bitcoin/feerate.h \
bitcoin/hash.h \
bitcoin/interpreter.h \
bitcoin/prevector.h \
bitcoin/pubkey.h \
bitcoin/rpc/protocol.h \
bitcoin/script.h \
bitcoin/script_error.h \
bitcoin/script_flags.h \
bitcoin/script_standard.h \
bitcoin/streams.h \
bitcoin/support/cleanse.h \
bitcoin/support/zeroafterfree.h \
bitcoin/serialize.h \
bitcoin/sigencoding.h \
bitcoin/sighashtype.h \
bitcoin/tinyformat.h \
bitcoin/transaction.h \
bitcoin/txid.h \
bitcoin/uint256.h \
bitcoin/utilstrencodings.h \
bitcoin/version.h
# Enable secp256k1 compilation on x86_64 only -- we don't actually use this lib
# yet in Fulcrum, so on platforms that aren't x86_64 it's ok to exclude it; it
# was included in case we wish to someday verify signatures in Fulcrum, etc.
contains(QT_ARCH, x86_64):!win32-msvc {
message("Including embedded secp256k1")
SOURCES += bitcoin/secp256k1/secp256k1.c
HEADERS += \
bitcoin/secp256k1/ecdsa.h \
bitcoin/secp256k1/ecdsa_impl.h \
bitcoin/secp256k1/eckey.h \
bitcoin/secp256k1/eckey_impl.h \
bitcoin/secp256k1/ecmult.h \
bitcoin/secp256k1/ecmult_const.h \
bitcoin/secp256k1/ecmult_const_impl.h \
bitcoin/secp256k1/ecmult_gen.h \
bitcoin/secp256k1/ecmult_gen_impl.h \
bitcoin/secp256k1/ecmult_impl.h \
bitcoin/secp256k1/field.h \
bitcoin/secp256k1/field_10x26.h \
bitcoin/secp256k1/field_10x26_impl.h \
bitcoin/secp256k1/field_5x52.h \
bitcoin/secp256k1/field_5x52_impl.h \
bitcoin/secp256k1/field_5x52_int128_impl.h \
bitcoin/secp256k1/field_impl.h \
bitcoin/secp256k1/group.h \
bitcoin/secp256k1/group_impl.h \
bitcoin/secp256k1/hash.h \
bitcoin/secp256k1/hash_impl.h \
bitcoin/secp256k1/libsecp256k1-config.h \
bitcoin/secp256k1/recovery_main_impl.h \
bitcoin/secp256k1/schnorr_main_impl.h \
bitcoin/secp256k1/schnorr.h \
bitcoin/secp256k1/schnorr_impl.h \
bitcoin/secp256k1/num.h \
bitcoin/secp256k1/num_impl.h \
bitcoin/secp256k1/scalar.h \
bitcoin/secp256k1/scalar_4x64.h \
bitcoin/secp256k1/scalar_4x64_impl.h \
bitcoin/secp256k1/scalar_8x32.h \
bitcoin/secp256k1/scalar_8x32_impl.h \
bitcoin/secp256k1/scalar_impl.h \
bitcoin/secp256k1/scalar_low.h \
bitcoin/secp256k1/scalar_low_impl.h \
bitcoin/secp256k1/secp256k1.h \
bitcoin/secp256k1/secp256k1_recovery.h \
bitcoin/secp256k1/secp256k1_schnorr.h \
bitcoin/secp256k1/util.h
} else {
message("Not including embedded secp256k1")
DEFINES += DISABLE_SECP256K1
}
# Installation
unix:!android: {
!defined(PREFIX, var) {
PREFIX=$$(PREFIX)
isEmpty(PREFIX) {
PREFIX = /usr/local
}
}
message("Installation dir prefix is $$PREFIX")
target.path = $${PREFIX}/bin
documentation.path = $${PREFIX}/share/doc/$${TARGET}
documentation.files = doc/*
QMAKE_STRIP = true # Trick qmake into not stripping files
admin.path = $${PREFIX}/bin
admin.files = FulcrumAdmin
}
!isEmpty(target.path): INSTALLS += target
!isEmpty(documentation.path): INSTALLS += documentation
!isEmpty(admin.path): INSTALLS += admin