2020-10-08 16:08:52 +00:00
|
|
|
mode = ScriptMode.Verbose
|
|
|
|
|
2020-07-02 13:20:16 +00:00
|
|
|
version = "0.1.0"
|
|
|
|
author = "Status Research & Development GmbH"
|
|
|
|
description = "Nim implementation of the Status protocol"
|
|
|
|
license = "MIT"
|
2020-10-08 16:08:52 +00:00
|
|
|
skipDirs = @["test"]
|
|
|
|
|
|
|
|
requires "nim >= 1.2.0",
|
|
|
|
"chroma",
|
|
|
|
"chronicles",
|
|
|
|
"chronos",
|
|
|
|
"confutils",
|
|
|
|
"eth",
|
|
|
|
"nimPNG",
|
|
|
|
"nimage",
|
|
|
|
"nimcrypto",
|
|
|
|
"secp256k1",
|
|
|
|
"stew",
|
|
|
|
"waku"
|
2020-07-02 13:20:16 +00:00
|
|
|
|
2020-10-08 16:08:52 +00:00
|
|
|
import strutils
|
2020-07-13 14:26:31 +00:00
|
|
|
|
2021-03-28 23:03:18 +00:00
|
|
|
const debug_opts =
|
|
|
|
" --debugger:native" &
|
|
|
|
" --define:chronicles_line_numbers" &
|
|
|
|
" --define:debug" &
|
|
|
|
" --linetrace:on" &
|
|
|
|
" --stacktrace:on"
|
|
|
|
|
|
|
|
const release_opts =
|
|
|
|
" --define:danger" &
|
|
|
|
" --define:strip" &
|
|
|
|
" --hints:off" &
|
|
|
|
" --opt:size" &
|
|
|
|
" --passC:-flto" &
|
|
|
|
" --passL:-flto"
|
|
|
|
|
|
|
|
proc buildAndRun(name: string,
|
|
|
|
srcDir = "test/",
|
|
|
|
outDir = "test/build/",
|
|
|
|
params = "",
|
|
|
|
cmdParams = "",
|
|
|
|
lang = "c") =
|
2020-10-08 16:08:52 +00:00
|
|
|
mkDir outDir
|
2020-07-13 14:26:31 +00:00
|
|
|
# allow something like "nim test --verbosity:0 --hints:off beacon_chain.nims"
|
|
|
|
var extra_params = params
|
|
|
|
for i in 2..<paramCount():
|
|
|
|
extra_params &= " " & paramStr(i)
|
2020-10-08 16:08:52 +00:00
|
|
|
exec "nim " &
|
|
|
|
lang &
|
2021-03-28 23:03:18 +00:00
|
|
|
(if getEnv("RELEASE").strip != "false": release_opts else: debug_opts) &
|
|
|
|
(if defined(windows): " --define:chronicles_colors:AnsiColors" else: "") &
|
|
|
|
" --define:chronicles_log_level=" & getEnv("LOG_LEVEL") &
|
|
|
|
(if getEnv("WIN_STATIC").strip != "false": " --passC:\"-static\" --passL:\"-static\"" else: "") &
|
2020-12-09 19:38:21 +00:00
|
|
|
(if getEnv("PCRE_STATIC").strip != "false": " --define:usePcreHeader --dynlibOverride:pcre" elif defined(windows): " --define:usePcreHeader" else: "") &
|
2021-03-28 23:03:18 +00:00
|
|
|
# " --define:rln" & (if getEnv("RLN_STATIC").strip != "false": (if defined(windows): " --dynlibOverride:vendor\\rln\\target\\debug\\rln" else: " --dynlibOverride:vendor/rln/target/debug/librln") else: "") &
|
|
|
|
# usually `--dynlibOverride` is used in case of static linking and so would
|
|
|
|
# be used conditionally (see commented code above), but because
|
|
|
|
# `vendor/nim-waku/waku/v2/protocol/waku_rln_relay/rln.nim` specifies the
|
|
|
|
# library with a relative path prefix (which isn't valid relative to root
|
|
|
|
# of this repo) it needs to be used in the case of shared or static linking
|
|
|
|
" --define:rln" & (if defined(windows): " --dynlibOverride:vendor\\rln\\target\\debug\\rln" else: " --dynlibOverride:vendor/rln/target/debug/librln") &
|
2020-10-08 16:08:52 +00:00
|
|
|
" --define:ssl" &
|
2021-03-28 23:03:18 +00:00
|
|
|
(if getEnv("SSL_STATIC").strip != "false": (if defined(windows): " --dynlibOverride:ssl- --dynlibOverride:crypto- --define:noOpenSSLHacks --define:sslVersion:\"(\"" else: " --dynlibOverride:ssl --dynlibOverride:crypto") else: "") &
|
|
|
|
" --nimcache:nimcache/" & (if getEnv("RELEASE").strip != "false": "release/" else: "debug/") & name &
|
2020-10-08 16:08:52 +00:00
|
|
|
" --out:" & outDir & name &
|
|
|
|
(if getEnv("NIMSTATUS_CFLAGS").strip != "": " --passC:\"" & getEnv("NIMSTATUS_CFLAGS") & "\"" else: "") &
|
|
|
|
(if getEnv("PCRE_LDFLAGS").strip != "": " --passL:\"" & getEnv("PCRE_LDFLAGS") & "\"" else: "") &
|
2021-03-28 23:03:18 +00:00
|
|
|
(if getEnv("RLN_LDFLAGS").strip != "": " --passL:\"" & getEnv("RLN_LDFLAGS") & "\"" else: "") &
|
2021-03-15 15:55:19 +00:00
|
|
|
(if getEnv("SQLCIPHER_LDFLAGS").strip != "": " --passL:\"" & getEnv("SQLCIPHER_LDFLAGS") & "\"" else: "") &
|
2020-10-08 16:08:52 +00:00
|
|
|
(if getEnv("SSL_LDFLAGS").strip != "": " --passL:\"" & getEnv("SSL_LDFLAGS") & "\"" else: "") &
|
|
|
|
" --threads:on" &
|
|
|
|
" --tlsEmulation:off" &
|
2021-03-28 23:03:18 +00:00
|
|
|
" --warning[ObservableStores]:off" &
|
2020-10-08 16:08:52 +00:00
|
|
|
" " &
|
|
|
|
extra_params &
|
|
|
|
" " &
|
|
|
|
srcDir & name & ".nim" &
|
|
|
|
" " &
|
|
|
|
cmdParams
|
2021-03-28 23:03:18 +00:00
|
|
|
if getEnv("RUN_AFTER_BUILD").strip != "false":
|
|
|
|
exec outDir & name
|
|
|
|
|
2021-07-28 21:03:55 +00:00
|
|
|
task client, "Build and run the example client":
|
2021-03-28 23:03:18 +00:00
|
|
|
buildAndRun(
|
2021-07-28 21:03:55 +00:00
|
|
|
"client", "examples/", "build/",
|
2021-07-08 17:55:50 +00:00
|
|
|
"-d:chronicles_runtime_filtering" &
|
2021-03-28 23:03:18 +00:00
|
|
|
" -d:chronicles_sinks=textlines[file]" &
|
|
|
|
(if getEnv("NCURSES_STATIC").strip != "false": " --dynlibOverride:ncursesw" else: "") &
|
|
|
|
(if getEnv("NCURSES_LDFLAGS").strip != "": " --passL:\"" & getEnv("NCURSES_LDFLAGS") & "\"" else: ""))
|
|
|
|
|
|
|
|
task waku_chat2, "Build and run the example waku_chat2 client":
|
2021-07-28 21:03:55 +00:00
|
|
|
buildAndRun "chat2", "examples/waku/", "build/"
|
2020-07-13 14:26:31 +00:00
|
|
|
|
2021-03-28 23:03:18 +00:00
|
|
|
task tests, "Build and run all tests":
|
|
|
|
rmDir "test/build/"
|
|
|
|
buildAndRun "test_all"
|