summary refs log tree commit diff stats
path: root/compiler/options.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2012-12-11 20:06:15 +0100
committerAraq <rumpf_a@web.de>2012-12-11 20:06:15 +0100
commitc98696d7428346b53c8998bf8fab77fe08830e2e (patch)
treef28cfd250d0b64fe5c5259908df52fdf5d9c8366 /compiler/options.nim
parenta840a4ce53c2344f77c6e07b4f8cbed0af2820dd (diff)
downloadNim-c98696d7428346b53c8998bf8fab77fe08830e2e.tar.gz
lazy paths for Babel support
Diffstat (limited to 'compiler/options.nim')
-rwxr-xr-xcompiler/options.nim29
1 files changed, 22 insertions, 7 deletions
diff --git a/compiler/options.nim b/compiler/options.nim
index 42fca1ad1..b8e65f8e3 100755
--- a/compiler/options.nim
+++ b/compiler/options.nim
@@ -88,7 +88,7 @@ var
                          optPatterns}
   gGlobalOptions*: TGlobalOptions = {optRefcGC, optThreadAnalysis}
   gExitcode*: int8
-  searchPaths*: TLinkedList
+  searchPaths*, lazyPaths*: TLinkedList
   outFile*: string = ""
   headerFile*: string = ""
   gCmd*: TCommands = cmdNone  # the command
@@ -194,22 +194,37 @@ proc completeGeneratedFilePath*(f: string, createSubDir: bool = true): string =
   result = joinPath(subdir, tail)
   #echo "completeGeneratedFilePath(", f, ") = ", result
 
-iterator iterSearchPath*(): string = 
+iterator iterSearchPath*(SearchPaths: TLinkedList): string = 
   var it = PStrEntry(SearchPaths.head)
-  while it != nil: 
+  while it != nil:
     yield it.data
     it = PStrEntry(it.Next)
 
 proc rawFindFile(f: string): string =
-  for it in iterSearchPath():
+  for it in iterSearchPath(SearchPaths):
     result = JoinPath(it, f)
-    if ExistsFile(result):
+    if existsFile(result):
       return result.canonicalizePath
   result = ""
 
+proc rawFindFile2(f: string): string =
+  var it = PStrEntry(lazyPaths.head)
+  while it != nil:
+    result = JoinPath(it.data, f)
+    if existsFile(result):
+      bringToFront(lazyPaths, it)
+      return result.canonicalizePath
+    it = PStrEntry(it.Next)
+  result = ""
+
 proc FindFile*(f: string): string {.procvar.} = 
-  result = rawFindFile(f)
-  if len(result) == 0: result = rawFindFile(toLower(f))
+  result = f.rawFindFile
+  if result.len == 0:
+    result = f.toLower.rawFindFile
+    if result.len == 0:
+      result = f.rawFindFile2
+      if result.len == 0:
+        result = f.toLower.rawFindFile2
 
 proc findModule*(modulename: string): string {.inline.} =
   # returns path to module