use cligen; fix bugs; some cleanups
This commit is contained in:
parent
691e7d80e5
commit
4a6973c14d
6 changed files with 62 additions and 54 deletions
|
|
@ -26,15 +26,19 @@ proc findPath(path: string, fail = true): string =
|
|||
|
||||
proc getToast(fullpath: string): string =
|
||||
var
|
||||
cmd = "toast -n -p "
|
||||
cmd = "toast --pnim --preprocess "
|
||||
|
||||
for i in gStateCT.defines:
|
||||
cmd &= &"-D\"{i}\" "
|
||||
cmd.add &"--defines+={i.quoteShell} "
|
||||
|
||||
for i in gStateCT.includeDirs:
|
||||
cmd &= &"-I\"{i}\" "
|
||||
cmd.add &"--includeDirs+={i.quoteShell} "
|
||||
|
||||
result = staticExec(cmd & fullpath)
|
||||
cmd.add &"--source:{fullpath.quoteShell}"
|
||||
echo cmd
|
||||
var (output, exitCode) = gorgeEx(cmd)
|
||||
doAssert exitCode == 0, $exitCode
|
||||
result = output
|
||||
|
||||
proc cSearchPath*(path: string): string {.compileTime.}=
|
||||
result = findPath(path, fail = false)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import macros, ospaths, strformat, strutils
|
||||
import macros, os, strformat, strutils
|
||||
|
||||
import regex
|
||||
|
||||
|
|
|
|||
|
|
@ -12,5 +12,13 @@ var
|
|||
gStateCT* {.compiletime.}: State
|
||||
gStateRT*: State
|
||||
|
||||
template nBl*(s: untyped): untyped =
|
||||
(s.len != 0)
|
||||
template nBl*(s: typed): untyped =
|
||||
(s.len != 0)
|
||||
|
||||
|
||||
type CompileMode* = enum
|
||||
c,
|
||||
cpp,
|
||||
|
||||
# TODO: can cligen accept enum instead of string?
|
||||
const modeDefault* = $cpp # TODO: USE this everywhere relevant
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import strutils
|
||||
import strformat
|
||||
|
||||
import globals
|
||||
|
||||
|
|
@ -11,7 +12,11 @@ proc tokenize(fullpath: string) =
|
|||
|
||||
gTokens = @[]
|
||||
idx = 0
|
||||
for i in staticExec("toast -m " & fullpath):
|
||||
# TODO: consider calling API directly
|
||||
const cmd = &"toast --past --pretty:false --source:{fullpath.quoteShell}"
|
||||
var (output, exitCode) = gorgeEx cmd
|
||||
doAssert exitCode == 0, $exitCode
|
||||
for i in output:
|
||||
case i:
|
||||
of ' ', '\n', '\r', '(', ')':
|
||||
if collect.nBl:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue