summary refs log tree commit diff stats
diff options
context:
space:
mode:
authortransfuturist <timothy.schmid@gmail.com>2015-05-11 00:02:01 -0700
committertransfuturist <timothy.schmid@gmail.com>2015-05-14 12:52:43 -0700
commit8fc53f29520dd9a5eee86393dad63bd3f16aa54b (patch)
tree277e1c174ab85dcb2a14de057391db179cdb15da
parentc30d7c3208c1da91e3f71be7d8d9f5149f3031c4 (diff)
downloadNim-8fc53f29520dd9a5eee86393dad63bd3f16aa54b.tar.gz
Add path directive to allow inclusion of config file's path itself
-rw-r--r--compiler/commands.nim6
1 files changed, 4 insertions, 2 deletions
diff --git a/compiler/commands.nim b/compiler/commands.nim
index b6ebb6bcb..d30d8326c 100644
--- a/compiler/commands.nim
+++ b/compiler/commands.nim
@@ -229,7 +229,8 @@ proc testCompileOption*(switch: string, info: TLineInfo): bool =
   of "experimental": result = gExperimentalMode
   else: invalidCmdLineOption(passCmd1, switch, info)
 
-proc processPath(path: string, notRelativeToProj = false): string =
+proc processPath(path: string, notRelativeToProj = false,
+                               cfginfo = unknownLineInfo()): string =
   let p = if notRelativeToProj or os.isAbsolute(path) or
               '$' in path or path[0] == '.':
             path
@@ -239,6 +240,7 @@ proc processPath(path: string, notRelativeToProj = false): string =
     "nim", getPrefixDir(),
     "lib", libpath,
     "home", removeTrailingDirSep(os.getHomeDir()),
+    "config", cfginfo.toFullPath().splitFile().dir,
     "projectname", options.gProjectName,
     "projectpath", options.gProjectPath])
 
@@ -281,7 +283,7 @@ proc processSwitch(switch, arg: string, pass: TCmdLinePass, info: TLineInfo) =
   case switch.normalize
   of "path", "p":
     expectArg(switch, arg, pass, info)
-    addPath(processPath(arg), info)
+    addPath(processPath(arg, cfginfo=info), info)
   of "nimblepath", "babelpath":
     # keep the old name for compat
     if pass in {passCmd2, passPP} and not options.gNoNimblePath: