diff options
author | data-man <datamanrb@gmail.com> | 2018-05-19 16:19:29 +0300 |
---|---|---|
committer | data-man <datamanrb@gmail.com> | 2018-05-19 16:19:29 +0300 |
commit | 2a9843c68fc60be6bcb41771dce88df004868e42 (patch) | |
tree | af0396a389f0d35b9239827a7915139e72e6ad9b /compiler/nim.nim | |
parent | 606d8b2f6d0ed4c26d44d2b07b8fef39cabc0b3c (diff) | |
parent | 04ddd069a1b3315dc0e323d98fefd621d1430a4d (diff) | |
download | Nim-2a9843c68fc60be6bcb41771dce88df004868e42.tar.gz |
Merge branch 'devel' of https://github.com/nim-lang/Nim into fix_2753
Diffstat (limited to 'compiler/nim.nim')
-rw-r--r-- | compiler/nim.nim | 89 |
1 files changed, 45 insertions, 44 deletions
diff --git a/compiler/nim.nim b/compiler/nim.nim index 280782330..d3e00017f 100644 --- a/compiler/nim.nim +++ b/compiler/nim.nim @@ -21,7 +21,7 @@ when defined(i386) and defined(windows) and defined(vcc): import commands, lexer, condsyms, options, msgs, nversion, nimconf, ropes, extccomp, strutils, os, osproc, platform, main, parseopt, service, - nodejs, scriptconfig, idents, modulegraphs + nodejs, scriptconfig, idents, modulegraphs, configuration when hasTinyCBackend: import tccgen @@ -37,69 +37,70 @@ proc prependCurDir(f: string): string = else: result = f -proc handleCmdLine(cache: IdentCache; config: ConfigRef) = +proc handleCmdLine(cache: IdentCache; conf: ConfigRef) = + condsyms.initDefines(conf.symbols) if paramCount() == 0: - writeCommandLineUsage() + writeCommandLineUsage(conf, conf.helpWritten) else: # Process command line arguments: - processCmdLine(passCmd1, "", config) - if gProjectName == "-": - gProjectName = "stdinfile" - gProjectFull = "stdinfile" - gProjectPath = canonicalizePath getCurrentDir() - gProjectIsStdin = true - elif gProjectName != "": + processCmdLine(passCmd1, "", conf) + if conf.projectName == "-": + conf.projectName = "stdinfile" + conf.projectFull = "stdinfile" + conf.projectPath = canonicalizePath(conf, getCurrentDir()) + conf.projectIsStdin = true + elif conf.projectName != "": try: - gProjectFull = canonicalizePath(gProjectName) + conf.projectFull = canonicalizePath(conf, conf.projectName) except OSError: - gProjectFull = gProjectName - let p = splitFile(gProjectFull) + conf.projectFull = conf.projectName + let p = splitFile(conf.projectFull) let dir = if p.dir.len > 0: p.dir else: getCurrentDir() - gProjectPath = canonicalizePath dir - gProjectName = p.name + conf.projectPath = canonicalizePath(conf, dir) + conf.projectName = p.name else: - gProjectPath = canonicalizePath getCurrentDir() - loadConfigs(DefaultConfig, config) # load all config files - let scriptFile = gProjectFull.changeFileExt("nims") + conf.projectPath = canonicalizePath(conf, getCurrentDir()) + loadConfigs(DefaultConfig, conf) # load all config files + let scriptFile = conf.projectFull.changeFileExt("nims") if fileExists(scriptFile): - runNimScript(cache, scriptFile, freshDefines=false, config) + runNimScript(cache, scriptFile, freshDefines=false, conf) # 'nim foo.nims' means to just run the NimScript file and do nothing more: - if scriptFile == gProjectFull: return - elif fileExists(gProjectPath / "config.nims"): + if scriptFile == conf.projectFull: return + elif fileExists(conf.projectPath / "config.nims"): # directory wide NimScript file - runNimScript(cache, gProjectPath / "config.nims", freshDefines=false, config) + runNimScript(cache, conf.projectPath / "config.nims", freshDefines=false, conf) # now process command line arguments again, because some options in the # command line can overwite the config file's settings - extccomp.initVars() - processCmdLine(passCmd2, "", config) - if options.command == "": - rawMessage(errNoCommand, command) - mainCommand(newModuleGraph(config), cache) - if optHints in gOptions and hintGCStats in gNotes: echo(GC_getStatistics()) + extccomp.initVars(conf) + processCmdLine(passCmd2, "", conf) + if conf.command == "": + rawMessage(conf, errGenerated, "command missing") + mainCommand(newModuleGraph(conf), cache) + if optHints in conf.options and hintGCStats in conf.notes: echo(GC_getStatistics()) #echo(GC_getStatistics()) - if msgs.gErrorCounter == 0: + if conf.errorCounter == 0: when hasTinyCBackend: - if gCmd == cmdRun: - tccgen.run(config.arguments) - if optRun in gGlobalOptions: - if gCmd == cmdCompileToJS: + if conf.cmd == cmdRun: + tccgen.run(conf.arguments) + if optRun in conf.globalOptions: + if conf.cmd == cmdCompileToJS: var ex: string - if options.outFile.len > 0: - ex = options.outFile.prependCurDir.quoteShell + if conf.outFile.len > 0: + ex = conf.outFile.prependCurDir.quoteShell else: ex = quoteShell( - completeCFilePath(changeFileExt(gProjectFull, "js").prependCurDir)) - execExternalProgram(findNodeJs() & " " & ex & ' ' & config.arguments) + completeCFilePath(conf, changeFileExt(conf.projectFull, "js").prependCurDir)) + execExternalProgram(conf, findNodeJs() & " " & ex & ' ' & conf.arguments) else: var binPath: string - if options.outFile.len > 0: + if conf.outFile.len > 0: # If the user specified an outFile path, use that directly. - binPath = options.outFile.prependCurDir + binPath = conf.outFile.prependCurDir else: # Figure out ourselves a valid binary name. - binPath = changeFileExt(gProjectFull, ExeExt).prependCurDir + binPath = changeFileExt(conf.projectFull, ExeExt).prependCurDir var ex = quoteShell(binPath) - execExternalProgram(ex & ' ' & config.arguments) + execExternalProgram(conf, ex & ' ' & conf.arguments) when declared(GC_setMaxPause): GC_setMaxPause 2_000 @@ -107,10 +108,10 @@ when declared(GC_setMaxPause): when compileOption("gc", "v2") or compileOption("gc", "refc"): # the new correct mark&sweet collector is too slow :-/ GC_disableMarkAndSweep() -condsyms.initDefines() when not defined(selftest): - handleCmdLine(newIdentCache(), newConfigRef()) + let conf = newConfigRef() + handleCmdLine(newIdentCache(), conf) when declared(GC_setMaxPause): echo GC_getStatistics() - msgQuit(int8(msgs.gErrorCounter > 0)) + msgQuit(int8(conf.errorCounter > 0)) |