Add feature flag capability

This commit is contained in:
Ganesh Viswanathan 2020-03-09 21:20:24 -05:00
commit 1b63a125c5
4 changed files with 22 additions and 8 deletions

View file

@ -9,4 +9,11 @@ when defined(Windows):
switch("gc", "markAndSweep")
# Retain stackTrace for clear errors
switch("stackTrace", "on")
switch("stackTrace", "on")
# Path to compiler
switch("path", "$nim")
# Case objects
when not defined(danger):
switch("define", "nimOldCaseObjects")

View file

@ -25,7 +25,7 @@ proc execTest(test: string) =
execCmd "nim cpp -r " & test
task buildToast, "build toast":
execCmd("nim c -f -d:danger nimterop/toast.nim")
execCmd("nim c -f nimterop/toast.nim")
task bt, "build toast":
execCmd("nim c -d:danger nimterop/toast.nim")

View file

@ -59,6 +59,8 @@ type
code*, dynlib*, mode*, nim*, overrides*, pluginSource*, pluginSourcePath*: string
feature*: seq[Feature]
onSymbol*, onSymbolOverride*: OnSymbol
onSymbolOverrideFinal*: OnSymbolOverrideFinal
@ -77,6 +79,12 @@ type
nodeBranch*: seq[string]
CompileMode = enum
c, cpp
Feature* = enum
ast2
var
gStateCT {.compiletime, used.} = new(State)
@ -86,12 +94,7 @@ template nBl(s: typed): untyped {.used.} =
template Bl(s: typed): untyped {.used.} =
(s.len == 0)
type CompileMode = enum
c,
cpp,
# TODO: can cligen accept enum instead of string?
const modeDefault {.used.} = $cpp # TODO: USE this everywhere relevant
const modeDefault {.used.} = $cpp
when not declared(CIMPORT):
export gAtoms, gExpressions, gEnumVals, Kind, Ast, AstTable, State, NimState,

View file

@ -103,6 +103,7 @@ proc main(
debug = false,
defines: seq[string] = @[],
dynlib: string = "",
feature: seq[Feature] = @[],
includeDirs: seq[string] = @[],
mode = modeDefault,
nim: string = "nim",
@ -126,6 +127,7 @@ proc main(
debug: debug,
defines: defines,
dynlib: dynlib,
feature: feature,
includeDirs: includeDirs,
mode: mode,
nim: nim,
@ -235,6 +237,7 @@ when isMainModule:
"debug": "enable debug output",
"defines": "definitions to pass to preprocessor",
"dynlib": "Import symbols from library in specified Nim string",
"feature": "flags to enable experimental features",
"includeDirs": "include directory to pass to preprocessor",
"mode": "language parser: c or cpp",
"nim": "use a particular Nim executable (default: $PATH/nim)",
@ -256,6 +259,7 @@ when isMainModule:
"debug": 'd',
"defines": 'D',
"dynlib": 'l',
"feature": 'f',
"includeDirs": 'I',
"nocomments": 'c',
"output": 'o',