Fix path resolution of submodules in the std namespace (#8453)

This commit is contained in:
Oscar Nihlgård 2018-07-30 09:07:11 +02:00 • committed by Andreas Rumpf
commit 97ea18746b
2 changed files with 20 additions and 17 deletions

View file

@ -556,13 +556,28 @@ proc findFile*(conf: ConfigRef; f: string; suppressStdlib = false): string {.pro
result = rawFindFile2(conf, f.toLowerAscii)
patchModule(conf)
const stdlibDirs = [
"pure", "core", "arch",
"pure/collections",
"pure/concurrency", "impure",
"wrappers", "wrappers/linenoise",
"windows", "posix", "js"]
proc findModule*(conf: ConfigRef; modulename, currentModule: string): string =
# returns path to module
const pkgPrefix = "pkg/"
let m = addFileExt(modulename, NimExt)
const stdPrefix = "std/"
var m = addFileExt(modulename, NimExt)
if m.startsWith(pkgPrefix):
result = findFile(conf, m.substr(pkgPrefix.len), suppressStdlib = true)
else:
if m.startsWith(stdPrefix):
let stripped = m.substr(stdPrefix.len)
for candidate in stdlibDirs:
let path = (conf.libpath / candidate / stripped)
if fileExists(path):
m = path
break
let currentPath = currentModule.splitFile.dir
result = currentPath / m
if not existsFile(result):