summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2012-12-09 23:20:48 +0100
committerAraq <rumpf_a@web.de>2012-12-09 23:20:48 +0100
commita840a4ce53c2344f77c6e07b4f8cbed0af2820dd (patch)
treee2f0853a3f85510744ea5e05514c6c6c5688b476 /compiler
parentb0dc877cc3cb45cce40f7cd9ad281823bf91cd72 (diff)
downloadNim-a840a4ce53c2344f77c6e07b4f8cbed0af2820dd.tar.gz
improvements for --babelPath
Diffstat (limited to 'compiler')
-rw-r--r--compiler/babelcmd.nim24
-rwxr-xr-xcompiler/condsyms.nim1
2 files changed, 20 insertions, 5 deletions
diff --git a/compiler/babelcmd.nim b/compiler/babelcmd.nim
index 99513e58b..97d3bcf6c 100644
--- a/compiler/babelcmd.nim
+++ b/compiler/babelcmd.nim
@@ -9,7 +9,7 @@
 
 ## Implements some helper procs for Babel (Nimrod's package manager) support.
 
-import parseutils, strtabs, os, options, msgs, lists
+import parseutils, strutils, strtabs, os, options, msgs, lists
 
 proc addPath*(path: string, info: TLineInfo) = 
   if not contains(options.searchPaths, path): 
@@ -58,6 +58,23 @@ iterator chosen(packages: PStringTable): string =
     let res = if val == latest: key else: key & '-' & val
     yield res
 
+proc addPathWithNimFiles(p: string, info: TLineInfo) =
+  proc hasNimFile(dir: string): bool =
+    for kind, path in walkDir(dir):
+      if kind == pcFile and path.endsWith(".nim"):
+        return true
+    
+  proc addPath(p: string) =
+    if not contains(options.searchPaths, p):
+      Message(info, hintPath, p)
+      lists.PrependStr(options.searchPaths, p)
+  
+  if hasNimFile(p):
+    addPath(p)
+  else:
+    for kind, p2 in walkDir(p):
+      if hasNimFile(p2): addPath(p2)
+
 proc addPathRec(dir: string, info: TLineInfo) =
   var packages = newStringTable(modeStyleInsensitive)
   var pos = dir.len-1
@@ -65,11 +82,8 @@ proc addPathRec(dir: string, info: TLineInfo) =
   for k,p in os.walkDir(dir):
     if k == pcDir and p[pos] != '.':
       addPackage(packages, p)
-
   for p in packages.chosen:
-    if not contains(options.searchPaths, p):
-      Message(info, hintPath, p)
-      lists.PrependStr(options.searchPaths, p)
+    addPathWithNimFiles(p, info)
 
 proc babelPath*(path: string, info: TLineInfo) =
   addPathRec(path, info)
diff --git a/compiler/condsyms.nim b/compiler/condsyms.nim
index 234029ea9..17366f6e9 100755
--- a/compiler/condsyms.nim
+++ b/compiler/condsyms.nim
@@ -60,6 +60,7 @@ proc InitDefines*() =
   DefineSymbol("niminheritable")
   DefineSymbol("nimmixin")
   DefineSymbol("nimeffects")
+  DefineSymbol("nimbabel")
   
   # add platform specific symbols:
   case targetCPU