improvements for --babelPath
This commit is contained in:
parent
b0dc877cc3
commit
a840a4ce53
3 changed files with 24 additions and 11 deletions
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
## Implements some helper procs for Babel (Nimrod's package manager) support.
|
## 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) =
|
proc addPath*(path: string, info: TLineInfo) =
|
||||||
if not contains(options.searchPaths, path):
|
if not contains(options.searchPaths, path):
|
||||||
|
|
@ -58,6 +58,23 @@ iterator chosen(packages: PStringTable): string =
|
||||||
let res = if val == latest: key else: key & '-' & val
|
let res = if val == latest: key else: key & '-' & val
|
||||||
yield res
|
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) =
|
proc addPathRec(dir: string, info: TLineInfo) =
|
||||||
var packages = newStringTable(modeStyleInsensitive)
|
var packages = newStringTable(modeStyleInsensitive)
|
||||||
var pos = dir.len-1
|
var pos = dir.len-1
|
||||||
|
|
@ -65,11 +82,8 @@ proc addPathRec(dir: string, info: TLineInfo) =
|
||||||
for k,p in os.walkDir(dir):
|
for k,p in os.walkDir(dir):
|
||||||
if k == pcDir and p[pos] != '.':
|
if k == pcDir and p[pos] != '.':
|
||||||
addPackage(packages, p)
|
addPackage(packages, p)
|
||||||
|
|
||||||
for p in packages.chosen:
|
for p in packages.chosen:
|
||||||
if not contains(options.searchPaths, p):
|
addPathWithNimFiles(p, info)
|
||||||
Message(info, hintPath, p)
|
|
||||||
lists.PrependStr(options.searchPaths, p)
|
|
||||||
|
|
||||||
proc babelPath*(path: string, info: TLineInfo) =
|
proc babelPath*(path: string, info: TLineInfo) =
|
||||||
addPathRec(path, info)
|
addPathRec(path, info)
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,7 @@ proc InitDefines*() =
|
||||||
DefineSymbol("niminheritable")
|
DefineSymbol("niminheritable")
|
||||||
DefineSymbol("nimmixin")
|
DefineSymbol("nimmixin")
|
||||||
DefineSymbol("nimeffects")
|
DefineSymbol("nimeffects")
|
||||||
|
DefineSymbol("nimbabel")
|
||||||
|
|
||||||
# add platform specific symbols:
|
# add platform specific symbols:
|
||||||
case targetCPU
|
case targetCPU
|
||||||
|
|
|
||||||
|
|
@ -13,11 +13,6 @@ cc = gcc
|
||||||
arm.linux.gcc.exe = "arm-linux-gcc"
|
arm.linux.gcc.exe = "arm-linux-gcc"
|
||||||
arm.linux.gcc.linkerexe = "arm-linux-gcc"
|
arm.linux.gcc.linkerexe = "arm-linux-gcc"
|
||||||
|
|
||||||
@if nim:
|
|
||||||
# use the old fixed library for bootstrapping with Nim:
|
|
||||||
lib = "nimlib"
|
|
||||||
@end
|
|
||||||
|
|
||||||
path="$lib/core"
|
path="$lib/core"
|
||||||
path="$lib/pure"
|
path="$lib/pure"
|
||||||
path="$lib/pure/collections"
|
path="$lib/pure/collections"
|
||||||
|
|
@ -36,7 +31,10 @@ path="$lib/windows"
|
||||||
path="$lib/posix"
|
path="$lib/posix"
|
||||||
path="$lib/ecmas"
|
path="$lib/ecmas"
|
||||||
path="$lib/pure/unidecode"
|
path="$lib/pure/unidecode"
|
||||||
path="$home/.babel/libs/"
|
|
||||||
|
@if nimbabel:
|
||||||
|
babelpath="$home/.babel/libs/"
|
||||||
|
@end
|
||||||
|
|
||||||
@if release or quick:
|
@if release or quick:
|
||||||
obj_checks:off
|
obj_checks:off
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue