diff options
| author | Ganesh Viswanathan <dev@genotrance.com> | 2020-03-09 21:20:24 -0500 |
|---|---|---|
| committer | Ganesh Viswanathan <dev@genotrance.com> | 2020-03-09 21:20:24 -0500 |
| commit | 1b63a125c527668b2e75080b62435d0b888d457f (patch) | |
| tree | ea26ab019eebb2dfcd3dbbd1a719a5be0a28caf6 | |
| parent | 6130c04bd8b239c31398af7b79e068abfdbd43f3 (diff) | |
| download | nimterop-1b63a125c527668b2e75080b62435d0b888d457f.tar.gz nimterop-1b63a125c527668b2e75080b62435d0b888d457f.zip | |
Add feature flag capability
| -rw-r--r-- | config.nims | 9 | ||||
| -rw-r--r-- | nimterop.nimble | 2 | ||||
| -rw-r--r-- | nimterop/globals.nim | 15 | ||||
| -rw-r--r-- | nimterop/toast.nim | 4 |
4 files changed, 22 insertions, 8 deletions
diff --git a/config.nims b/config.nims index 54a9a06..7e7a6e1 100644 --- a/config.nims +++ b/config.nims @@ -9,4 +9,11 @@ when defined(Windows): switch("gc", "markAndSweep") # Retain stackTrace for clear errors -switch("stackTrace", "on")
\ No newline at end of file +switch("stackTrace", "on") + +# Path to compiler +switch("path", "$nim") + +# Case objects +when not defined(danger): + switch("define", "nimOldCaseObjects")
\ No newline at end of file diff --git a/nimterop.nimble b/nimterop.nimble index 3b6b7c1..37637f5 100644 --- a/nimterop.nimble +++ b/nimterop.nimble @@ -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") diff --git a/nimterop/globals.nim b/nimterop/globals.nim index 52343de..9ee9de1 100644 --- a/nimterop/globals.nim +++ b/nimterop/globals.nim @@ -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, diff --git a/nimterop/toast.nim b/nimterop/toast.nim index 76604f1..40cc704 100644 --- a/nimterop/toast.nim +++ b/nimterop/toast.nim @@ -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', |
