[wip] refactor Makefile and .nimble support to be more flexible
This commit is contained in:
parent
e9b3dd070e
commit
28781608a5
15
Makefile
15
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
|
||||
|
|
13
codex.nimble
13
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..<paramCount():
|
||||
extra_params &= " " & paramStr(i)
|
||||
|
||||
|
||||
exec "nim " & lang & " --out:build/" & name & " " & extra_params & " " & srcDir & name & ".nim"
|
||||
exec "nim " & lang & " --out:build/" & (if outName != "": outName else: name) & " " & extra_params & " " & srcDir & name & ".nim"
|
||||
|
||||
proc test(name: string, srcDir = "tests/", lang = "c") =
|
||||
buildBinary name, srcDir
|
||||
buildBinary name, srcDir = srcDir
|
||||
exec "build/" & name
|
||||
|
||||
task codex, "build codex binary":
|
||||
buildBinary "codex", params = "-d:chronicles_runtime_filtering -d:chronicles_log_level=TRACE"
|
||||
|
||||
task hello_codex, "build hello_codex binary":
|
||||
buildBinary "hello_codex", srcDir = "testground/hello_codex/", params = "-d:chronicles_runtime_filtering"
|
||||
task testground_exec, "build codex_testground binary":
|
||||
buildBinary "main", outName = "codex_testground", srcDir = "testground/" & getEnv("TESTGROUND_PLAN").strip & "/"
|
||||
|
||||
task testCodex, "Build & run Codex tests":
|
||||
test "testCodex"
|
||||
|
|
|
@ -9,6 +9,7 @@ COPY . .
|
|||
|
||||
RUN cd /extra/scratch/nim-codex && make USE_SYSTEM_NIM=1 V=1 update
|
||||
|
||||
RUN cd /extra/scratch/nim-codex && make USE_SYSTEM_NIM=1 V=1 hello_codex
|
||||
RUN cd /extra/scratch/nim-codex && \
|
||||
make TESTGROUND_PLAN=hello_codex USE_SYSTEM_NIM=1 V=1 testground_exec
|
||||
|
||||
ENTRYPOINT ["/extra/scratch/nim-codex/build/hello_codex"]
|
||||
ENTRYPOINT ["/extra/scratch/nim-codex/build/codex_testground"]
|
||||
|
|
|
@ -10,7 +10,7 @@ enabled = true
|
|||
enabled = true
|
||||
|
||||
[[testcases]]
|
||||
name= "hello_codex"
|
||||
name= "hello"
|
||||
instances = { min = 2, default = 2, max = 200 }
|
||||
|
||||
# [testcases.params]
|
||||
|
|
Loading…
Reference in New Issue