2020-04-30 15:51:30 +00:00
|
|
|
mode = ScriptMode.Verbose
|
|
|
|
|
|
|
|
### Package
|
2024-07-09 11:14:28 +00:00
|
|
|
version = "0.1.0"
|
|
|
|
author = "Status Research & Development GmbH"
|
|
|
|
description = "Waku, Private P2P Messaging for Resource-Restricted Devices"
|
|
|
|
license = "MIT or Apache License 2.0"
|
2020-04-30 15:51:30 +00:00
|
|
|
#bin = @["build/waku"]
|
|
|
|
|
|
|
|
### Dependencies
|
2024-07-09 11:14:28 +00:00
|
|
|
requires "nim >= 2.0.8",
|
2020-04-30 15:51:30 +00:00
|
|
|
"chronicles",
|
|
|
|
"confutils",
|
|
|
|
"chronos",
|
|
|
|
"eth",
|
|
|
|
"json_rpc",
|
|
|
|
"libbacktrace",
|
|
|
|
"nimcrypto",
|
|
|
|
"stew",
|
|
|
|
"stint",
|
|
|
|
"metrics",
|
2020-12-04 04:41:28 +00:00
|
|
|
"libp2p", # Only for Waku v2
|
2022-06-02 09:45:00 +00:00
|
|
|
"web3",
|
2022-11-02 14:55:09 +00:00
|
|
|
"presto",
|
2024-07-09 11:14:28 +00:00
|
|
|
"regex",
|
|
|
|
"db_connector"
|
2020-04-30 15:51:30 +00:00
|
|
|
|
|
|
|
### Helper functions
|
2024-07-17 13:21:37 +00:00
|
|
|
proc buildModule(filePath, params = "", lang = "c"): bool =
|
|
|
|
if not dirExists "build":
|
|
|
|
mkDir "build"
|
|
|
|
# allow something like "nim nimbus --verbosity:0 --hints:off nimbus.nims"
|
|
|
|
var extra_params = params
|
|
|
|
for i in 2 ..< paramCount() - 1:
|
|
|
|
extra_params &= " " & paramStr(i)
|
|
|
|
|
|
|
|
if not fileExists(filePath):
|
|
|
|
echo "File to build not found: " & filePath
|
|
|
|
return false
|
|
|
|
|
|
|
|
exec "nim " & lang & " --out:build/" & filepath & ".bin --mm:refc " & extra_params &
|
|
|
|
" " & filePath
|
|
|
|
|
|
|
|
# exec will raise exception if anything goes wrong
|
|
|
|
return true
|
|
|
|
|
2020-04-30 15:51:30 +00:00
|
|
|
proc buildBinary(name: string, srcDir = "./", params = "", lang = "c") =
|
|
|
|
if not dirExists "build":
|
|
|
|
mkDir "build"
|
|
|
|
# allow something like "nim nimbus --verbosity:0 --hints:off nimbus.nims"
|
|
|
|
var extra_params = params
|
2024-07-09 11:14:28 +00:00
|
|
|
for i in 2 ..< paramCount():
|
2020-04-30 15:51:30 +00:00
|
|
|
extra_params &= " " & paramStr(i)
|
2024-07-17 13:21:37 +00:00
|
|
|
exec "nim " & lang & " --out:build/" & name & " --mm:refc " & extra_params & " " &
|
|
|
|
srcDir & name & ".nim"
|
2020-04-30 15:51:30 +00:00
|
|
|
|
2023-05-19 06:20:12 +00:00
|
|
|
proc buildLibrary(name: string, srcDir = "./", params = "", `type` = "static") =
|
2023-05-12 16:08:41 +00:00
|
|
|
if not dirExists "build":
|
|
|
|
mkDir "build"
|
|
|
|
# allow something like "nim nimbus --verbosity:0 --hints:off nimbus.nims"
|
|
|
|
var extra_params = params
|
2024-07-09 11:14:28 +00:00
|
|
|
for i in 2 ..< paramCount():
|
2023-05-12 16:08:41 +00:00
|
|
|
extra_params &= " " & paramStr(i)
|
2023-05-19 06:20:12 +00:00
|
|
|
if `type` == "static":
|
2024-07-09 11:14:28 +00:00
|
|
|
exec "nim c" & " --out:build/" & name &
|
2024-09-25 11:08:01 +00:00
|
|
|
".a --threads:on --app:staticlib --opt:size --noMain --mm:refc --header --undef:metrics " &
|
2024-07-17 13:21:37 +00:00
|
|
|
extra_params & " " & srcDir & name & ".nim"
|
2023-05-12 16:08:41 +00:00
|
|
|
else:
|
2024-07-09 11:14:28 +00:00
|
|
|
exec "nim c" & " --out:build/" & name &
|
2024-09-25 11:08:01 +00:00
|
|
|
".so --threads:on --app:lib --opt:size --noMain --mm:refc --header --undef:metrics " &
|
|
|
|
extra_params & " " & srcDir & name & ".nim"
|
2023-05-12 16:08:41 +00:00
|
|
|
|
2024-05-22 01:00:22 +00:00
|
|
|
proc buildMobileAndroid(srcDir = ".", params = "") =
|
|
|
|
let cpu = getEnv("CPU")
|
|
|
|
let abiDir = getEnv("ABIDIR")
|
|
|
|
|
|
|
|
let outDir = "build/android/" & abiDir
|
|
|
|
if not dirExists outDir:
|
|
|
|
mkDir outDir
|
|
|
|
|
|
|
|
var extra_params = params
|
2024-07-09 11:14:28 +00:00
|
|
|
for i in 2 ..< paramCount():
|
2024-05-22 01:00:22 +00:00
|
|
|
extra_params &= " " & paramStr(i)
|
|
|
|
|
2024-07-09 11:14:28 +00:00
|
|
|
exec "nim c" & " --out:" & outDir &
|
|
|
|
"/libwaku.so --threads:on --app:lib --opt:size --noMain --mm:refc -d:chronicles_sinks=textlines[dynamic] --header --passL:-L" &
|
|
|
|
outdir & " --passL:-lrln --passL:-llog --cpu:" & cpu & " --os:android -d:androidNDK " &
|
|
|
|
extra_params & " " & srcDir & "/libwaku.nim"
|
2024-05-22 01:00:22 +00:00
|
|
|
|
2021-06-14 12:40:08 +00:00
|
|
|
proc test(name: string, params = "-d:chronicles_log_level=DEBUG", lang = "c") =
|
2020-09-16 04:23:10 +00:00
|
|
|
# XXX: When running `> NIM_PARAMS="-d:chronicles_log_level=INFO" make test2`
|
|
|
|
# I expect compiler flag to be overridden, however it stays with whatever is
|
|
|
|
# specified here.
|
2021-06-14 12:40:08 +00:00
|
|
|
buildBinary name, "tests/", params
|
2020-04-30 15:51:30 +00:00
|
|
|
exec "build/" & name
|
|
|
|
|
2023-03-31 13:24:04 +00:00
|
|
|
### Waku common tasks
|
|
|
|
task testcommon, "Build & run common tests":
|
|
|
|
test "all_tests_common", "-d:chronicles_log_level=WARN -d:chronosStrictException"
|
|
|
|
|
2023-08-09 17:11:50 +00:00
|
|
|
### Waku tasks
|
2023-04-25 13:34:57 +00:00
|
|
|
task wakunode2, "Build Waku v2 cli node":
|
2022-10-12 19:41:25 +00:00
|
|
|
let name = "wakunode2"
|
2023-05-23 08:44:57 +00:00
|
|
|
buildBinary name, "apps/wakunode2/"
|
2022-10-12 19:41:25 +00:00
|
|
|
|
2024-02-09 16:06:25 +00:00
|
|
|
task benchmarks, "Some benchmarks":
|
|
|
|
let name = "benchmarks"
|
|
|
|
buildBinary name, "apps/benchmarks/"
|
|
|
|
|
2023-04-27 14:25:31 +00:00
|
|
|
task wakucanary, "Build waku-canary tool":
|
|
|
|
let name = "wakucanary"
|
2023-05-23 08:44:57 +00:00
|
|
|
buildBinary name, "apps/wakucanary/"
|
2023-04-25 13:34:57 +00:00
|
|
|
|
2023-04-27 14:25:31 +00:00
|
|
|
task networkmonitor, "Build network monitor tool":
|
|
|
|
let name = "networkmonitor"
|
2023-05-23 08:44:57 +00:00
|
|
|
buildBinary name, "apps/networkmonitor/"
|
2023-04-25 13:34:57 +00:00
|
|
|
|
2023-09-07 12:45:25 +00:00
|
|
|
task rln_db_inspector, "Build the rln db inspector":
|
|
|
|
let name = "rln_db_inspector"
|
|
|
|
buildBinary name, "tools/rln_db_inspector/"
|
|
|
|
|
2023-08-09 17:11:50 +00:00
|
|
|
task test, "Build & run Waku tests":
|
|
|
|
test "all_tests_waku"
|
2022-10-12 19:41:25 +00:00
|
|
|
|
2023-04-27 14:25:31 +00:00
|
|
|
task testwakunode2, "Build & run wakunode2 app tests":
|
|
|
|
test "all_tests_wakunode2"
|
|
|
|
|
2023-08-09 17:11:50 +00:00
|
|
|
task example2, "Build Waku examples":
|
|
|
|
buildBinary "publisher", "examples/"
|
|
|
|
buildBinary "subscriber", "examples/"
|
|
|
|
buildBinary "filter_subscriber", "examples/"
|
|
|
|
buildBinary "lightpush_publisher", "examples/"
|
2020-10-08 09:10:45 +00:00
|
|
|
|
2023-08-09 17:11:50 +00:00
|
|
|
task chat2, "Build example Waku chat usage":
|
2020-10-01 11:38:32 +00:00
|
|
|
# NOTE For debugging, set debug level. For chat usage we want minimal log
|
|
|
|
# output to STDOUT. Can be fixed by redirecting logs to file (e.g.)
|
2023-08-09 17:11:50 +00:00
|
|
|
#buildBinary name, "examples/", "-d:chronicles_log_level=WARN"
|
2020-10-21 09:54:29 +00:00
|
|
|
|
2022-10-12 19:41:25 +00:00
|
|
|
let name = "chat2"
|
2023-05-23 08:44:57 +00:00
|
|
|
buildBinary name, "apps/chat2/", "-d:chronicles_sinks=textlines[file] -d:ssl"
|
2021-05-06 13:43:43 +00:00
|
|
|
|
2022-10-12 19:41:25 +00:00
|
|
|
task chat2bridge, "Build chat2bridge":
|
2021-05-06 13:43:43 +00:00
|
|
|
let name = "chat2bridge"
|
2023-05-23 08:44:57 +00:00
|
|
|
buildBinary name, "apps/chat2bridge/"
|
2021-05-06 13:43:43 +00:00
|
|
|
|
2024-05-21 21:03:33 +00:00
|
|
|
task liteprotocoltester, "Build liteprotocoltester":
|
|
|
|
let name = "liteprotocoltester"
|
|
|
|
buildBinary name, "apps/liteprotocoltester/"
|
|
|
|
|
2024-07-17 13:21:37 +00:00
|
|
|
task buildone, "Build custom target":
|
|
|
|
let filepath = paramStr(paramCount())
|
|
|
|
discard buildModule filepath
|
|
|
|
|
|
|
|
task testone, "Test custom target":
|
|
|
|
let filepath = paramStr(paramCount())
|
|
|
|
if buildModule(filepath):
|
|
|
|
exec "build/" & filepath & ".bin"
|
|
|
|
|
2023-05-12 16:08:41 +00:00
|
|
|
### C Bindings
|
2023-05-19 06:20:12 +00:00
|
|
|
task libwakuStatic, "Build the cbindings waku node library":
|
2023-05-12 16:08:41 +00:00
|
|
|
let name = "libwaku"
|
2024-05-17 14:28:54 +00:00
|
|
|
buildLibrary name,
|
|
|
|
"library/",
|
2024-10-10 12:40:09 +00:00
|
|
|
"""-d:chronicles_line_numbers -d:chronicles_runtime_filtering=on -d:chronicles_sinks="textlines,json" -d:chronicles_default_output_device=Dynamic -d:chronicles_disabled_topics="eth,dnsdisc.client" --warning:Deprecated:off --warning:UnusedImport:on """,
|
2024-05-17 14:28:54 +00:00
|
|
|
"static"
|
2023-05-19 06:20:12 +00:00
|
|
|
|
|
|
|
task libwakuDynamic, "Build the cbindings waku node library":
|
|
|
|
let name = "libwaku"
|
2024-05-17 14:28:54 +00:00
|
|
|
buildLibrary name,
|
|
|
|
"library/",
|
2024-10-10 12:40:09 +00:00
|
|
|
"""-d:chronicles_line_numbers -d:chronicles_runtime_filtering=on -d:chronicles_sinks="textlines,json" -d:chronicles_default_output_device=Dynamic -d:chronicles_disabled_topics="eth,dnsdisc.client" --warning:Deprecated:off --warning:UnusedImport:on """,
|
2024-05-17 14:28:54 +00:00
|
|
|
"dynamic"
|
2024-05-22 01:00:22 +00:00
|
|
|
|
|
|
|
### Mobile Android
|
|
|
|
task libWakuAndroid, "Build the mobile bindings for Android":
|
|
|
|
let srcDir = "./library"
|
|
|
|
let extraParams = "-d:chronicles_log_level=ERROR"
|
|
|
|
buildMobileAndroid srcDir, extraParams
|