From 14d2c3f51efc7d66b70532a43b6f1b2efa8774de Mon Sep 17 00:00:00 2001 From: Miran Date: Thu, 1 Sep 2022 14:00:22 +0200 Subject: [PATCH] Configuration refactoring (#732) move -d:nimRawSetjmp to nim.cfg switch .cfg to .nims add --skipParentCfg Co-authored-by: Tanguy --- .github/workflows/ci.yml | 4 ---- .github/workflows/multi_nim.yml | 4 ---- config.nims | 15 +++++++++++++++ libp2p.nimble | 22 ++++------------------ tests/config.nims | 3 +++ tests/nim.cfg | 1 - 6 files changed, 22 insertions(+), 27 deletions(-) create mode 100644 tests/config.nims delete mode 100644 tests/nim.cfg diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 493973db5..d671424ba 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -162,10 +162,6 @@ jobs: - name: Run tests run: | - if [[ "${{ matrix.target.os }}" == "windows" ]]; then - # https://github.com/status-im/nimbus-eth2/issues/3121 - export NIMFLAGS="-d:nimRawSetjmp" - fi nim --version nimble --version nimble install_pinned diff --git a/.github/workflows/multi_nim.yml b/.github/workflows/multi_nim.yml index 943a3cd70..4b52a8159 100644 --- a/.github/workflows/multi_nim.yml +++ b/.github/workflows/multi_nim.yml @@ -160,10 +160,6 @@ jobs: - name: Run tests run: | - if [[ "${{ matrix.target.os }}" == "windows" ]]; then - # https://github.com/status-im/nimbus-eth2/issues/3121 - export NIMFLAGS="-d:nimRawSetjmp" - fi nim --version nimble --version nimble install -y --depsOnly diff --git a/config.nims b/config.nims index 0a5c80dbc..da72649d4 100644 --- a/config.nims +++ b/config.nims @@ -2,6 +2,21 @@ if dirExists("nimbledeps/pkgs"): switch("NimblePath", "nimbledeps/pkgs") +switch("warning", "CaseTransition:off") +switch("warning", "ObservableStores:off") +switch("warning", "LockLevel:off") +--define:chronosStrictException +--styleCheck:usages +if (NimMajor, NimMinor) < (1, 6): + --styleCheck:hint +else: + --styleCheck:error + +# Avoid some rare stack corruption while using exceptions with a SEH-enabled +# toolchain: https://github.com/status-im/nimbus-eth2/issues/3121 +if defined(windows) and not defined(vcc): + --define:nimRawSetjmp + # begin Nimble config (version 1) when fileExists("nimble.paths"): include "nimble.paths" diff --git a/libp2p.nimble b/libp2p.nimble index 26925ee2b..f17495cd6 100644 --- a/libp2p.nimble +++ b/libp2p.nimble @@ -18,26 +18,13 @@ requires "nim >= 1.2.0", "stew#head", "websock" -const styleCheckStyle = - if (NimMajor, NimMinor) < (1, 6): - "hint" - else: - "error" - -const nimflags = - "--verbosity:0 --hints:off " & - "--warning[CaseTransition]:off --warning[ObservableStores]:off " & - "--warning[LockLevel]:off " & - "-d:chronosStrictException " & - "--styleCheck:usages --styleCheck:" & styleCheckStyle & " " - proc runTest(filename: string, verify: bool = true, sign: bool = true, moreoptions: string = "") = - var excstr = "nim c --opt:speed -d:debug -d:libp2p_agents_metrics -d:libp2p_protobuf_metrics -d:libp2p_network_protocols_metrics -d:libp2p_mplex_metrics " + 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 " excstr.add(" -d:chronicles_sinks=textlines[stdout],json[dynamic] -d:chronicles_log_level=TRACE ") excstr.add(" -d:chronicles_runtime_filtering=TRUE ") excstr.add(" " & getEnv("NIMFLAGS") & " ") - excstr.add(" " & nimflags & " ") + excstr.add(" --verbosity:0 --hints:off ") excstr.add(" -d:libp2p_pubsub_sign=" & $sign) excstr.add(" -d:libp2p_pubsub_verify=" & $verify) excstr.add(" " & moreoptions & " ") @@ -45,8 +32,7 @@ proc runTest(filename: string, verify: bool = true, sign: bool = true, rmFile "tests/" & filename.toExe proc buildSample(filename: string, run = false) = - var excstr = "nim c --opt:speed --threads:on -d:debug " - excstr.add(" " & nimflags & " ") + var excstr = "nim c --opt:speed --threads:on -d:debug --verbosity:0 --hints:off " excstr.add(" examples/" & filename) exec excstr if run: @@ -55,7 +41,7 @@ proc buildSample(filename: string, run = false) = proc buildTutorial(filename: string) = discard gorge "cat " & filename & " | nim c -r --hints:off tools/markdown_runner.nim | " & - " nim " & nimflags & " c -" + " nim --verbosity:0 --hints:off c -" task testnative, "Runs libp2p native tests": runTest("testnative") diff --git a/tests/config.nims b/tests/config.nims new file mode 100644 index 000000000..3ec031e76 --- /dev/null +++ b/tests/config.nims @@ -0,0 +1,3 @@ +import ../config.nims + +--threads:on diff --git a/tests/nim.cfg b/tests/nim.cfg deleted file mode 100644 index 9d57ecf93..000000000 --- a/tests/nim.cfg +++ /dev/null @@ -1 +0,0 @@ ---threads:on \ No newline at end of file