mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-10 12:26:02 +00:00
ede45648e7
- build all tools using the Makefile and place them in ./build - add copyright header to Makefile - premix/readme.md edited to fix some errors, improve descriptions and document Makefile usage - link the Premix documentation in the main README.md - also build `hunter` in the nimble tests - refactored the file and directory search so all debugging tools can be run from the top-level dir like this: `./build/<tool> ...` - write all JSON debugging data in the current directory - add JSON files generated in the top-level dir to .gitignore - Nimbus now exits with an exception after dumping debug data and running `premix` on it
48 lines
1.0 KiB
Nim
48 lines
1.0 KiB
Nim
import os, osproc, json
|
|
|
|
when defined(windows):
|
|
const
|
|
premixExecutable = "premix.exe"
|
|
browserLauncher = "cmd /c start"
|
|
elif defined(macos):
|
|
const
|
|
premixExecutable = "premix"
|
|
browserLauncher = "open"
|
|
else:
|
|
const
|
|
premixExecutable = "premix"
|
|
browserLauncher = "xdg-open"
|
|
|
|
proc getFileDir*(file: string): string =
|
|
var searchDirs = [
|
|
"." ,
|
|
"." / "build" ,
|
|
"." / "premix"
|
|
]
|
|
|
|
for dir in searchDirs:
|
|
if fileExists(dir / file):
|
|
return dir
|
|
|
|
result = ""
|
|
|
|
proc getFilePath(file: string): string =
|
|
let dir = getFileDir(file)
|
|
if dir.len > 0:
|
|
return dir / file
|
|
else:
|
|
return ""
|
|
|
|
proc launchPremix*(fileName: string, metaData: JsonNode) =
|
|
let premixExe = getFilePath(premixExecutable)
|
|
|
|
writeFile(fileName, metaData.pretty)
|
|
|
|
if premixExe.len > 0:
|
|
if execCmd(premixExe & " " & fileName) == 0:
|
|
if execCmd(browserLauncher & " " & getFilePath("index.html")) != 0:
|
|
echo "failed to launch default browser"
|
|
else:
|
|
echo "failed to execute the premix debugging tool"
|
|
|