From 28781608a50a7bf84f7f28992e8b671366538677 Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Wed, 17 Aug 2022 20:34:09 -0500 Subject: [PATCH] [wip] refactor Makefile and .nimble support to be more flexible --- Makefile | 15 ++++++++++----- codex.nimble | 13 +++++++------ testground/hello_codex/Dockerfile | 5 +++-- .../hello_codex/{hello_codex.nim => main.nim} | 0 testground/hello_codex/manifest.toml | 2 +- 5 files changed, 21 insertions(+), 14 deletions(-) rename testground/hello_codex/{hello_codex.nim => main.nim} (100%) diff --git a/Makefile b/Makefile index f8660d24..85f03980 100644 --- a/Makefile +++ b/Makefile @@ -24,10 +24,10 @@ LINK_PCRE := 0 clean \ coverage \ deps \ - hello_codex \ libbacktrace \ test \ testground \ + testground_exec \ update ifeq ($(NIM_PARAMS),) @@ -125,13 +125,18 @@ coverage: genhtml coverage/coverage.f.info --output-directory coverage/report if which open >/dev/null; then (echo -e "\e[92mOpening\e[39m HTML coverage report in browser..." && open coverage/report/index.html) || true; fi +TESTGROUND_BUILDER ?= docker:generic +TESTGROUND_PLAN ?= hello_codex +TESTGROUND_RUNNER ?= local:docker +TESTGROUND_TESTCASE ?= hello + testground: mkdir -p scratch && rm -rf scratch/* && git clone --depth=1 "file://$${PWD}" "scratch/$$(basename $${PWD})" - testground plan import --from=testground/hello_codex - testground run single --builder=docker:generic --runner=local:docker --plan=hello_codex --testcase=hello_codex --instances=2 + testground plan import --from=testground/$(TESTGROUND_PLAN) + testground run single --builder=$(TESTGROUND_BUILDER) --runner=$(TESTGROUND_RUNNER) --plan=$(TESTGROUND_PLAN) --testcase=$(TESTGROUND_TESTCASE) --instances=2 -hello_codex: | build deps - $(ENV_SCRIPT) nim hello_codex codex.nims +testground_exec: | build deps + TESTGROUND_PLAN=$(TESTGROUND_PLAN) $(ENV_SCRIPT) nim testground_exec codex.nims # usual cleaning clean: | clean-common diff --git a/codex.nimble b/codex.nimble index 5df8c365..3da66c97 100644 --- a/codex.nimble +++ b/codex.nimble @@ -31,13 +31,15 @@ requires "nim >= 1.2.0", "libp2pdht", "eth" +import std/strutils + when declared(namedBin): namedBin = { "codex/codex": "codex" }.toTable() ### Helper functions -proc buildBinary(name: string, srcDir = "./", params = "", lang = "c") = +proc buildBinary(name: string, outName = "", srcDir = "./", params = "", lang = "c") = if not dirExists "build": mkDir "build" # allow something like "nim nimbus --verbosity:0 --hints:off nimbus.nims" @@ -49,18 +51,17 @@ proc buildBinary(name: string, srcDir = "./", params = "", lang = "c") = for i in 2..