2018-11-19 04:52:11 +02:00
|
|
|
mode = ScriptMode.Verbose
|
|
|
|
|
2018-11-19 06:03:23 +02:00
|
|
|
packageName = "libp2p"
|
2019-11-06 13:01:16 +02:00
|
|
|
version = "0.0.2"
|
2018-11-19 04:52:11 +02:00
|
|
|
author = "Status Research & Development GmbH"
|
|
|
|
description = "LibP2P implementation"
|
|
|
|
license = "MIT"
|
2020-09-15 12:16:43 +03:00
|
|
|
skipDirs = @["tests", "examples", "Nim", "tools", "scripts", "docs"]
|
2018-11-19 04:52:11 +02:00
|
|
|
|
2020-04-14 13:26:12 +08:00
|
|
|
requires "nim >= 1.2.0",
|
|
|
|
"nimcrypto >= 0.4.1",
|
2022-01-05 16:27:33 +01:00
|
|
|
"dnsclient >= 0.1.2",
|
2020-03-06 21:19:43 +02:00
|
|
|
"bearssl >= 0.1.4",
|
2021-12-16 19:00:10 +01:00
|
|
|
"chronicles >= 0.10.2",
|
2021-11-24 14:01:12 -06:00
|
|
|
"chronos >= 3.0.6",
|
2020-04-14 15:27:07 +02:00
|
|
|
"metrics",
|
|
|
|
"secp256k1",
|
2021-08-03 15:48:03 +02:00
|
|
|
"stew#head",
|
2021-11-08 13:02:03 +01:00
|
|
|
"websock"
|
2018-11-19 04:52:11 +02:00
|
|
|
|
2020-07-21 23:10:21 +03:00
|
|
|
proc runTest(filename: string, verify: bool = true, sign: bool = true,
|
|
|
|
moreoptions: string = "") =
|
2022-09-01 14:00:22 +02:00
|
|
|
var excstr = "nim c --skipParentCfg --opt:speed -d:debug -d:libp2p_agents_metrics -d:libp2p_protobuf_metrics -d:libp2p_network_protocols_metrics -d:libp2p_mplex_metrics "
|
2022-07-01 20:20:42 +02:00
|
|
|
excstr.add(" -d:chronicles_sinks=textlines[stdout],json[dynamic] -d:chronicles_log_level=TRACE ")
|
|
|
|
excstr.add(" -d:chronicles_runtime_filtering=TRUE ")
|
2022-01-10 12:29:52 +01:00
|
|
|
excstr.add(" " & getEnv("NIMFLAGS") & " ")
|
2022-09-01 14:00:22 +02:00
|
|
|
excstr.add(" --verbosity:0 --hints:off ")
|
2020-06-20 19:56:55 +09:00
|
|
|
excstr.add(" -d:libp2p_pubsub_sign=" & $sign)
|
|
|
|
excstr.add(" -d:libp2p_pubsub_verify=" & $verify)
|
2020-07-21 23:10:21 +03:00
|
|
|
excstr.add(" " & moreoptions & " ")
|
2022-07-01 20:20:42 +02:00
|
|
|
exec excstr & " -r " & " tests/" & filename
|
2020-04-14 15:21:16 +02:00
|
|
|
rmFile "tests/" & filename.toExe
|
2019-03-14 03:55:47 +01:00
|
|
|
|
2021-11-08 13:00:44 +01:00
|
|
|
proc buildSample(filename: string, run = false) =
|
2022-09-01 14:00:22 +02:00
|
|
|
var excstr = "nim c --opt:speed --threads:on -d:debug --verbosity:0 --hints:off "
|
2020-06-20 19:56:55 +09:00
|
|
|
excstr.add(" examples/" & filename)
|
|
|
|
exec excstr
|
2021-11-08 13:00:44 +01:00
|
|
|
if run:
|
|
|
|
exec "./examples/" & filename.toExe
|
|
|
|
rmFile "examples/" & filename.toExe
|
|
|
|
|
|
|
|
proc buildTutorial(filename: string) =
|
|
|
|
discard gorge "cat " & filename & " | nim c -r --hints:off tools/markdown_runner.nim | " &
|
2022-09-01 14:00:22 +02:00
|
|
|
" nim --verbosity:0 --hints:off c -"
|
2020-04-19 14:04:53 +09:00
|
|
|
|
2020-05-06 03:26:08 -06:00
|
|
|
task testnative, "Runs libp2p native tests":
|
2020-04-23 10:27:29 +09:00
|
|
|
runTest("testnative")
|
2020-05-06 03:26:08 -06:00
|
|
|
|
|
|
|
task testdaemon, "Runs daemon tests":
|
2020-04-23 10:27:29 +09:00
|
|
|
runTest("testdaemon")
|
2020-05-06 03:26:08 -06:00
|
|
|
|
|
|
|
task testinterop, "Runs interop tests":
|
2020-04-23 10:27:29 +09:00
|
|
|
runTest("testinterop")
|
2020-04-19 14:04:53 +09:00
|
|
|
|
2020-05-06 03:26:08 -06:00
|
|
|
task testpubsub, "Runs pubsub tests":
|
2020-09-21 18:16:29 +09:00
|
|
|
runTest("pubsub/testgossipinternal", sign = false, verify = false, moreoptions = "-d:pubsub_internal_testing")
|
2020-05-06 03:26:08 -06:00
|
|
|
runTest("pubsub/testpubsub")
|
|
|
|
runTest("pubsub/testpubsub", sign = false, verify = false)
|
2020-09-28 16:11:18 +09:00
|
|
|
runTest("pubsub/testpubsub", sign = false, verify = false, moreoptions = "-d:libp2p_pubsub_anonymize=true")
|
2020-05-06 03:26:08 -06:00
|
|
|
|
2020-09-28 16:11:18 +09:00
|
|
|
task testpubsub_slim, "Runs pubsub tests":
|
|
|
|
runTest("pubsub/testgossipinternal", sign = false, verify = false, moreoptions = "-d:pubsub_internal_testing")
|
|
|
|
runTest("pubsub/testpubsub")
|
|
|
|
|
2020-07-21 23:10:21 +03:00
|
|
|
task testfilter, "Run PKI filter test":
|
|
|
|
runTest("testpkifilter",
|
|
|
|
moreoptions = "-d:libp2p_pki_schemes=\"secp256k1\"")
|
|
|
|
runTest("testpkifilter",
|
|
|
|
moreoptions = "-d:libp2p_pki_schemes=\"secp256k1;ed25519\"")
|
|
|
|
runTest("testpkifilter",
|
|
|
|
moreoptions = "-d:libp2p_pki_schemes=\"secp256k1;ed25519;ecnist\"")
|
|
|
|
runTest("testpkifilter",
|
|
|
|
moreoptions = "-d:libp2p_pki_schemes=")
|
|
|
|
|
2020-05-06 03:26:08 -06:00
|
|
|
task test, "Runs the test suite":
|
|
|
|
exec "nimble testnative"
|
|
|
|
exec "nimble testpubsub"
|
|
|
|
exec "nimble testdaemon"
|
|
|
|
exec "nimble testinterop"
|
2020-07-21 23:10:21 +03:00
|
|
|
exec "nimble testfilter"
|
2021-11-08 13:00:44 +01:00
|
|
|
exec "nimble examples_build"
|
2020-05-06 03:26:08 -06:00
|
|
|
|
2022-01-10 12:29:52 +01:00
|
|
|
task test_slim, "Runs the (slimmed down) test suite":
|
2020-09-28 16:11:18 +09:00
|
|
|
exec "nimble testnative"
|
|
|
|
exec "nimble testpubsub_slim"
|
|
|
|
exec "nimble testfilter"
|
2021-11-19 11:52:29 +01:00
|
|
|
exec "nimble examples_build"
|
2020-09-28 16:11:18 +09:00
|
|
|
|
2020-04-19 14:04:53 +09:00
|
|
|
task examples_build, "Build the samples":
|
2020-04-23 10:27:29 +09:00
|
|
|
buildSample("directchat")
|
2021-11-08 13:00:44 +01:00
|
|
|
buildSample("helloworld", true)
|
2022-08-01 14:31:22 +02:00
|
|
|
buildSample("circuitrelay", true)
|
2021-11-08 13:00:44 +01:00
|
|
|
buildTutorial("examples/tutorial_1_connect.md")
|
|
|
|
buildTutorial("examples/tutorial_2_customproto.md")
|
2021-12-16 19:00:10 +01:00
|
|
|
|
|
|
|
# pin system
|
|
|
|
# while nimble lockfile
|
|
|
|
# isn't available
|
|
|
|
|
|
|
|
const PinFile = ".pinned"
|
|
|
|
task pin, "Create a lockfile":
|
|
|
|
# pinner.nim was originally here
|
|
|
|
# but you can't read output from
|
|
|
|
# a command in a nimscript
|
|
|
|
exec "nim c -r tools/pinner.nim"
|
|
|
|
|
|
|
|
import sequtils
|
|
|
|
import os
|
|
|
|
task install_pinned, "Reads the lockfile":
|
|
|
|
let toInstall = readFile(PinFile).splitWhitespace().mapIt((it.split(";", 1)[0], it.split(";", 1)[1]))
|
|
|
|
# [('packageName', 'packageFullUri')]
|
|
|
|
|
|
|
|
rmDir("nimbledeps")
|
|
|
|
mkDir("nimbledeps")
|
|
|
|
exec "nimble install -y " & toInstall.mapIt(it[1]).join(" ")
|
|
|
|
|
|
|
|
# Remove the automatically installed deps
|
|
|
|
# (inefficient you say?)
|
|
|
|
let allowedDirectories = toInstall.mapIt(it[0] & "-" & it[1].split('@')[1])
|
|
|
|
for dependency in listDirs("nimbledeps/pkgs"):
|
|
|
|
if dependency.extractFilename notin allowedDirectories:
|
|
|
|
rmDir(dependency)
|
|
|
|
|
|
|
|
task unpin, "Restore global package use":
|
|
|
|
rmDir("nimbledeps")
|