diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2018-09-07 01:53:09 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2018-09-07 01:53:09 +0200 |
commit | ad9db5cb1aab17d12bc0ed20a1ed0548e351b3db (patch) | |
tree | be7af65d131263d1fd619a4e656a1205a871739b /compiler/cmdlinehelper.nim | |
parent | 92863c0e75d32bffb0d7af15310e04cca7da9d3a (diff) | |
download | Nim-ad9db5cb1aab17d12bc0ed20a1ed0548e351b3db.tar.gz |
compiler refactoring; use typesafe path handing; docgen: render symbols between modules
Diffstat (limited to 'compiler/cmdlinehelper.nim')
-rw-r--r-- | compiler/cmdlinehelper.nim | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/compiler/cmdlinehelper.nim b/compiler/cmdlinehelper.nim index 9d2334af5..8bd073314 100644 --- a/compiler/cmdlinehelper.nim +++ b/compiler/cmdlinehelper.nim @@ -1,10 +1,17 @@ -## Helpers for binaries that use compiler passes, eg: nim, nimsuggest, nimfix +# +# +# The Nim Compiler +# (c) Copyright 2018 Nim contributors +# +# See the file "copying.txt", included in this +# distribution, for details about the copyright. +# -# TODO: nimfix should use this; currently out of sync +## Helpers for binaries that use compiler passes, eg: nim, nimsuggest, nimfix import - compiler/[options, idents, nimconf, scriptconfig, extccomp, commands, msgs, lineinfos, modulegraphs, condsyms], - std/os + options, idents, nimconf, scriptconfig, extccomp, commands, msgs, + lineinfos, modulegraphs, condsyms, os, pathutils type NimProg* = ref object @@ -21,27 +28,27 @@ proc processCmdLineAndProjectPath*(self: NimProg, conf: ConfigRef) = self.processCmdLine(passCmd1, "", conf) if self.supportsStdinFile and conf.projectName == "-": conf.projectName = "stdinfile" - conf.projectFull = "stdinfile" - conf.projectPath = canonicalizePath(conf, getCurrentDir()) + conf.projectFull = AbsoluteFile "stdinfile" + conf.projectPath = AbsoluteDir getCurrentDir() conf.projectIsStdin = true elif conf.projectName != "": try: - conf.projectFull = canonicalizePath(conf, conf.projectName) + conf.projectFull = canonicalizePath(conf, AbsoluteFile conf.projectName) except OSError: - conf.projectFull = conf.projectName + conf.projectFull = AbsoluteFile conf.projectName let p = splitFile(conf.projectFull) - let dir = if p.dir.len > 0: p.dir else: getCurrentDir() - conf.projectPath = canonicalizePath(conf, dir) + let dir = if p.dir.isEmpty: AbsoluteDir getCurrentDir() else: p.dir + conf.projectPath = AbsoluteDir canonicalizePath(conf, AbsoluteFile dir) conf.projectName = p.name else: - conf.projectPath = canonicalizePath(conf, getCurrentDir()) + conf.projectPath = AbsoluteDir canonicalizePath(conf, AbsoluteFile getCurrentDir()) proc loadConfigsAndRunMainCommand*(self: NimProg, cache: IdentCache; conf: ConfigRef): bool = loadConfigs(DefaultConfig, cache, conf) # load all config files if self.suggestMode: conf.command = "nimsuggest" - proc runNimScriptIfExists(path: string)= + proc runNimScriptIfExists(path: AbsoluteFile)= if fileExists(path): runNimScript(cache, path, freshDefines = false, conf) @@ -53,8 +60,8 @@ proc loadConfigsAndRunMainCommand*(self: NimProg, cache: IdentCache; conf: Confi runNimScriptIfExists(getUserConfigPath(DefaultConfigNims)) if optSkipParentConfigFiles notin conf.globalOptions: - for dir in parentDirs(conf.projectPath, fromRoot = true, inclusive = false): - runNimScriptIfExists(dir / DefaultConfigNims) + for dir in parentDirs(conf.projectPath.string, fromRoot = true, inclusive = false): + runNimScriptIfExists(AbsoluteDir(dir) / DefaultConfigNims) if optSkipProjConfigFile notin conf.globalOptions: runNimScriptIfExists(conf.projectPath / DefaultConfigNims) @@ -63,10 +70,10 @@ proc loadConfigsAndRunMainCommand*(self: NimProg, cache: IdentCache; conf: Confi if not self.suggestMode: runNimScriptIfExists(scriptFile) # 'nim foo.nims' means to just run the NimScript file and do nothing more: - if fileExists(scriptFile) and scriptFile.cmpPaths(conf.projectFull) == 0: + if fileExists(scriptFile) and scriptFile == conf.projectFull: return false else: - if scriptFile.cmpPaths(conf.projectFull) != 0: + if scriptFile != conf.projectFull: runNimScriptIfExists(scriptFile) else: # 'nimsuggest foo.nims' means to just auto-complete the NimScript file |