From 80cfc99dcd08a145569f28ad6b9999dbd9868bda Mon Sep 17 00:00:00 2001 From: Ganesh Viswanathan Date: Wed, 20 May 2020 16:58:52 -0500 Subject: Fix nimconf path to nim --- nimterop/ast2.nim | 2 +- nimterop/build.nim | 14 +++++++++----- nimterop/getters.nim | 2 +- nimterop/nimconf.nim | 2 +- nimterop/toast.nim | 5 +++-- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/nimterop/ast2.nim b/nimterop/ast2.nim index e2cdf8f..b604f1b 100644 --- a/nimterop/ast2.nim +++ b/nimterop/ast2.nim @@ -139,7 +139,7 @@ proc newConstDef(gState: State, node: TSNode, fname = "", fval = ""): PNode = else: gecho &"# const '{origname}' is duplicate, skipped" else: - gecho &"# const '{origname}' has unsupported value '{val}'" + gecho &"# const '{origname}' has unsupported value '{val.strip()}'" gState.skippedSyms.incl origname proc addConst(gState: State, node: TSNode) = diff --git a/nimterop/build.nim b/nimterop/build.nim index 6f13ac7..58ecbd1 100644 --- a/nimterop/build.nim +++ b/nimterop/build.nim @@ -15,6 +15,7 @@ type var gDebug* = false gDebugCT* {.compileTime.} = false + gNimExe* = "" proc echoDebug(str: string) = let str = "\n# " & str.strip().replace("\n", "\n# ") @@ -46,6 +47,14 @@ proc sanitizePath*(path: string, noQuote = false, sep = $DirSep): string = if not noQuote: result = result.quoteShell +proc getCurrentNimCompiler*(): string = + when nimvm: + result = getCurrentCompilerExe() + when defined(nimsuggest): + result = result.replace("nimsuggest", "nim") + else: + result = gNimExe + # Nim cfg file related functionality include "."/nimconf @@ -64,11 +73,6 @@ proc getNimteropCacheDir(): string = # Get location to cache all nimterop artifacts result = getNimcacheDir() / "nimterop" -proc getCurrentNimCompiler*(): string = - result = getCurrentCompilerExe() - when defined(nimsuggest): - result = result.replace("nimsuggest", "nim") - proc execAction*(cmd: string, retry = 0, die = true, cache = false, cacheKey = ""): tuple[output: string, ret: int] = ## Execute an external command - supported at compile time diff --git a/nimterop/getters.nim b/nimterop/getters.nim index 0906d56..b092663 100644 --- a/nimterop/getters.nim +++ b/nimterop/getters.nim @@ -454,7 +454,7 @@ proc loadPlugin*(gState: State, sourcePath: string) = outflags = &"--out:\"{pdll}\"" # Compile plugin as library with `markAndSweep` GC - cmd = &"{gState.nim.sanitizePath} c --app:lib --gc:markAndSweep {flags} {outflags} {sourcePath.sanitizePath}" + cmd = &"{gState.nim} c --app:lib --gc:markAndSweep {flags} {outflags} {sourcePath.sanitizePath}" discard execAction(cmd) doAssert fileExists(pdll), "No plugin binary generated for " & sourcePath diff --git a/nimterop/nimconf.nim b/nimterop/nimconf.nim index 2a54d7e..33215ef 100644 --- a/nimterop/nimconf.nim +++ b/nimterop/nimconf.nim @@ -20,7 +20,7 @@ type proc getJson(projectDir: string): JsonNode = # Get `nim dump` json value for `projectDir` var - cmd = "nim --hints:off --dump.format:json dump dummy" + cmd = &"{getCurrentNimCompiler()} --hints:off --dump.format:json dump dummy" dump = "" ret = 0 diff --git a/nimterop/toast.nim b/nimterop/toast.nim index 84835a3..4a9553b 100644 --- a/nimterop/toast.nim +++ b/nimterop/toast.nim @@ -64,7 +64,7 @@ proc main( feature: feature, includeDirs: includeDirs, mode: mode, - nim: nim, + nim: nim.sanitizePath, noComments: noComments, noHeader: noHeader, past: past, @@ -79,7 +79,8 @@ proc main( ) # Set gDebug in build.nim - build.gDebug = debug + build.gDebug = gState.debug + build.gNimExe = gState.nim # Default `ast` mode if gState.feature.Bl: -- cgit v1.2.3