summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorDominik Picheta <dominikpicheta@googlemail.com>2015-06-14 18:51:06 +0100
committerDominik Picheta <dominikpicheta@googlemail.com>2015-06-14 18:51:06 +0100
commit2f68b0baf0c7b70c511a9988640ebd946f2408c0 (patch)
tree6ca2550f5347a57fb7767fd17c0f3216e6376f21
parent2782cddb56b2f3b56893915bc227839dc3d246c0 (diff)
downloadNim-2f68b0baf0c7b70c511a9988640ebd946f2408c0.tar.gz
Introduce gPrefixDir for nimsuggest.
-rw-r--r--compiler/options.nim10
1 files changed, 8 insertions, 2 deletions
diff --git a/compiler/options.nim b/compiler/options.nim
index 48e2db0c7..42a13f8e8 100644
--- a/compiler/options.nim
+++ b/compiler/options.nim
@@ -146,6 +146,7 @@ const
 var
   gConfigVars* = newStringTable(modeStyleInsensitive)
   gDllOverrides = newStringTable(modeCaseInsensitive)
+  gPrefixDir* = "" # Overrides the default prefix dir in getPrefixDir proc.
   libpath* = ""
   gProjectName* = "" # holds a name like 'nimrod'
   gProjectPath* = "" # holds a path like /home/alice/projects/nimrod/compiler/
@@ -184,8 +185,13 @@ proc getOutFile*(filename, ext: string): string =
   else: result = changeFileExt(filename, ext)
 
 proc getPrefixDir*(): string =
-  ## gets the application directory
-  result = splitPath(getAppDir()).head
+  ## Gets the prefix dir, usually the parent directory where the binary resides.
+  ##
+  ## This is overrided by some tools (namely nimsuggest) via the ``gPrefixDir``
+  ## global.
+  if gPrefixDir != "": result = gPrefixDir
+  else:
+    result = splitPath(getAppDir()).head
 
 proc canonicalizePath*(path: string): string =
   when not FileSystemCaseSensitive: result = path.expandFilename.toLower