the current directory is no longer taken into account when resolving module paths
This commit is contained in:
parent
67bc23bb60
commit
caa4766a33
5 changed files with 24 additions and 30 deletions
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
import
|
import
|
||||||
msgs, hashes, nversion, options, strutils, crc, ropes, idents, lists,
|
msgs, hashes, nversion, options, strutils, crc, ropes, idents, lists,
|
||||||
intsets, idgen, os
|
intsets, idgen
|
||||||
|
|
||||||
const
|
const
|
||||||
ImportTablePos* = 0 # imported symbols are at level 0
|
ImportTablePos* = 0 # imported symbols are at level 0
|
||||||
|
|
@ -1001,18 +1001,3 @@ proc getStrOrChar*(a: PNode): string =
|
||||||
internalError(a.info, "getStrOrChar")
|
internalError(a.info, "getStrOrChar")
|
||||||
result = ""
|
result = ""
|
||||||
|
|
||||||
proc getModuleName*(n: PNode): string =
|
|
||||||
# This returns a short relative module name without the nim extension
|
|
||||||
# e.g. like "system", "importer" or "somepath/module"
|
|
||||||
# The proc won't perform any checks that the path is actually valid
|
|
||||||
case n.kind
|
|
||||||
of nkStrLit, nkRStrLit, nkTripleStrLit:
|
|
||||||
result = UnixToNativePath(n.strVal)
|
|
||||||
of nkIdent:
|
|
||||||
result = n.ident.s
|
|
||||||
of nkSym:
|
|
||||||
result = n.sym.name.s
|
|
||||||
else:
|
|
||||||
internalError(n.info, "getModuleName")
|
|
||||||
result = ""
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
import
|
import
|
||||||
ast, astalgo, strutils, hashes, options, nversion, msgs, os, ropes, idents,
|
ast, astalgo, strutils, hashes, options, nversion, msgs, os, ropes, idents,
|
||||||
wordrecg, math, syntaxes, renderer, lexer, rst, times, highlite
|
wordrecg, math, syntaxes, renderer, lexer, rst, times, highlite, importer
|
||||||
|
|
||||||
proc CommandDoc*()
|
proc CommandDoc*()
|
||||||
proc CommandRst2Html*()
|
proc CommandRst2Html*()
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,21 @@ proc evalImport*(c: PContext, n: PNode): PNode
|
||||||
proc evalFrom*(c: PContext, n: PNode): PNode
|
proc evalFrom*(c: PContext, n: PNode): PNode
|
||||||
proc importAllSymbols*(c: PContext, fromMod: PSym)
|
proc importAllSymbols*(c: PContext, fromMod: PSym)
|
||||||
|
|
||||||
|
proc getModuleName*(n: PNode): string =
|
||||||
|
# This returns a short relative module name without the nim extension
|
||||||
|
# e.g. like "system", "importer" or "somepath/module"
|
||||||
|
# The proc won't perform any checks that the path is actually valid
|
||||||
|
case n.kind
|
||||||
|
of nkStrLit, nkRStrLit, nkTripleStrLit:
|
||||||
|
result = UnixToNativePath(n.strVal)
|
||||||
|
of nkIdent:
|
||||||
|
result = n.ident.s
|
||||||
|
of nkSym:
|
||||||
|
result = n.sym.name.s
|
||||||
|
else:
|
||||||
|
internalError(n.info, "getModuleName")
|
||||||
|
result = ""
|
||||||
|
|
||||||
proc checkModuleName*(n: PNode): string =
|
proc checkModuleName*(n: PNode): string =
|
||||||
# This returns the full canonical path for a given module import
|
# This returns the full canonical path for a given module import
|
||||||
var modulename = n.getModuleName
|
var modulename = n.getModuleName
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
--hint[XDeclaredButNotUsed]=off
|
--hint[XDeclaredButNotUsed]=off
|
||||||
path="llvm"
|
path="llvm"
|
||||||
|
path="$projectPath/.."
|
||||||
|
|
||||||
@if llvm_gcc or gcc:
|
@if llvm_gcc or gcc:
|
||||||
# GCC, LLVM and Visual C++ have a problem to optimize some modules.
|
# GCC, LLVM and Visual C++ have a problem to optimize some modules.
|
||||||
|
|
|
||||||
|
|
@ -189,17 +189,10 @@ iterator iterSearchPath*(): string =
|
||||||
it = PStrEntry(it.Next)
|
it = PStrEntry(it.Next)
|
||||||
|
|
||||||
proc rawFindFile(f: string): string =
|
proc rawFindFile(f: string): string =
|
||||||
template ret(e: expr) =
|
|
||||||
result = e.canonicalizePath
|
|
||||||
return
|
|
||||||
|
|
||||||
if ExistsFile(f):
|
|
||||||
ret f
|
|
||||||
else:
|
|
||||||
for it in iterSearchPath():
|
for it in iterSearchPath():
|
||||||
result = JoinPath(it, f)
|
result = JoinPath(it, f)
|
||||||
if ExistsFile(result):
|
if ExistsFile(result):
|
||||||
ret result
|
return result.canonicalizePath
|
||||||
result = ""
|
result = ""
|
||||||
|
|
||||||
proc FindFile*(f: string): string =
|
proc FindFile*(f: string): string =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue