From bcc91a319c7b638c3db2da6afe6bd2b06ebf7e0e Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Tue, 24 May 2016 23:35:23 +0200 Subject: [PATCH] Nimscript knows about the command line defines --- compiler/nim.nim | 4 ++-- compiler/scriptconfig.nim | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/nim.nim b/compiler/nim.nim index b242052ec0..a58afd593d 100644 --- a/compiler/nim.nim +++ b/compiler/nim.nim @@ -56,12 +56,12 @@ proc handleCmdLine() = loadConfigs(DefaultConfig) # load all config files let scriptFile = gProjectFull.changeFileExt("nims") if fileExists(scriptFile): - runNimScript(scriptFile) + runNimScript(scriptFile, freshDefines=false) # 'nim foo.nims' means to just run the NimScript file and do nothing more: if scriptFile == gProjectFull: return elif fileExists(gProjectPath / "config.nims"): # directory wide NimScript file - runNimScript(gProjectPath / "config.nims") + runNimScript(gProjectPath / "config.nims", freshDefines=false) # now process command line arguments again, because some options in the # command line can overwite the config file's settings extccomp.initVars() diff --git a/compiler/scriptconfig.nim b/compiler/scriptconfig.nim index 22cd282fda..d04fd52316 100644 --- a/compiler/scriptconfig.nim +++ b/compiler/scriptconfig.nim @@ -118,10 +118,10 @@ proc setupVM*(module: PSym; scriptName: string): PEvalContext = processSwitch(a.getString 0, a.getString 1, passPP, unknownLineInfo()) -proc runNimScript*(scriptName: string) = +proc runNimScript*(scriptName: string; freshDefines=true) = passes.gIncludeFile = includeModule passes.gImportModule = importModule - initDefines() + if freshDefines: initDefines() defineSymbol("nimscript") defineSymbol("nimconfig")