Exclude comments from output with flag
This commit is contained in:
parent
b0a8f9bec5
commit
d9ab18c775
4 changed files with 27 additions and 27 deletions
|
|
@ -27,12 +27,9 @@ proc execTest(test: string) =
|
|||
proc tsoloud() =
|
||||
execTest "tests/tsoloud.nim"
|
||||
|
||||
proc buildToast() =
|
||||
execCmd(&"nim c -d:release nimterop/toast.nim")
|
||||
|
||||
task rebuildToast, "rebuild toast":
|
||||
task buildToast, "build toast":
|
||||
# If need to manually rebuild (automatically built on 1st need)
|
||||
buildToast()
|
||||
execCmd(&"nim c -d:release nimterop/toast.nim")
|
||||
|
||||
proc testAll() =
|
||||
execTest "tests/tnimterop_c.nim"
|
||||
|
|
@ -69,7 +66,7 @@ proc runNimDoc() =
|
|||
execCmd &"nim js -o:{htmldocsDir}/dochack.js {getNimRootDir()}/tools/dochack/dochack.nim"
|
||||
|
||||
task test, "Test":
|
||||
buildToast()
|
||||
buildToastTask()
|
||||
testAll()
|
||||
runNimDoc()
|
||||
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ type
|
|||
State = ref object
|
||||
compile*, defines*, headers*, includeDirs*, searchDirs*, symOverride*: seq[string]
|
||||
|
||||
nocache*, debug*, past*, preprocess*, pnim*, pretty*, recurse*: bool
|
||||
nocache*, nocomments*, debug*, past*, preprocess*, pnim*, pretty*, recurse*: bool
|
||||
|
||||
code*, mode*, pluginSourcePath*: string
|
||||
|
||||
|
|
@ -64,7 +64,7 @@ type
|
|||
NimState {.used.} = ref object
|
||||
identifiers*: TableRef[string, string]
|
||||
|
||||
constStr*, debugStr*, enumStr*, procStr*, typeStr*, commentStr*: string
|
||||
commentStr*, constStr*, debugStr*, enumStr*, procStr*, typeStr*: string
|
||||
|
||||
gState*: State
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ proc genPragma(nimState: NimState, pragmas: varargs[string]): string =
|
|||
result = result.replace(nimState.impHeader & ", cdecl", nimState.impHeader & "C")
|
||||
|
||||
proc getComments(nimState: NimState): string =
|
||||
if nimState.commentStr.len != 0:
|
||||
if not nimState.gState.nocomments and nimState.commentStr.len != 0:
|
||||
result = "\n" & nimState.commentStr
|
||||
nimState.commentStr = ""
|
||||
|
||||
|
|
|
|||
|
|
@ -98,33 +98,34 @@ proc process(gState: State, path: string, astTable: AstTable) =
|
|||
echo gState.code
|
||||
|
||||
proc main(
|
||||
mode = modeDefault,
|
||||
preprocess = false,
|
||||
past = false,
|
||||
pnim = false,
|
||||
pretty = true,
|
||||
preprocess = false,
|
||||
pgrammar = false,
|
||||
recurse = false,
|
||||
debug = false,
|
||||
nocomments = false,
|
||||
defines: seq[string] = @[],
|
||||
includeDirs: seq[string] = @[],
|
||||
symOverride: seq[string] = @[],
|
||||
pluginSourcePath: string = "",
|
||||
source: seq[string],
|
||||
debug = false,
|
||||
mode = modeDefault,
|
||||
pgrammar = false,
|
||||
source: seq[string]
|
||||
) =
|
||||
|
||||
var gState = State(
|
||||
mode: mode,
|
||||
preprocess: preprocess,
|
||||
past: past,
|
||||
pnim: pnim,
|
||||
pretty: pretty,
|
||||
preprocess: preprocess,
|
||||
recurse: recurse,
|
||||
debug: debug,
|
||||
nocomments: nocomments,
|
||||
defines: defines,
|
||||
includeDirs: includeDirs,
|
||||
symOverride: symOverride,
|
||||
pluginSourcePath: pluginSourcePath
|
||||
pluginSourcePath: pluginSourcePath,
|
||||
debug: debug,
|
||||
mode: mode,
|
||||
pretty: true
|
||||
)
|
||||
|
||||
gState.symOverride = gState.symOverride.getSplitComma()
|
||||
|
|
@ -145,26 +146,28 @@ proc main(
|
|||
when isMainModule:
|
||||
import cligen
|
||||
dispatch(main, help = {
|
||||
"preprocess": "run preprocessor on header",
|
||||
"past": "print AST output",
|
||||
"mode": "language; see CompileMode", # TODO: auto-generate valid choices
|
||||
"pnim": "print Nim output",
|
||||
"recurse": "process #include files",
|
||||
"nocomments": "exclude top-level comments from output",
|
||||
"defines": "definitions to pass to preprocessor",
|
||||
"includeDirs": "include directory to pass to preprocessor",
|
||||
"symOverride": "skip generating specified symbols",
|
||||
"pluginSourcePath": "Nim file to build and load as a plugin",
|
||||
"preprocess": "run preprocessor on header",
|
||||
"pgrammar": "print grammar",
|
||||
"recurse": "process #include files",
|
||||
"debug": "enable debug output",
|
||||
"source" : "C/C++ source/header",
|
||||
"mode": "language parser: c or cpp",
|
||||
"pgrammar": "print grammar",
|
||||
"source" : "C/C++ source/header"
|
||||
}, short = {
|
||||
"preprocess": 'p',
|
||||
"past": 'a',
|
||||
"pnim": 'n',
|
||||
"recurse": 'r',
|
||||
"nocomments": 'c',
|
||||
"defines": 'D',
|
||||
"includeDirs": 'I',
|
||||
"symOverride": 'O',
|
||||
"preprocess": 'p',
|
||||
"recurse": 'r',
|
||||
"debug": 'd',
|
||||
"pgrammar": 'g'
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue