mirror of
https://github.com/status-im/nim-dagger.git
synced 2025-02-08 12:54:41 +00:00
cleanup
This commit is contained in:
parent
6352392d87
commit
7ed2c0a531
@ -1,24 +1,5 @@
|
|||||||
import std/[hashes, json, strutils, strformat, os, osproc]
|
import std/[hashes, json, strutils, strformat, os, osproc]
|
||||||
|
|
||||||
template withDir(dir: string, blk: untyped) =
|
|
||||||
let prev = getCurrentDir()
|
|
||||||
try:
|
|
||||||
setCurrentDir(dir)
|
|
||||||
`blk`
|
|
||||||
finally:
|
|
||||||
setCurrentDir(prev)
|
|
||||||
|
|
||||||
proc setProjDir(prev = getCurrentDir()): string =
|
|
||||||
if not "codex.nimble".fileExists():
|
|
||||||
setCurrentDir("..")
|
|
||||||
if prev == getCurrentDir():
|
|
||||||
echo "\nERROR: Codex project folder not found (could not find codex.nimble)"
|
|
||||||
echo "\nBenchmark must be run from within the Codex project folder"
|
|
||||||
quit 1
|
|
||||||
setProjDir()
|
|
||||||
else:
|
|
||||||
getCurrentDir()
|
|
||||||
|
|
||||||
type
|
type
|
||||||
CircuitEnv* = object
|
CircuitEnv* = object
|
||||||
nimCircuitCli =
|
nimCircuitCli =
|
||||||
@ -41,8 +22,29 @@ type
|
|||||||
ncells*: int
|
ncells*: int
|
||||||
index*: int
|
index*: int
|
||||||
|
|
||||||
proc checkEnv*() =
|
template withDir(dir: string, blk: untyped) =
|
||||||
codexProjDir = setProjDir()
|
let prev = getCurrentDir()
|
||||||
|
try:
|
||||||
|
setCurrentDir(dir)
|
||||||
|
`blk`
|
||||||
|
finally:
|
||||||
|
setCurrentDir(prev)
|
||||||
|
|
||||||
|
proc findCodexProjectDir(prev = getCurrentDir()): string =
|
||||||
|
## check that the CWD of script is in the codex parent
|
||||||
|
if not "codex.nimble".fileExists():
|
||||||
|
setCurrentDir("..")
|
||||||
|
if prev == getCurrentDir():
|
||||||
|
echo "\nERROR: Codex project folder not found (could not find codex.nimble)"
|
||||||
|
echo "\nBenchmark must be run from within the Codex project folder"
|
||||||
|
quit 1
|
||||||
|
setProjDir()
|
||||||
|
else:
|
||||||
|
getCurrentDir()
|
||||||
|
|
||||||
|
proc checkEnv*(env: CircuitEnv) =
|
||||||
|
## check that the CWD of script is in the codex parent
|
||||||
|
codexProjDir = findCodexProjectDir()
|
||||||
echo "\n\nFound project dir: ", codexProjDir
|
echo "\n\nFound project dir: ", codexProjDir
|
||||||
|
|
||||||
let snarkjs = findExe("snarkjs")
|
let snarkjs = findExe("snarkjs")
|
||||||
@ -187,6 +189,7 @@ proc createCircuit*(
|
|||||||
return (circdir, name)
|
return (circdir, name)
|
||||||
|
|
||||||
when isMainModule:
|
when isMainModule:
|
||||||
|
## test run creating a circuit
|
||||||
checkEnv()
|
checkEnv()
|
||||||
|
|
||||||
let args = CircArgs(
|
let args = CircArgs(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user